there direct graph n vertex number 1 n vertex n outgoing arcs red blue at point time exactly arcs active vertex initially blue arc active token locate vertex 1 in second vertex token switch active arcs inactive arc active vice versa then token move active arc when token reach vertex n stop it guarantee n reachable arc vertexyou give q query each query contain state graph pair v s follow form v vertex token currently locate s string consist n 1 character the ith character correspond color active edge lead ith vertex character r red arc active character b for query determine give state reachable initial state time configuration appear note operation change active arc traverse atomic state consider reach appear change active arc traverse