spoj#FROGS. Frog Wrestling

Frog Wrestling

Billy Jean loves collecting frogs.  Recently, she developed the sport of frog wrestling.  Now she wants to rank her frogs by their wrestling prowess.

Billy Jean has made a algorithm for sorting her frogs.

  1. She arranges N cages, numbered 1,2,...N, each with one frog.
  2. For each pair of cages in a specified, pre-determined list of K pairs of cages,
    1. she removes the frogs from the two cages,
    2. has the frogs wrestle,
    3. puts the winner in the higher-numbered cage, and
    4. puts the loser in the lower-numbered cage.

When she is finished, she hopes to have all her frogs sorted from worst to best in the cages 1 to N.  Will her algorithm work regardless of the initial order of the frogs?

Note:

  • Assume that a strict ordering by wrestling ability is possible.
  • Billy Jean isn't the sharpest tool in the shed.  Sometimes she has written the same two numbers for a pair.  In this case, that frog is simply taken out and then put back.

Constraints

1<=N<=20

1<=K<=1000

Input

The first line is the number of test cases.  Each test cases is preceded by a blank line.

The first line of each test case is N.  The next line is K.  The next K lines are the pairs, separated by a single space.

Output

On separate lines, output whether Billy Jean's algorithm is correct.  Output "YES" (without quotes) if it is or "NO" (without quotes) if it is not.

Example

Input:
4

2
1
2 1

2
1
1 1

1
1
1 1

4
5
1 2
3 4
1 3
2 4
2 3

Output: YES
NO
YES
YES