you give direct graph consist n vertex each direct edge arc label single character Initially graph emptyyou process m query each query type u v c add arc u v label c its guarantee arc u v graph moment u v erase arc u v its guarantee graph contain arc u v moment k find sequence k vertex v_1 v_2 dot v_k exist route v_1 v_2 dot v_k v_k v_k 1 dot v_1 write character route you ll stre you visit vertex number time