E. Relationships
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

After many hours of stalking a group of $$$n$$$ people, you notice that each pair of persons has a relationship. Denote $$$R(A,B)$$$ the type of relationship between persons $$$A$$$ and $$$B$$$.

There are exactly $$$10^{18}$$$ types of relationships, numbered $$$1,2,\dots,10^{18}$$$.

It is also known that the relationsip is symetric, that is, $$$R(A,B)=R(B,A)$$$.

The group is called stable if for each three distinct persons $$$A$$$, $$$B$$$ and $$$C$$$, the set $$$\{R(A,B),R(B,C),R(C,A)\}$$$ contains exactly $$$1$$$ or $$$3$$$ distinct numbers.

You know the types of $$$m$$$ relationships. Is it possible that the group is stable?

Input

The first number contains an integer $$$t$$$ $$$(1 \leq t \leq 10^4)$$$, denoting the number of testcases.

For each testcase, the first line contains two integers $$$n$$$,$$$m$$$ $$$(2 \leq n,m \leq 10^5)$$$, denoting the number of people in the group and the number of known relationships.

The next $$$m$$$ lines contain three integers $$$a$$$,$$$b$$$,$$$c$$$ $$$(1 \leq a,b \leq n, 1 \leq c \leq m, a \neq b)$$$, indicating that the $$$a$$$-th person and the $$$b$$$-th person have a relationship of type $$$c$$$.

The sum of $$$n+m$$$ on all testcases is at most $$$2 \times 10^5$$$.

It is guaranteed that the unordered pair $$$\{a,b\}$$$ does not appear more than once.

Output

For each testcase, output a single line containing "YES" if there is a possible way other people have relationships so that the group is stable, or "NO" otherwise.

Example
Input
2
10 3
1 2 1
3 4 1
2 3 2
10 4
1 2 1
3 4 1
2 3 1
1 4 2
Output
YES
NO