#P3907. 环的异或

环的异或

Description

Given an undirected graph GG, the weight of edge (Ai,Bi)(A_i, B_i) is CiC_i. Determine whether the following property holds: For any cycle CC, the XOR of the edge weights along CC is 00.

Input Format

The first line contains an integer TT, denoting the number of test cases. For each test case, the first line contains two integers N,MN, M, denoting the numbers of vertices and edges of graph GG. The next MM lines each contain three integers Ai,Bi,CiA_i, B_i, C_i.

Output Format

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

2
3 3
1 2 1
2 3 2
3 1 3
1 1
1 1 1
Yes
No

Hint

  • For 50% of the testdata, N,M20N, M \le 20.
  • For 100% of the testdata, 1T101 \le T \le 10, 1N,M501 \le N, M \le 50, 1Ai,BiN1 \le A_i, B_i \le N, 0Ci<1050 \le C_i < 10^5.

Translated by ChatGPT 5