#Lutece2874. 幸运之环

幸运之环

Migrated from Lutece 2874 幸运之环

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

Kanade 收到了一些连通无向图。对于每张图,都保证没有重边和自环。图中的每条边都有一个边权。

Kanade 认为,对于图中的简单环(即不含重复点的环),如果构成这个简单环的边的边权异或和为 00,那么她就认为这个环是「幸运」的。

如果某张图的所有简单环都是「幸运」的,那么 Kanade 会把这张图送给 Isla 当礼物。当然,如果某张图没有简单环,它也是满足送出条件的。请帮 Kanade 挑选出所有可以送给 Isla 当礼物的图。

Input

第一行一个正整数 T (1T104)T\ (1\le T\le 10^4),表示 Kanade 收到的图的个数。

对于每组数据,第一行两个整数 n,m (2n105,n1m3×105)n,m\ (2\le n\le 10^5, n-1\le m\le 3\times 10^5),分别表示一张图的点数和边数。

接下来 mm 行,每行三个整数 ui,vi,wi (1ui,vin,0wi109)u_i,v_i,w_i\ (1\le u_i,v_i\le n,0\le w_i\le 10^9),描述这张图。保证图中无重边,无自环,并且保证图是连通图。

对于全部数据,保证 n5×105,m106\sum n\le 5\times 10^5,\sum m\le 10^6

Output

对于每组数据,输出一行。如果这张图可以送给 Isla,输出 Yes,否则输出 No

Samples

4
2 1
1 2 3
4 4
1 2 1
2 3 2
3 4 3
4 1 1
4 4
1 2 1
2 3 3
3 4 2
4 1 0
6 8
1 2 6
2 3 1
3 5 6
3 1 5
4 5 0
3 6 0
4 2 8
4 1 1
Yes
No
Yes
No

Resources

The 20th UESTC Programming Contest Preliminary