you undirected graph consist n vertex weight edgesA simple cycle cycle graph repeat vertex let weight cycle XOR weight edge consist oflet graph good simple cycle weight 1 a graph bad goodinitially graph then q query follow each query type u v x add edge vertex u v weight x do not graph bad for query print edge add