## Good Graph solution codeforces

You have an undirected graph consisting of nn vertices with weighted edges.

A simple cycle is a cycle of the graph without repeated vertices. Let the weight of the cycle be the XOR of weights of edges it consists of.

Let’s say the graph is good if all its simple cycles have weight 11. A graph is bad if it’s not good.

Initially, the graph is empty. Then qq queries follow. Each query has the next type:

- uu vv xx — add edge between vertices uu and vv of weight xx if it doesn’t make the graph bad.

For each query print, was the edge added or not.

The first line contains two integers nn and qq (3≤n≤3⋅1053≤n≤3⋅105; 1≤q≤5⋅1051≤q≤5⋅105) — the number of vertices and queries.

Next qq lines contain queries — one per line. Each query contains three integers uu, vv and xx (1≤u,v≤n1≤u,v≤n; u≠vu≠v; 0≤x≤10≤x≤1) — the vertices of the edge and its weight.

It’s guaranteed that there are no multiple edges in the input.

For each query, print YES if the edge was added to the graph, or NO otherwise (both case-insensitive).

input

9 12 6 1 0 1 3 1 3 6 0 6 2 0 6 4 1 3 4 1 2 4 0 2 5 0 4 5 0 7 8 1 8 9 1 9 7 0

output

YES YES YES YES YES NO YES YES NO YES YES NO