P3907 XOR of Cycles

Description

Given an undirected graph $G$, the weight of edge $(A_i, B_i)$ is $C_i$. Determine whether the following property holds: For any cycle $C$, the XOR of the edge weights along $C$ is $0$.

Input Format

The first line contains an integer $T$, denoting the number of test cases. For each test case, the first line contains two integers $N, M$, denoting the numbers of vertices and edges of graph $G$. The next $M$ lines each contain three integers $A_i, B_i, C_i$.

Output Format

For each test case, output one line: Yes or No.

Explanation/Hint

- For 50% of the testdata, $N, M \le 20$. - For 100% of the testdata, $1 \le T \le 10$, $1 \le N, M \le 50$, $1 \le A_i, B_i \le N$, $0 \le C_i < 10^5$. Translated by ChatGPT 5