Read problems statements in Mandarin Chinese  and Russian. 

The following is an easy game that the setter of this problem played when he was 8:

A boatman, a wolf, a sheep, and a cabbage are on the bank of a river. They have a small boat that is capable of carrying the boatman and at most one other animal/item with him. However, if left alone by the boatman, the wolf can eat the sheep, and the sheep can eat the cabbage. How can all four be moved safely to the opposite bank of the river?

Here is a nice visualization of the whole process in the original game. Disclaimer: writers, testers and CodeChef are not related to this link.

This leads to a more general problem. If there are other groups of animals/items with the boatman, is it possible to move them all to the opposite bank of the river in such a way that nobody/nothing gets eaten?

We will give you the number of animals/items (not including the boatman). Moreover, we will give you all a list of pairs of the form "X Y" where the X-th animal/item will be eaten by the Y-th one if they are both on the opposite bank to the boatman.

You are to determine whether it is possible to achieve the task or not.

------ Input ------ 

The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.

The first line of each test contains two space separated integers N and M - the number of animals/items not including the boatman, and the number of relations of the form "X will be eaten by Y", respectively.

The following M lines contain pairs of the form X Y with the meaning that the X-th animal/item will be eaten by the Y-th one if they are both on the opposite bank to the boatman.

------ Output ------ 

For each test case, output a single line containing either "YES" or "NO" - the answer to the question "Is it possible to move them all to the opposite bank of the river in such a way that nobody/nothing gets eaten?".

------ Constraints ------ 

$1 ≤ T ≤ 100000$
$Subtask 1: 1 ≤ N ≤ 5,  0 ≤ M ≤ 10 - 73 points.$
$Subtask 2: 1 ≤ N ≤ 10,  0 ≤ M ≤ 20 - 27 points.$

----- Sample Input 1 ------ 
2
3 2
1 2
2 3
3 3
1 2
2 3
1 3
----- Sample Output 1 ------ 
YES
NO
----- explanation 1 ------ 
The first example is the original version of the problem.

The second example would have a solution if a boat could seat an additional animal/item.

Source: codechef | Difficulty: MEDIUM_HARD


Solutions:
testcases = int(input())
for _ in range(testcases):
	(n, m) = map(int, input().split())
	l = []
	if m > 2:
		print('NO')
		for i in range(m):
			input()
	elif m == 0:
		print('YES')
	elif m == 1:
		print('YES')
		input()
	else:
		for i in range(m):
			(x, y) = map(int, input().split())
			if x not in l:
				l.append(x)
			if y not in l:
				l.append(y)
		if len(l) < 4:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	nodes = set()
	edges = set()
	for __ in range(m):
		(i, j) = map(int, input().split())
		nodes.add(i)
		nodes.add(j)
		edges.add((i, j))
	if len(nodes) < 3:
		print('YES')
	elif len(nodes) == 3 and len(edges) < 3:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [0] * n
	for i in range(m):
		(l, r) = map(int, input().split())
		(a[l - 1], a[r - 1]) = (1, 1)
	print('NO') if sum(a) > 3 or m > 2 else print('YES')


t = int(input())
for o in range(t):
	(n, m) = map(int, input().split())
	d = []
	if m > 2:
		print('NO')
		for i in range(m):
			input()
	elif m == 0:
		print('YES')
	elif m == 1:
		print('YES')
		input()
	else:
		for i in range(m):
			(x, y) = map(int, input().split())
			if x not in d:
				d.append(x)
			if y not in d:
				d.append(y)
		if len(d) < 4:
			print('YES')
		else:
			print('NO')


t = int(input())
for o in range(t):
	(n, m) = map(int, input().split())
	arr = set()
	for i in range(m):
		(u, v) = map(int, input().split())
		arr.add(u)
		arr.add(v)
	if m > 2:
		print('NO')
	elif len(arr) > 3:
		print('NO')
	else:
		print('YES')


t = int(input())
for j in range(t):
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	l = [0] * (n + 1)
	for i in range(m):
		(x, y) = input().split()
		x = int(x)
		y = int(y)
		l[x] = 1
		l[y] = 1
	n = sum(l)
	if m == 0 or m == 1:
		print('YES')
	elif m == 2 and n <= 3:
		print('YES')
	else:
		print('NO')


k = int(input())
for p in range(k):
	(a, b) = map(int, input().split())
	arr = set()
	for i in range(b):
		(x, y) = map(int, input().split())
		arr.add(x)
		arr.add(y)
	if b > 2:
		print('NO')
	elif len(arr) > 3:
		print('NO')
	else:
		print('YES')