you give undirected connect graph weight edge the length path vertice bitwise xor weight edge belong path edge traverse include bitwise xor number time there type query process 1 x y d add edge connect vertex x vertex y weight d it guarantee edge connect x y query 2 x y remove edge connect vertex x vertex y it guarantee edge graph graph stay connect query 3 x y calculate length short path possibly nonsimple vertex x vertex y Print answer query type 3