Masha has $n$ types of tiles of size $2 \times 2$. Each cell of the tile contains one integer. Masha has an infinite number of tiles of each type.

Masha decides to construct the square of size $m \times m$ consisting of the given tiles. This square also has to be a symmetric with respect to the main diagonal matrix, and each cell of this square has to be covered with exactly one tile cell, and also sides of tiles should be parallel to the sides of the square. All placed tiles cannot intersect with each other. Also, each tile should lie inside the square. See the picture in Notes section for better understanding.

Symmetric with respect to the main diagonal matrix is such a square $s$ that for each pair $(i, j)$ the condition $s[i][j] = s[j][i]$ holds. I.e. it is true that the element written in the $i$-row and $j$-th column equals to the element written in the $j$-th row and $i$-th column.

Your task is to determine if Masha can construct a square of size $m \times m$ which is a symmetric matrix and consists of tiles she has. Masha can use any number of tiles of each type she has to construct the square. Note that she can not rotate tiles, she can only place them in the orientation they have in the input.

You have to answer $t$ independent test cases.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 100$) — the number of test cases. Then $t$ test cases follow.

The first line of the test case contains two integers $n$ and $m$ ($1 \le n \le 100$, $1 \le m \le 100$) — the number of types of tiles and the size of the square Masha wants to construct.

The next $2n$ lines of the test case contain descriptions of tiles types. Types of tiles are written one after another, each type is written on two lines. 

The first line of the description contains two positive (greater than zero) integers not exceeding $100$ — the number written in the top left corner of the tile and the number written in the top right corner of the tile of the current type. The second line of the description contains two positive (greater than zero) integers not exceeding $100$ — the number written in the bottom left corner of the tile and the number written in the bottom right corner of the tile of the current type.

It is forbidden to rotate tiles, it is only allowed to place them in the orientation they have in the input.


-----Output-----

For each test case print the answer: "YES" (without quotes) if Masha can construct the square of size $m \times m$ which is a symmetric matrix. Otherwise, print "NO" (withtout quotes).


-----Example-----
Input
6
3 4
1 2
5 6
5 7
7 4
8 9
9 8
2 5
1 1
1 1
2 2
2 2
1 100
10 10
10 10
1 2
4 5
8 4
2 2
1 1
1 1
1 2
3 4
1 2
1 1
1 1

Output
YES
NO
YES
NO
YES
YES



-----Note-----

The first test case of the input has three types of tiles, they are shown on the picture below. [Image] 

Masha can construct, for example, the following square of size $4 \times 4$ which is a symmetric matrix: $\left. \begin{array}{|c|c|c|c|} \hline 5 & {7} & {8} & {9} \\ \hline 7 & {4} & {9} & {8} \\ \hline 8 & {9} & {5} & {7} \\ \hline 9 & {8} & {7} & {4} \\ \hline \end{array} \right.$

Source: codeforces | Difficulty: EASY
Tags: Implementation


Solutions:
t = int(input())
while t:
	(n, m) = list(map(int, input().split()))
	right = False
	for _ in range(n):
		(a, b) = list(map(int, input().split()))
		(c, d) = list(map(int, input().split()))
		if c == b and m & 1 == 0:
			right = True
	if right:
		print('YES')
	else:
		print('NO')
	t -= 1


l = []
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	flg = 1
	for i in range(n):
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		if a == y:
			flg = 0
	if m % 2 == 1:
		l.append('NO')
	elif flg == 1:
		l.append('NO')
	else:
		l.append('YES')
for i in l:
	print(i)


from sys import stdout, stdin
from collections import defaultdict, deque
import math
t = int(stdin.readline())
for _ in range(t):
	(n, k) = map(int, stdin.readline().split())
	flag = False
	for i in range(n):
		(x, y) = map(int, stdin.readline().split())
		(z, zz) = map(int, stdin.readline().split())
		if flag == False:
			if y == z:
				flag = True
	if k % 2 == 0:
		if flag:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	flag = False
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			flag = True
	if m & 1:
		print('NO')
		continue
	if flag:
		print('YES')
	else:
		print('NO')


import sys
infile = sys.stdin
next(infile)
s = [[0, 0], [0, 0]]
for line in infile:
	l1 = list(map(int, line.split()))
	n = l1[0]
	m = l1[1]
	c = 0
	for i in range(n):
		l2 = list(map(int, infile.readline().split()))
		s[0][0] = l2[0]
		s[0][1] = l2[1]
		l3 = list(map(int, infile.readline().split()))
		s[1][0] = l3[0]
		s[1][1] = l3[1]
		if s[0][1] == s[1][0]:
			c += 1
	if m % 2 != 0:
		print('NO')
	elif c == 0:
		print('NO')
	else:
		print('YES')


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	flag = 0
	for j in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			flag = 1
	if m % 2 == 1 or flag == 0:
		print('NO')
	else:
		print('YES')


def main(n, m, matrix):
	if m % 2 != 0:
		return 'NO'
	eligible = 0
	for i in range(n):
		if matrix[i][1] == matrix[i][2]:
			eligible += 1
	if eligible > 0:
		return 'YES'
	return 'NO'
k = int(input())
for _ in range(k):
	(n, m) = map(int, input().split())
	matrix = []
	for i in range(0, 2 * n, 2):
		s = list(map(int, input().strip().split()))
		s2 = list(map(int, input().strip().split()))
		s.extend(s2)
		matrix.append(s)
	print(main(n, m, matrix))


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	flg = False
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			flg = True
	if m % 2 == 0 and flg == True:
		print('YES')
	else:
		print('NO')


cases = int(input())
for _ in range(cases):
	s = 'NO'
	(no_matrix, m) = map(int, input().split())
	for i in range(no_matrix):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if c == b and m % 2 == 0:
			s = 'YES'
	print(s)


def mat(a, b, c, d, x):
	if b == c:
		x += 1
	return x
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	x = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		x = mat(a, b, c, d, x)
	if m % 2 != 0:
		print('NO')
	elif x >= 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	flag = 1
	for i in range(n):
		(a, b) = list(map(int, input().split()))
		(d, c) = list(map(int, input().split()))
		if b == d and m % 2 == 0:
			flag = 0
	if flag == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for h in range(t):
	sh = list(map(int, input().split()))
	n = sh[0]
	m = sh[1]
	til = []
	hr = 0
	for j in range(n):
		t0 = list(map(int, input().split()))
		t1 = list(map(int, input().split()))
		if t0[1] == t1[0]:
			hr = 1
	if m % 2 == 1:
		print('NO')
	elif hr == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for j in range(t):
	(n, x) = map(int, input().split())
	g = False
	t = False
	for j in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			g = True
	if x % 2 == 1:
		print('NO')
	elif g:
		print('YES')
	else:
		print('NO')


from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	ans = 'NO'
	for i in range(n):
		a = [[int(x) for x in input().split()] for _ in range(2)]
		if a[0][1] == a[1][0]:
			ans = 'YES'
	if m % 2 > 0:
		ans = 'NO'
	print(ans)


t = int(input())
for z in range(t):
	arr = []
	(n, m) = map(int, input().split())
	for o in range(n):
		(tl, tr) = map(int, input().split())
		(bl, br) = map(int, input().split())
		arr.append([tl, tr, bl, br])
	if m % 2 == 0:
		ok = 0
		for num in arr:
			if num[1] == num[2]:
				ok = 1
		if ok == 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def solve():
	(n, m) = [int(v) for v in input().split()]
	mp = set()
	foundasym = False
	foundcomps = False
	for _ in range(n):
		mat = []
		mat.append(tuple((int(v) for v in input().split())))
		mat.append(tuple((int(v) for v in input().split())))
		comp = []
		for c in range(2):
			arr = []
			for r in range(2):
				arr.append(mat[r][c])
			comp.append(tuple(arr))
		if tuple(comp) in mp or mat == comp:
			foundcomps = True
		if mat[1][0] == mat[0][1]:
			foundasym = True
		mp.add(tuple(mat))
	if m % 2 != 0 or not (foundasym and foundcomps):
		print('NO')
	else:
		print('YES')
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	if m % 2 != 0:
		for i in range(2 * n):
			(r, c) = map(int, input().split())
		print('NO')
	else:
		cnt = 0
		for i in range(n):
			arr = []
			for j in range(2):
				r = list(map(int, input().split()))
				arr.append(r)
			if arr[0][1] == arr[1][0]:
				cnt += 1
		if cnt > 0:
			print('YES')
		else:
			print('NO')


t = int(input())
for u in range(t):
	ch = 0
	cod = input()
	cod = cod.split()
	(n, m) = (int(cod[0]), int(cod[1]))
	for i in range(2 * n):
		cd = input()
		cd = cd.split()
		if i % 2 == 0:
			l = cd[1]
		elif cd[0] == l:
			ch = 1
	if ch == 1 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	ok = False
	(p, q, r, s) = (0, 0, -1, 0)
	for i in range(2 * n):
		if i % 2 == 0:
			(p, q) = map(int, input().split())
		else:
			(r, s) = map(int, input().split())
			if q == r:
				ok = True
	if m % 2 == 1:
		print('NO')
	elif ok:
		print('YES')
	else:
		print('NO')


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write('\n'.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
from decimal import Decimal
mod = 998244353
INF = float('inf')
for t in range(int(data())):
	(n, m) = mdata()
	flag = False
	for i in range(n):
		(a, b) = mdata()
		(c, d) = mdata()
		if b == c:
			flag = True
	if m % 2 == 0 and flag:
		out('YES')
	else:
		out('NO')


from math import *
t = int(input())
while t:
	t = t - 1
	(n, m) = map(int, input().split())
	if m % 2:
		for i in range(n):
			(a, b) = map(int, input().split())
			(c, d) = map(int, input().split())
		print('NO')
	elif 1:
		flag = 0
		for i in range(n):
			(a, b) = map(int, input().split())
			(c, d) = map(int, input().split())
			if b == c:
				flag = 1
		if flag:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr = [[0 for j in range(4)] for i in range(n)]
	for i in range(n):
		(arr[i][0], arr[i][1]) = map(int, input().split())
		(arr[i][2], arr[i][3]) = map(int, input().split())
	conditions = [False for i in range(1)]
	for i in range(n):
		if arr[i][1] == arr[i][2]:
			conditions[0] = True
			break
	if m % 2 == 1:
		print('NO')
		continue
	if conditions[0]:
		print('YES')
	else:
		print('NO')


def main(matrix_arr, m):
	if m & 1:
		return 'NO'
	for matrix in matrix_arr:
		if matrix[0][1] == matrix[1][0]:
			return 'YES'
	return 'NO'
t = int(input().strip())
for _ in range(t):
	matrix_arr = []
	(n, m) = map(int, input().strip().split())
	for i in range(n):
		matrix = []
		r0 = list(map(int, input().strip().split()))
		r1 = list(map(int, input().strip().split()))
		matrix = [r0, r1]
		matrix_arr.append(matrix)
	print(main(matrix_arr, m))


N = int(input())
for i in range(N):
	(n, m) = map(int, input().split())
	possible = 0
	for i in range(n):
		(f1, f2) = map(int, input().split())
		(f3, f4) = map(int, input().split())
		if f2 == f3:
			possible = 1
	if possible == 1 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	a = []
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	ans = False
	for i in range(2 * n):
		a.append(input().split())
		if i % 2 != 0:
			if a[i - 1][1] == a[i][0]:
				ans = True
	if m % 2 != 0:
		print('NO')
	elif ans:
		print('YES')
	else:
		print('NO')


t = int(input())
for t in range(0, t):
	q = list(map(int, input().rstrip().split()))
	n = q[0]
	m = q[1]
	flag = 0
	for i in range(0, n):
		r1 = list(map(int, input().rstrip().split()))
		r2 = list(map(int, input().rstrip().split()))
		if r1[1] == r2[0]:
			flag = flag + 1
	if m % 2 == 0 and flag > 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [0] * 4
	ans = 'NO'
	for z in range(n):
		for y in range(0, 3, 2):
			(a[y], a[y + 1]) = map(int, input().split())
		if a[1] == a[2] and (not m % 2):
			ans = 'YES'
	print(ans)


def sym(x):
	if x[0][1] == x[1][0]:
		return True
	else:
		return False
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	c = 0
	for _ in range(n):
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		x = [a, b]
		if sym(x):
			c += 1
	if c != 0 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = [int(p) for p in input().split()]
	flag = False
	for i in range(n):
		(x1, x2) = [int(p) for p in input().split()]
		(x3, x4) = [int(p) for p in input().split()]
		if x2 == x3:
			flag = True
	if m % 2 == 1:
		print('NO')
		continue
	print('YES' if flag else 'NO')


def mezrab(squar):
	if squar % 2 == 0:
		return True
	else:
		return False
t = int(input())
for k in range(t):
	flag = False
	(n, m) = map(int, input().split())
	for p in range(n):
		(tl, tr) = map(int, input().split())
		(bl, br) = map(int, input().split())
		if tr == bl:
			flag = True
	if mezrab(m):
		if flag == False:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	tiles = [[] for j in range(n)]
	for j in range(2 * n):
		line = list(map(int, input().split()))
		tiles[j // 2] = tiles[j // 2] + line
	if m % 2 != 0:
		print('NO')
		continue
	check = False
	for tile in tiles:
		if tile[1] == tile[2]:
			check = True
			break
	if check == True:
		print('YES')
	else:
		print('NO')


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True

def main():
	for z in range(ii()):
		f = 0
		(n, m) = mi()
		for i in range(n):
			(a, b) = mi()
			(c, d) = mi()
			if b == c:
				f = 1
		if f == 1 and m % 2 == 0:
			print('YES')
		else:
			print('NO')
main()


for test in range(int(input())):
	(n, m) = map(int, input().split())
	arr = [tuple(map(int, input().split())) for i in range(2 * n)]
	if m % 2 == 0:
		ans = False
		for x in range(0, 2 * n, 2):
			if arr[x][1] == arr[x + 1][0]:
				ans = True
				break
		if ans:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


from math import *
for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	yes = 0
	for i in range(n):
		b = [list(map(int, input().split())), list(map(int, input().split()))]
		if b[0][1] == b[1][0]:
			yes = 1
	if m % 2 == 1:
		print('NO')
	elif yes == 0:
		print('NO')
	else:
		print('YES')


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
sys.setrecursionlimit(10 ** 5)

def mod():
	return 1000000007

def ii():
	return int(sys.stdin.readline())

def si():
	return sys.stdin.readline().strip()

def li():
	return list(sys.stdin.readline().strip())

def mii():
	return map(int, sys.stdin.readline().split())

def lii():
	return list(map(int, sys.stdin.readline().strip().split()))

def solve():
	(n, m) = mii()
	flag = None
	for _ in range(n):
		(a, b) = mii()
		(c, d) = mii()
		if a == b == c == d:
			flag = True
		elif b == c:
			flag = True
		elif flag == None:
			flag = False
	if m % 2 == 1:
		print('NO')
	elif flag:
		print('YES')
	else:
		print('NO')
for _ in range(ii()):
	solve()


def cal(n, m, arr):
	if m % 2 != 0:
		return 'NO'
	for i in range(n):
		if arr[i][0][1] == arr[i][1][0]:
			return 'YES'
	return 'NO'
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr = []
	for _ in range(n):
		temp = []
		(a, b) = map(int, input().split())
		temp.append([a, b])
		(a, b) = map(int, input().split())
		temp.append([a, b])
		arr.append(temp)
	print(cal(n, m, arr))


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	diag = False
	for _ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			diag = True
	if m % 2 == 1:
		print('NO')
	else:
		print('YES' if diag else 'NO')


import sys
t = int(sys.stdin.readline().strip())
for _ in range(t):
	(n, m) = map(int, sys.stdin.readline().strip().split())
	f = False
	for i in range(n):
		p1 = list(map(int, sys.stdin.readline().strip().split()))
		p2 = list(map(int, sys.stdin.readline().strip().split()))
		if p1[1] == p2[0] and (not f):
			f = True
	print('YES') if f and m % 2 == 0 else print('NO')


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
t = int(stdin.readline())
for _ in range(t):
	(n, m) = list(map(int, stdin.readline().rstrip().split()))
	chk = False
	for i in range(n):
		r1 = list(map(int, stdin.readline().rstrip().split()))
		r2 = list(map(int, stdin.readline().rstrip().split()))
		if r1[1] == r2[0]:
			chk = True
	if m % 2 == 1:
		print('NO')
		continue
	if chk:
		print('YES')
	else:
		print('NO')


def iinput():
	return [int(i) for i in input().split()]

def solve(n, x):
	pass
t = int(input())
for _ in range(t):
	(n, m) = iinput()
	fl = False
	mas = []
	for _ in range(n):
		(lv, pv) = iinput()
		(ln, pn) = iinput()
		mas.append([pv, ln])
	if m % 2:
		print('NO')
		continue
	for i in mas:
		if i[0] == i[1]:
			print('YES')
			fl = True
			break
	if not fl:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	flag = 0
	for j in range(n):
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		if a[1] == b[0]:
			flag = 1
			continue
	if flag == 1 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


import os
import sys
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def seive(n):
	primes = [True] * (n + 1)
	ans = []
	for i in range(2, n):
		if not primes[i]:
			continue
		j = 2 * i
		while j <= n:
			primes[j] = False
			j += i
	for p in range(2, n + 1):
		if primes[p]:
			ans += [p]
	return ans

def factors(n):
	factors = []
	x = 2
	while x * x <= n:
		while n % x == 0:
			factors.append(x)
			n //= x
		if n > 1:
			factors.append(x)
	return factors

def main():
	try:
		for _ in range(inp()):
			(n, m) = invr()
			f = False
			for i in range(n):
				x = inlt()
				y = inlt()
				if x[1] == y[0]:
					f = True
			if f and (not m % 2):
				print('YES')
			else:
				print('NO')
	except Exception as e:
		print(e)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	sim = False
	for i in range(n):
		(a, b) = list(map(int, input().split()))
		(c, d) = list(map(int, input().split()))
		if c == b:
			sim = True
	if m % 2 == 1:
		print('NO')
	elif sim:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	f = 0
	for i in range(n):
		s1 = list(map(int, input().split()))
		s2 = list(map(int, input().split()))
		if s1[1] == s2[0]:
			f = 1
	if x % 2 == 1 or f == 0:
		print('NO')
	else:
		print('YES')


import sys
from sys import flags
t = int(sys.stdin.readline())
for _ in range(t):
	(n, m) = map(int, sys.stdin.readline().split())
	answ = 'NO'
	for _ in range(n):
		(a, b) = map(int, sys.stdin.readline().split())
		(c, d) = map(int, sys.stdin.readline().split())
		if b == c:
			answ = 'YES'
	if m % 2:
		answ = 'NO'
	print(answ)


t = int(input())
for i in range(t):
	(n, m) = [int(i) for i in input().split()]
	e = False
	for j in range(n):
		(q, w) = [int(i) for i in input().split()]
		(q1, w1) = [int(i) for i in input().split()]
		if w == q1:
			e = True
	if e and m % 2 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = []
	for i in range(n):
		l2 = []
		for j in range(2):
			l2.append(tuple(input().split()))
		l.append(l2)
	if m % 2 == 0:
		for i in l:
			if i[0][1] == i[1][0]:
				print('YES')
				break
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
while t > 0:
	(x, y) = map(int, input().split())
	c = 0
	z = 0
	for i in range(x):
		(a, b) = map(int, input().split())
		(d, e) = map(int, input().split())
		if b == d:
			c = c + 1
	if y % 2 == 1:
		print('NO')
	elif c > 0:
		print('YES')
	else:
		print('NO')
	t = t - 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	is_sim = False
	for i in range(n):
		(x11, x12) = map(int, input().split())
		(x21, x22) = map(int, input().split())
		is_sim |= x12 == x21
	if m % 2 == 0 and is_sim:
		print('YES')
	else:
		print('NO')


import sys
ii = lambda : sys.stdin.readline().strip()
idata = lambda : [int(x) for x in ii().split()]

def solve():
	(n, m) = idata()
	flag = m % 2 == 0
	flag1 = 1
	for i in range(n):
		(a, b) = idata()
		(c, d) = idata()
		if flag and b == c:
			print('YES')
			flag1 = 0
			flag = 0
	if flag1:
		print('NO')
	return
for t in range(int(ii())):
	solve()


t = int(input())
for j in range(0, t):
	(n, m) = map(int, input().split())
	ui = 0
	for o in range(0, n):
		(x, y) = map(int, input().split())
		(v, w) = map(int, input().split())
		if y == v:
			ui += 1
	if m % 2 != 0:
		print('NO')
	elif ui > 0:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	ans = 'NO'
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if c == b:
			ans = 'YES'
	if m % 2 != 0:
		ans = 'NO'
	print(ans)


t = int(input())
for _ in range(t):
	n = list(map(int, input().split()))
	if n[1] % 2 != 0:
		for i in range(n[0]):
			l1 = list(map(int, input().split()))
			l2 = list(map(int, input().split()))
		print('NO')
	else:
		flag = False
		for i in range(n[0]):
			l1 = list(map(int, input().split()))
			l2 = list(map(int, input().split()))
			if l1[1] == l2[0]:
				flag = True
		if flag:
			print('YES')
		else:
			print('NO')


T = int(input())
for _ in range(T):
	(n, m) = map(int, input().split())
	f = 0
	for __ in range(n):
		a1 = list(map(int, input().split()))
		a2 = list(map(int, input().split()))
		if a1[-1] == a2[0]:
			f = 1
	if f == 1 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


import sys
from sys import stdin, stdout
ipi = lambda : int(stdin.readline())
ipil = lambda : map(int, stdin.readline().split())
ipf = lambda : float(stdin.readline())
ipfl = lambda : map(float, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
outl = lambda x: print(*x)
T = ipi()
for _ in range(T):
	(n, m) = ipil()
	flag = False
	for i in range(n):
		(_, a) = ipil()
		(b, _) = ipil()
		if a == b:
			flag = True
	if flag and m % 2 == 0:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	flag = 0
	grid = []
	for i in range(n):
		(x1, y1) = map(int, input().split())
		(x2, y2) = map(int, input().split())
		grid.append([[x1, y1], [x2, y2]])
		if x2 == y1:
			flag = 1
	if m % 2 != 0 or flag == 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	lst = []
	for j in range(2 * a):
		lst.append(list(map(int, input().split())))
	if b % 2 == 0:
		check = False
		sz = len(lst)
		for k in range(0, sz, 2):
			if lst[k][1] == lst[k + 1][0]:
				check = True
				break
		if check:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
while t > 0:
	t -= 1
	(n, m) = map(int, input().split())
	found = False
	for i in range(n):
		(a1, a2) = map(int, input().split())
		(b1, b2) = map(int, input().split())
		if a2 == b1:
			found = True
	if m % 2 != 0:
		print('NO')
		continue
	if found:
		print('YES')
	else:
		print('NO')


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.buffer.readline())

def MI():
	return map(int, sys.stdin.buffer.readline().split())

def LI():
	return list(map(int, sys.stdin.buffer.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def BI():
	return sys.stdin.buffer.readline()[:-1]

def SI():
	return sys.stdin.buffer.readline()[:-1].decode()

def solve():
	flag = False
	(n, m) = MI()
	tt = []
	for i in range(n):
		t = LLI(2)
		if t[0][1] == t[1][0]:
			flag = True
		tt.append(t)
	if m & 1:
		return False
	if not flag:
		return False
	for j in range(n):
		t1 = tt[j]
		for i in range(j + 1):
			t0 = tt[i]
			if t0[0][0] == t1[0][0] and t0[1][1] == t1[1][1] and (t0[1][0] == t1[0][1]) and (t0[0][1] == t1[1][0]):
				return True
	return False
for _ in range(II()):
	if solve():
		print('YES')
	else:
		print('NO')


t = int(input())
ans = ['NO'] * t
for i in range(t):
	(n, m) = map(int, input().split())
	if m % 2 == 1:
		for j in range(n):
			vec1 = list(map(int, input().split()))
			vec2 = list(map(int, input().split()))
		continue
	for j in range(n):
		vec1 = list(map(int, input().split()))
		vec2 = list(map(int, input().split()))
		if vec1[1] == vec2[0]:
			ans[i] = 'YES'
print(*ans, sep='\n')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	q = 0
	for _ in range(1, n + 1):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if c == b:
			q = 1
	if m % 2 == 0 and q == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n_tiles, n_matrix) = map(int, input().split())
	symmetric = False
	for idx in range(n_tiles):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			symmetric = True
	if n_matrix % 2:
		print('NO')
	else:
		print('YES' if symmetric else 'NO')


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def fi():
	return float(input())

def si():
	return input()

def msi():
	return map(str, input().split())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	return x * y // gcd(x, y)
mod = 1000000007

def modInverse(b, m):
	g = gcd(b, m)
	if g != 1:
		return -1
	else:
		return pow(b, m - 2, m)

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def modu(a, b, m):
	a = a % m
	inv = modInverse(b, m)
	if inv == -1:
		return -999999999
	else:
		return inv * a % m
from math import log, sqrt, factorial, cos, tan, sin, radians, floor, log2
import bisect
from decimal import *
getcontext().prec = 8
abc = 'abcdefghijklmnopqrstuvwxyz'
pi = 3.141592653589793

def fn(n):
	c = 0
	while n % 2 == 0:
		c += 1
		n //= 2
	return c

def main():
	for _ in range(ii()):
		(n, m) = mi()
		f = 0
		for i in range(n):
			(a, b) = mi()
			(c, d) = mi()
			if b == c:
				f = 1
		if m % 2:
			print('NO')
			continue
		if f:
			print('YES')
		else:
			print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = []
	for j in range(n):
		a.append([list(map(int, input().split())) for l in range(2)])
	if m % 2 == 0:
		for j in a:
			if j[0][1] == j[1][0]:
				print('YES')
				break
		else:
			print('NO')
	else:
		print('NO')


I = lambda : map(int, input().split())

def ispoosible(n):
	Flag = 'NO'
	for i in range(n):
		(l1, r1) = I()
		(l2, r2) = I()
		if l2 == r1:
			Flag = 'YES'
	return Flag
for i in range(int(input())):
	(n, k) = I()
	if k % 2 == 0:
		print(ispoosible(n))
	else:
		for i in range(n):
			I()
			I()
		print('NO')


def main():
	(n, m) = map(int, input().split())
	true = False
	for _ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			true = True
	if not true or m % 2:
		print('NO')
	else:
		print('YES')
for _ in range(int(input())):
	main()


def solve():
	(n, m) = map(int, input().split())
	found = False
	for _ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			found = True
	if m % 2 == 1:
		return False
	if found:
		return True
	return False
t = int(input())
for _ in range(t):
	if solve():
		print('YES')
	else:
		print('NO')


t = int(input())

def f(l1, l2):
	if l1[1] == l2[0]:
		return True
	else:
		return False
for _ in range(t):
	(n, m) = map(int, input().split())
	l = [None] * n
	for i in range(n):
		l[i] = f(list(map(int, input().split())), list(map(int, input().split())))
	if m % 2 != 0:
		print('NO')
	elif True in l:
		print('YES')
	else:
		print('NO')


dds = int(input())
for sadsd in range(dds):
	(n, m) = input().split()
	(n, m) = (int(n), int(m))
	poop = 0
	if m % 2 == 1:
		print('NO')
		for sdasd in range(n):
			(x, y) = input().split()
			(xx, yy) = input().split()
	else:
		for sdasd in range(n):
			(x, y) = input().split()
			(xx, yy) = input().split()
			if xx == y and poop == 0:
				print('YES')
				poop = 1
		if poop == 0:
			print('NO')


t = int(input())
for you in range(t):
	l = input().split()
	n = int(l[0])
	m = int(l[1])
	l = []
	col = dict()
	row = dict()
	found = 0
	done = 0
	for i in range(n):
		lo = input().split()
		a = int(lo[0])
		b = int(lo[1])
		lo = input().split()
		c = int(lo[0])
		d = int(lo[1])
		if b == c:
			found = 1
	if found == 1 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


testcases = int(input())
for _ in range(testcases):
	(n, m) = map(int, input().split())
	symmetry = 0
	for i in range(n):
		m1 = [[0, 0] for j in range(2)]
		l = list(map(int, input().split()))
		l1 = list(map(int, input().split()))
		(m1[0][0], m1[0][1]) = (l[0], l[1])
		(m1[1][0], m1[1][1]) = (l1[0], l1[1])
		if m1[0][1] == m1[1][0]:
			symmetry += 1
	if m % 2 != 0:
		print('NO')
	elif symmetry > 0:
		print('YES')
	else:
		print('NO')


import math
f = lambda : map(int, input().split())
for _ in range(int(input())):
	(n, m) = f()
	a = list()
	flag = 0
	for i in range(n):
		t1 = list(f())
		t2 = list(f())
		t3 = t1 + t2
		if t3[1] == t3[2]:
			flag = 1
	print('YES' if flag and m % 2 == 0 else 'NO')


def process():
	(n, m) = list(map(int, input().split()))
	flag = 0
	for i in range(n):
		tile = []
		tile.append(list(input().split()))
		tile.append(list(input().split()))
		if tile[0][1] == tile[1][0]:
			flag = 1
	if m % 2:
		print('NO')
	elif flag:
		print('YES')
	else:
		print('NO')

def main():
	for i in range(int(input())):
		process()
main()


t = int(input())
for i in range(t):
	n = [int(x) for x in input().split(' ')]
	flag = 'NO'
	for j in range(n[0]):
		r1 = [int(x) for x in input().split(' ')]
		r2 = [int(x) for x in input().split(' ')]
		if flag == 'NO' and r1[1] == r2[0]:
			flag = 'YES'
	if n[1] % 2 == 1 or n[1] < 2:
		flag = 'NO'
	print(flag)


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	flag = 0
	for i in range(n):
		(u, v) = map(int, input().split())
		(w, x) = map(int, input().split())
		if u == v and w == x and (u == w):
			flag += 1
		elif w == v:
			flag += 1
	if flag and m % 2 == 0:
		print('YES')
	else:
		print('NO')


import os, sys
from collections import defaultdict, Counter
from io import BytesIO, IOBase
from math import ceil

def main():
	for _ in range(int(input())):
		an = 0
		(n, m) = map(int, input().split())
		for i in range(n):
			(a, b) = map(int, input().split())
			(c, d) = map(int, input().split())
			if a == b == c == d:
				an = 1
			elif b == c:
				an = 1
		if m % 2 == 1 or an == 0:
			print('NO')
		else:
			print('YES')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	parts = []
	for i in range(n):
		parts.append([])
		parts[i].append(list(map(int, input().split())))
		parts[i].append(list(map(int, input().split())))
	ans = False
	if m % 2:
		print('NO')
		continue
	for i in parts:
		if i[0][1] == i[1][0]:
			print('YES')
			ans = True
			break
	if not ans:
		print('NO')


t = int(input())
ans = []
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	bad = True
	for i in range(n):
		(a, b) = input().split()
		(c, d) = input().split()
		if b == c:
			bad = False
	if m & 1 or bad:
		ans.append('NO')
	else:
		ans.append('YES')
print('\n'.join(ans))


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		(n, m) = ria()
		g = 0
		for i in range(n):
			(a, b) = ria()
			(c, d) = ria()
			if b == c:
				g += 1
				if a == d:
					g += 1
		ans = ''
		if m % 2 == 1:
			ans = 'NO'
		elif g >= 1:
			ans = 'YES'
		elif g == 0:
			ans = 'NO'
		print(ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


cases = int(input())
for _ in range(cases):
	(n, m) = map(int, input().split())
	a = []
	for i in range(n):
		a.append([[int(x) for x in input().split()] for i in range(2)])
	ok = False
	for i in range(n):
		ok |= a[i][0][1] == a[i][1][0]
	ok &= m % 2 == 0
	if ok:
		print('YES')
	else:
		print('NO')


def transpose(mat, tr, N):
	for i in range(N):
		for j in range(N):
			tr[i][j] = mat[j][i]

def isSymmetric(mat, N):
	tr = [[0 for j in range(len(mat[0]))] for i in range(len(mat))]
	transpose(mat, tr, N)
	for i in range(N):
		for j in range(N):
			if mat[i][j] != tr[i][j]:
				return False
	return True
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = []
	c = 0
	tempm = []
	for i in range(n * 2):
		if c != 2:
			tempm.append([int(x) for x in input().split()])
			c += 1
		if c == 2:
			s.append(tempm)
			tempm = []
			c = 0
	if m % 2 != 0:
		print('NO')
	else:
		flag = False
		for i in s:
			if isSymmetric(i, 2):
				flag = True
				break
		if flag:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	if m % 2 != 0:
		for _ in range(n):
			a = list(map(int, input().split()))
			b = list(map(int, input().split()))
		print('NO')
	else:
		c = False
		for _ in range(n):
			a = list(map(int, input().split()))
			b = list(map(int, input().split()))
			if a[1] == b[0]:
				c = True
		if c:
			print('YES')
		else:
			print('NO')


import sys
from collections import defaultdict
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	lis = []
	for i in range(n):
		lis.append([])
		for j in range(2):
			lis[-1].append(list(map(int, input().split())))
	if m % 2 == 1:
		print('NO')
		continue
	for i in range(n):
		if lis[i][1][0] == lis[i][0][1]:
			print('YES')
			break
	else:
		print('NO')


import sys

def main():
	(n, m) = map(int, sys.stdin.readline().split())
	q = []
	for i in range(n):
		q.append([list(map(int, sys.stdin.readline().split())), list(map(int, sys.stdin.readline().split()))])
	if m % 2:
		print('NO')
	else:
		fl = 0
		for i in range(n):
			if q[i][0][1] == q[i][1][0]:
				fl = 1
				break
		if fl:
			print('YES')
		else:
			print('NO')
for i in range(int(sys.stdin.readline().strip())):
	main()


from collections import *
from itertools import *
from bisect import *

def inp():
	return int(input())

def arrinp():
	return [int(x) for x in input().split()]

def main():
	t = inp()
	for _ in range(t):
		(n, m) = arrinp()
		tiles = []
		for i in range(n):
			tiles.append(arrinp())
			tiles[i].extend(arrinp())
		if m % 2 != 0:
			print('NO')
			continue
		found = False
		for tile in tiles:
			if tile[1] == tile[2]:
				print('YES')
				found = True
				break
		if not found:
			print('NO')
main()


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	a = [[*input().split()] for i in range(n) for j in range(2)]
	a = [*zip(a[::2], a[1::2])]
	can = m & 1 == 0
	can &= len([*filter(lambda g: g[0][1] == g[1][0], a)]) > 0
	print('Yes' if can else 'No')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = []
	for i in range(n):
		x = list(map(int, input().split()))
		y = list(map(int, input().split()))
		l.append(x)
		l.append(y)
	if m % 2 == 0:
		for i in range(0, 2 * n, 2):
			if l[i][1] == l[i + 1][0]:
				print('YES')
				break
		else:
			print('NO')
	else:
		print('NO')


from sys import stdin, stdout
import math
from collections import deque
input = stdin.readline

def print(*args, end='\n'):
	s = []
	for i in args:
		s.append(str(i) + ' ')
	s = ''.join(s)
	stdout.write(s + end)

def solve():
	(n, m) = map(int, input().split())
	flag = 0
	for i in range(n):
		mat = []
		for j in range(2):
			mat.append(list(map(int, input().split())))
		if mat[0][1] == mat[1][0]:
			flag = 1
	if m % 2:
		print('NO')
		return
	if flag:
		print('YES')
	else:
		print('NO')
tt = 1
tt = int(input())
for __ in range(tt):
	solve()


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	col = 0
	for j in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		col += int(b == c)
	if m % 2 == 0 and col > 0:
		print('YES')
	else:
		print('NO')


N = int(input())
for i in range(N):
	arr = input().split()
	num = 0
	for i in range(int(arr[0])):
		arr1 = input().split()
		arr2 = input().split()
		if arr1[1] == arr2[0]:
			num = 1
	if int(arr[1]) % 2 == 0 and num == 1:
		print('YES')
	else:
		print('NO')


from functools import lru_cache
from sys import stdin, stdout
import sys
from math import *
input = stdin.readline
for __ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	ans = 'NO'
	for i in range(n):
		(a, b) = list(map(int, input().split()))
		(x, y) = list(map(int, input().split()))
		if x == b:
			ans = 'YES'
	if m % 2 == 1:
		print('NO')
	else:
		print(ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = []
	for i in range(2 * n):
		a.append(list(map(int, input().split())))
	if m % 2 != 0:
		print('NO')
	else:
		flag = 0
		for i in range(0, len(a), 2):
			if a[i][1] == a[i + 1][0]:
				flag = 1
				break
		if flag == 1:
			print('YES')
		else:
			print('NO')


import sys
import bisect as bi
import math
from collections import defaultdict as dd
import heapq
import itertools
import io
import os
import operator
input = sys.stdin.readline
import random
mo = 10 ** 9 + 7

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
for _ in range(inin()):
	(n, m) = cin()
	f = 0
	for i in range(n):
		(a, b) = cin()
		(c, d) = cin()
		if c == b:
			f = 1
	if m % 2:
		f = 0
	if f:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	flag = False
	for i in range(n):
		(a1, a2) = map(int, input().split())
		(b1, b2) = map(int, input().split())
		if m % 2 != 0:
			continue
		elif b1 == a2:
			flag = True
	print('YES' if flag else 'NO')


import math
t = int(input())
for _ in range(0, t):
	ls = list(map(int, input().split()))
	n = ls[0]
	m = ls[1]
	first = 0
	z = 0
	if m % 2 == 1:
		z = 1
	for i in range(0, n):
		f = list(map(int, input().split()))
		l = list(map(int, input().split()))
		if z == 0:
			if f[1] == l[0]:
				first = 1
	if first == 1:
		print('YES')
	else:
		print('NO')


def findsym(piles):
	for i in range(len(piles)):
		for j in range(len(piles)):
			if piles[i][0] == piles[j][0] and piles[i][2] == piles[j][1] and (piles[i][1] == piles[j][2]) and (piles[i][3] == piles[j][3]):
				return True
	return False
t = int(input())
for i in range(t):
	temp = input().split(' ')
	n = int(temp[0])
	m = int(temp[1])
	tiles = []
	sym = False
	center = False
	for j in range(n):
		tile = input().split(' ') + input().split(' ')
		tile = list(map(int, tile))
		if tile[1] == tile[2]:
			center = True
			if tile[0] == tile[3]:
				sym = True
		tiles.append(tile)
	if m % 2 == 1:
		sym = False
		center = False
	if sym:
		print('YES')
	elif not center:
		print('NO')
	elif findsym(tiles):
		print('YES')
	else:
		print('NO')


from __future__ import division, print_function
from io import BytesIO, IOBase
import os, sys, math, heapq, copy
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from functools import cmp_to_key
from itertools import permutations, combinations, combinations_with_replacement
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 1000000007

def get_int():
	return int(sys.stdin.readline().strip())

def get_str():
	return sys.stdin.readline().strip()

def get_float():
	return float(sys.stdin.readline().strip())

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_strs():
	return map(str, sys.stdin.readline().strip().split())

def get_floats():
	return map(float, sys.stdin.readline().strip().split())

def list_ints():
	return list(map(int, sys.stdin.readline().strip().split()))

def list_strs():
	return list(map(str, sys.stdin.readline().strip().split()))

def list_floats():
	return list(map(float, sys.stdin.readline().strip().split()))
t = get_int()
for _ in range(t):
	(n, m) = get_ints()
	flag = 0
	for i in range(n):
		(x1, x2) = get_ints()
		(x3, x4) = get_ints()
		if x2 == x3:
			flag = 1
	if m & 1:
		print('NO')
	elif flag == 0:
		print('NO')
	else:
		print('YES')


cases = int(input())
for t in range(cases):
	(n, m) = list(map(int, input().split()))
	f = 0
	for i in range(n):
		(x1, x2) = list(map(int, input().split()))
		(x3, x4) = list(map(int, input().split()))
		if x2 == x3:
			f = 1
	if m % 2 == 1:
		print('NO')
	elif f == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	tiles = []
	symtricTiles = 0
	havediagnol = False
	for i in range(n):
		(t1, t2) = map(int, input().split())
		(t3, t4) = map(int, input().split())
		if t1 == t2 == t3 == t4 or t1 == t4 == t2 == t3:
			symtricTiles += 1
		if t2 == t3:
			havediagnol = True
	if m % 2 == 1:
		print('NO')
	elif havediagnol == False:
		print('NO')
	else:
		print('YES')


ITR = int(input())
for _ in range(ITR):
	nm = [int(x) for x in input().split(' ')]
	hasReflectInner = False
	hasReflectOuter = False
	pool = set()
	for i in range(nm[0]):
		UP = input().split(' ')
		DOWN = input().split(' ')
		if UP[1] == DOWN[0]:
			hasReflectInner = True
		pool.add((UP[0], UP[1], DOWN[0], DOWN[1]))
		if (UP[0], DOWN[0], UP[1], DOWN[1]) in pool:
			hasReflectOuter = True
	if hasReflectInner and hasReflectOuter and (nm[1] % 2 == 0):
		print('YES')
	else:
		print('NO')


t = int(input())
c = 0
for i in range(t):
	(tn, x) = list(map(int, input().split()))
	for j in range(tn):
		(n, m) = list(map(int, input().split()))
		(p, q) = list(map(int, input().split()))
		if m == p:
			c = 1
	if c == 1 and x % 2 == 0:
		print('YES')
	else:
		print('NO')
	c = 0


t = int(input())
while t > 0:
	t -= 1
	(n, m) = map(int, input().split())
	if m % 2 == 0:
		val = 0
	else:
		val = 1
	ans = 'NO'
	while n > 0:
		n -= 1
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if val == 0:
			if c == b:
				ans = 'YES'
	print(ans)


import os
import sys

def get_int():
	return int(input())

def get_ints():
	return map(int, input().split())

def get_float():
	return float(input())

def get_floats():
	return map(float, input().split())

def list_ints():
	return list(map(int, input().split()))

def list_floats():
	return list(map(float, input.split()))

def post(x):
	print(x, end=' ')
T = int(input())
for t in range(1, T + 1):
	(n, m) = get_ints()
	a = []
	for i in range(n):
		a.append([list_ints() for i in range(2)])
	ok = False
	for i in range(n):
		ok |= a[i][0][1] == a[i][1][0]
	ok &= m % 2 == 0
	print('YES' if ok else 'NO')


import time, math as mt, bisect as bs, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * (2 * 10 ** 5 + 5)
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(2 * 10 ** 5 + 5):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return

def readTree(n, e):
	adj = [set() for i in range(n + 1)]
	for i in range(e):
		(u1, u2) = IP()
		adj[u1].add(u2)
	return adj
mod = 10 ** 9 + 7

def solve():
	(n, m) = IP()
	check = False
	sec = False
	for i in range(n):
		(a, b) = IP()
		(c, d) = IP()
		if b == c:
			sec = True
	if m % 2 == 0 and sec:
		print('YES')
		return
	print('NO')
	return
t = II()
for i in range(t):
	solve()


x1 = int(input())
for i in range(x1):
	c = 0
	l = []
	(n, x) = map(int, input().split())
	for i in range(2 * n):
		l1 = list(map(int, input().split()))
		l.append(l1)
	for i in range(len(l) - 1):
		if i % 2 == 0 and l[i][1] == l[i + 1][0]:
			c += 1
			break
	if c > 0 and x % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	if m % 2 == 1:
		print('NO')
		for j in range(n):
			c = [int(s) for s in input().split()]
			d = [int(s) for s in input().split()]
	else:
		poss = False
		for j in range(n):
			c = [int(s) for s in input().split()]
			d = [int(s) for s in input().split()]
			if c[1] == d[0]:
				poss = True
			else:
				continue
		if poss == False:
			print('NO')
		else:
			print('YES')


def task_B():
	t = int(input())
	for _ in range(t):
		(n, m) = map(int, input().split())
		flag = False
		for _ in range(n):
			first_row = list(map(int, input().split()))
			second_row = list(map(int, input().split()))
			if first_row[1] == second_row[0]:
				flag = True
		if m % 2 == 0 and flag:
			ans = 'YES'
		else:
			ans = 'NO'
		print(ans)

def main():
	task_B()
main()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	f = 'NO'
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if m % 2 == 0 and c == b:
			f = 'YES'
	print(f)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass

def pmat(A):
	for ele in A:
		print(*ele, end='\n')

def seive():
	prime = [1 for i in range(10 ** 6 + 1)]
	prime[0] = 0
	prime[1] = 0
	for i in range(10 ** 6 + 1):
		if prime[i]:
			for j in range(2 * i, 10 ** 6 + 1, i):
				prime[j] = 0
	return prime
for _ in range(L()[0]):
	(n, m) = L()
	A = [[L(), L()] for i in range(n)]
	if m % 2:
		print('NO')
		continue
	for ele in A:
		if ele[0][1] == ele[1][0]:
			print('YES')
			break
	else:
		print('NO')
endtime = time.time()


t = int(input())
for i in range(t):
	arr = [int(x) for x in input().split()]
	(n, m) = (arr[0], arr[1])
	arr = []
	for j in range(n):
		arr_1 = [int(x) for x in input().split()] + [int(x) for x in input().split()]
		arr += [arr_1]
	if m <= 0 or m % 2 != 0:
		print('NO')
	else:
		f = 0
		for j in arr:
			if j[1] == j[2]:
				f = 1
				break
		if f == 1:
			print('YES')
		else:
			print('NO')


import random

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	fl = 0
	for i in range(n):
		(f, s) = map(int, input().split())
		(t, fo) = map(int, input().split())
		if s == t:
			fl = 1
	if m % 2 == 1:
		print('NO')
	elif fl == 0:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.readline
Q = int(input())
for _ in range(Q):
	(N, M) = map(int, input().split())
	hasPairs = False
	existsSimilar = False
	S = set()
	for _ in range(N):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			existsSimilar = True
			hasPairs = True
		if (a, b, c, d) in S:
			hasPairs = True
		S.add((a, c, b, d))
	print('YES' if existsSimilar and M % 2 == 0 else 'NO')


def issymm(p):
	if p[0][1] == p[1][0]:
		return 1
	else:
		return 0

def solve():
	main = []
	(n, m) = input().split()
	(n, m) = (int(n), int(m))
	for i in range(n):
		k = []
		for j in range(2):
			l = list(map(int, input().split()))
			k.append(l)
		main.append(k)
	if m % 2 != 0:
		return 'NO'
	else:
		for p in main:
			if issymm(p):
				return 'YES'
		return 'NO'
t = int(input())
for _ in range(t):
	print(solve())


x = input()
for i in range(int(x)):
	star = 0
	(a, b) = map(int, input().split())
	for j in range(int(a)):
		(_1, _2) = map(int, input().split())
		(_3, _4) = map(int, input().split())
		if _2 == _3:
			star = 1
	if star == 1 and b % 2 == 0:
		print('YES')
	else:
		print('NO')


def issymm(tile):
	return tile[1] == tile[2]

def ulta(tile):
	(a, b, c, d) = tile
	return (a, c, b, d)

def process():
	(n, m) = map(int, input().split())
	tiles = set()
	for i in range(n):
		tile = (*map(int, input().split()), *map(int, input().split()))
		tiles.add(tile)
	if m % 2 == 1:
		return False
	found = False
	for t in tiles:
		if issymm(t):
			found = True
			break
	if not found:
		return False
	if m == 2:
		return True
	for x in tiles:
		if ulta(x) in tiles:
			return True
	return False
for i in range(int(input())):
	print('YES' if process() else 'NO')


n1 = int(input())
for i in range(n1):
	(n, m) = list(map(int, input().split()))
	f = False
	for ii in range(n):
		(_, a) = list(map(int, input().split()))
		(__, aa) = list(map(int, input().split()))
		if a == __:
			f = True
	if m % 2 != 0:
		print('NO')
	elif not f:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(cond1, cond2) = (0, 0)
	(n, m) = map(int, input().split())
	l = []
	for j in range(n):
		(l1, l2) = map(int, input().split())
		(l3, l4) = map(int, input().split())
		l.append([l1, l2, l3, l4])
	if m % 2 != 0:
		print('NO')
		continue
	if m == 2:
		for i in l:
			if i[1] == i[2]:
				cond1 += 1
		if cond1:
			print('YES')
			continue
	for i in l:
		if i[0] == i[1] == i[2] == i[3]:
			cond1 += 1
			cond2 += 1
		if i[1] == i[2]:
			cond1 += 1
	for i in l:
		for j in l:
			if i[0] == j[0] and i[3] == j[3] and (i[1] == j[2]) and (i[2] == j[1]):
				cond2 += 1
	if cond1 and cond2:
		print('YES')
	else:
		print('NO')


from math import *
from bisect import bisect_left as bl
from bisect import bisect_right as br
from collections import Counter as ctr
from collections import deque as dq
from array import array
from re import search
li = lambda : list(map(int, input().split()))
arr = lambda a: array('i', a)
bi = lambda n: bin(n).replace('0b', '')
yn = lambda f: print('NYOE S'[f::2])
sbstr = lambda a, s: search('.*'.join(a), s)

def solve():
	for _ in range(int(input())):
		(n, m) = li()
		t = []
		f = False
		f1 = False
		for i in range(n):
			t1 = li()
			t2 = li()
			if t1[1] == t2[0] and f == False and (f1 == False):
				f = True
		yn(f and m % 2 == 0)
solve()


for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = []
	for i in range(n):
		a.append([[int(x) for x in input().split()] for i in range(2)])
	check = False
	for i in range(n):
		check |= a[i][0][1] == a[i][1][0]
	check &= m % 2 == 0
	print('YES' if check else 'NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	f = 0
	for i in range(n):
		(x, y) = list(map(int, input().split()))
		(u, v) = list(map(int, input().split()))
		if y == u:
			f = 1
	if m % 2 != 0:
		f = 0
	if f == 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	found = False
	for i in range(n):
		(a11, a12) = map(int, input().split())
		(a21, a22) = map(int, input().split())
		found |= a21 == a12
	if found and m % 2 == 0:
		print('YES')
	else:
		print('NO')


for pratyush in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	f = 0
	for i in range(n):
		(a, b) = [int(x) for x in input().split()]
		(c, d) = [int(x) for x in input().split()]
		if b == c:
			f = 1
	if m % 2 == 0 and f == 1:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	flag = False
	for i in range(n):
		arr = []
		for j in range(2):
			l = list(map(int, input().split()))
			arr.append(l)
		if arr[0][1] == arr[1][0]:
			flag = True
	if m * m % 4 != 0:
		print('NO')
	elif flag:
		print('YES')
	else:
		print('NO')


t = int(input())
while t != 0:
	(N, M) = input().split()
	m = int(M)
	n = int(N)
	c = 0
	d = 0
	for i in range(n):
		arr = []
		l = []
		l1 = []
		for j in range(2):
			(A, B) = input().split()
			a = int(A)
			b = int(B)
			arr.append([a, b])
			if j == 0:
				l.append(b)
			else:
				l.append(a)
			if j == 0:
				l1.append(a)
			else:
				l1.append(b)
		if l[0] == l[1]:
			c = 1
		if l1[0] == l[1]:
			d = 1
	if m % 2 == 0:
		if c == 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	t -= 1


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	check = False
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			check = True
	if check and m % 2 == 0:
		print('YES')
	else:
		print('NO')


from collections import defaultdict
import bisect
from math import ceil
for _ in range(int(input())):
	(n, x) = map(int, input().split())
	f = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			f = 1
	if x % 2 == 1 or f == 0:
		print('NO')
	else:
		print('YES')


def solve(n, m, pp):
	if m % 2 != 0:
		return 'NO'
	for (a, b, c, d) in pp:
		if b == c:
			return 'YES'
	return 'NO'
t = int(input())
for _ in range(t):
	(n, m) = (int(item) for item in input().split())
	pp = []
	for _ in range(n):
		(a, b) = (int(item) for item in input().split())
		(c, d) = (int(item) for item in input().split())
		pp.append((a, b, c, d))
	result = solve(n, m, pp)
	print(result)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = 0
	if m % 2 == 0:
		for __ in range(n):
			(g, imp1) = map(int, input().split())
			(imp2, f) = map(int, input().split())
			if imp1 == imp2:
				s += 1
		print('YNEOS'[s < 1::2])
	else:
		for __ in range(2 * n):
			input()
		print('NO')


for i in range(int(input())):
	s = 'NO'
	(n, m) = map(int, input().split())
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c and m % 2 == 0:
			s = 'YES'
	print(s)


import math
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	given = []
	for z in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		given.append([[a, b], [c, d]])
	ans = False
	for i in range(len(given)):
		if given[i][0][1] == given[i][1][0]:
			ans = True
			break
	if m % 2 != 0:
		ans = False
	print('YES' if ans else 'NO')


tt = int(input())
while tt:
	flag1 = False
	flag2 = False
	(n, m) = [int(i) for i in input().split()]
	bs = []
	cs = []
	for i in range(n):
		(a, b) = [int(i) for i in input().split()]
		bs.append(b)
		(c, d) = [int(i) for i in input().split()]
		cs.append(c)
		if b == c:
			flag1 = True
		if b in cs and c in bs:
			flag2 = True
	flag = flag1 and flag2 and (m % 2 == 0)
	if flag:
		print('YES')
	else:
		print('NO')
	tt -= 1


def gt():
	return list(map(int, input().split()))

def test():
	(a, b) = gt()
	(c, d) = gt()
	return b == c
(t,) = gt()
while t:
	t -= 1
	(n, m) = gt()
	if True in [test() for _ in range(n)] and (not m & 1):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	arr = []
	for _ in range(n):
		arr.append([[int(x) for x in input().split()] for _ in range(2)])
	flag = False
	for i in range(n):
		flag |= arr[i][0][1] == arr[i][1][0]
		if flag:
			break
	flag &= m % 2 == 0
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	t = 0
	for _ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			t += 1
	if t == 0 or m % 2 == 1:
		print('NO')
	else:
		print('YES')


from math import ceil, sqrt
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	flag = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if c == b:
			flag = 1
	if m % 2 == 0:
		if flag == 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


from sys import stdin
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, m) = [int(x) for x in inp().split()]
	flag = False
	for i in range(n):
		(x, y) = [int(x) for x in inp().split()]
		(x2, y2) = [int(x) for x in inp().split()]
		if x2 == y:
			flag = True
	if flag and m % 2 == 0:
		print('YES')
	else:
		print('NO')


cases = int(input())
for c in range(cases):
	(nt, size) = input().split(' ')
	nt = int(nt)
	size = int(size)
	tiles = []
	has_sym = False
	if size % 2 == 1:
		print('NO')
		for tile in range(nt):
			input()
			input()
		continue
	for tile in range(nt):
		top = input().split(' ')
		bot = input().split(' ')
		if top[1] == bot[0]:
			has_sym = True
	print('YES' if has_sym else 'NO')


t = int(input())
import math
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	if m % 2 == 1:
		print('NO')
		for i in range(n):
			l = []
			k = [int(x) for x in input().split()]
			l.append(k)
			k = [int(x) for x in input().split()]
			l.append(k)
	else:
		flag = 0
		for i in range(n):
			l = []
			k = [int(x) for x in input().split()]
			l.append(k)
			k = [int(x) for x in input().split()]
			l.append(k)
			if l[0][1] == l[1][0]:
				flag = 1
		if flag == 0:
			print('NO')
		else:
			print('YES')


for aww in range(int(input())):
	(a, b) = map(int, input().split())
	c = []
	d = []
	for i in range(a):
		c.append([*map(int, input().split())])
		d.append([*map(int, input().split())])
	if a == 1 and b % 2 == 0:
		if c[0][1] == d[0][0]:
			print('YES')
		else:
			print('NO')
	elif b % 2 != 0:
		print('NO')
	else:
		f = True
		for i in range(a):
			if c[i][1] == d[i][0]:
				print('YES')
				f = False
				break
		if f == True:
			print('NO')


time = int(input())
for t in range(time):
	a = input()
	list = []
	(b, c) = map(int, a.split())
	for i in range(b):
		e = input()
		f = input()
		(g, h) = map(int, e.split())
		(k, l) = map(int, f.split())
		temp = [g, h, k, l]
		list.append(temp)
	if c % 2 == 0:
		for i in list:
			if i[1] == i[2]:
				print('Yes')
				break
		else:
			print('No')
	else:
		print('No')


from math import ceil
t = int(input())
while t:
	t -= 1
	(n, x) = map(int, input().split())
	a = [input().split() for i in range(2 * n)]
	if x % 2 == 1:
		print('NO')
		continue
	k = False
	for i in range(0, 2 * n, 2):
		if a[i][1] == a[i + 1][0]:
			k = True
			break
	print('YES' if k else 'NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	arr3 = []
	for k in range(n):
		l1 = list(map(int, input().split()))
		l2 = list(map(int, input().split()))
		if l1[1] == l2[0]:
			arr3.append(True)
	if m % 2 != 0:
		print('No')
	elif True in arr3:
		print('Yes')
	else:
		print('No')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	r = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			r += 1
	if m % 2 != 0:
		print('NO')
		continue
	if n == 1 and r >= 1:
		print('YES')
	elif r >= 1:
		print('YES')
	else:
		print('NO')


import heapq as hq
from heapq import heappop, heappush
from collections import deque, defaultdict, Counter
from sys import stdin, stdout

def inp():
	return int(stdin.readline())

def inlt():
	return list(map(int, stdin.readline().split()))

def insr():
	return list(stdin.readline().strip())

def invr():
	return map(int, stdin.readline().split())

def subset_sum_count(arr, n, sum):
	dp = [[0 for _ in range(sum + 1)] for _ in range(n + 1)]
	for i in range(n + 1):
		for j in range(sum + 1):
			if j == 0:
				dp[i][j] = 1
			elif arr[i - 1] <= j:
				dp[i][j] = dp[i - 1][j - arr[i - 1]] + dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j]
	return dp[n][sum]

def binary_search(func, lo, hi, abs_prec=1e-07):
	while abs(hi - lo) > abs_prec:
		mi = lo + (hi - lo) / 2
		if func(mi):
			hi = mi
		else:
			lo = mi
	return (lo + hi) / 2

def ternary_search(func, lo, hi, abs_prec=1e-07):
	while abs(hi - lo) > abs_prec:
		lo_third = lo + (hi - lo) / 3
		hi_third = hi - (hi - lo) / 3
		if func(lo_third) < func(hi_third):
			lo = lo_third
		else:
			hi = hi_third
	return (lo + hi) / 2

def discrete_binary_search(func, lo, hi):
	while lo < hi:
		mi = lo + (hi - lo) // 2
		if func(mi):
			hi = mi
		else:
			lo = mi + 1
	return lo

def discrete_ternary_search(func, lo, hi):
	while lo <= hi:
		lo_third = lo + (hi - lo) // 3
		hi_third = lo + (hi - lo) // 3 + (1 if 0 < hi - lo < 3 else (hi - lo) // 3)
		if func(lo_third) < func(hi_third):
			lo = lo_third + 1
		else:
			hi = hi_third - 1
	return lo
	return -1

def right_rotate(a, s):
	return a[s:] + a[:s]

def dec_to_bin(x):
	return int(bin(x)[2:])

def str_to_integer_list(n):
	a = []
	for i in range(len(n)):
		a.append(int(n[i]))
	return a

def list_to_str(l):
	s = ''
	for i in l:
		s += str(i)
	return s

def dijkstra(s, N, E):
	visited = set()
	dist = {}
	for i in range(1, N + 1):
		dist[i] = 1 << 29
	queue = [(dist[i], i) for i in range(1, N + 1)]
	hq.heappush(queue, (0, s))
	dist[s] = 0
	while queue:
		(d, u) = hq.heappop(queue)
		if u in visited:
			continue
		for t in E[u]:
			(v, r) = t
			if dist[v] > d + r:
				dist[v] = d + r
				hq.heappush(queue, (dist[v], v))
		visited.add(u)
	return dist

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def dijkstra(n, graph, start):
	(dist, parents) = ([float('inf')] * n, [-1] * n)
	dist[start] = 0
	queue = [(0, start)]
	while queue:
		(path_len, v) = heappop(queue)
		if path_len == dist[v]:
			for (w, edge_len) in graph[v]:
				if edge_len + path_len < dist[w]:
					(dist[w], parents[w]) = (edge_len + path_len, v)
					heappush(queue, (edge_len + path_len, w))
	return (dist, parents)

def path(start, end, parent):
	path = [end]
	while path[-1] != start:
		path.append(parent[path[-1]])
	path.reverse()
	return path

def bfs(graph, start, goal):
	if start == goal:
		return [start]
	visited = {start}
	queue = deque([(start, [])])
	while queue:
		(current, path) = queue.popleft()
		visited.add(current)
		for neighbor in graph[current]:
			if neighbor == goal:
				return path + [current, neighbor]
			if neighbor in visited:
				continue
			queue.append((neighbor, path + [current]))
			visited.add(neighbor)
	return None

def fillPrefixSum(arr, n, prefixSum):
	prefixSum[0] = arr[0]
	for i in range(1, n):
		prefixSum[i] = prefixSum[i - 1] + arr[i]

def check(a, ind, d1):
	beg = a[:ind + 1]
	end = a[ind + 1:]
	d = []
	c = 0
	for i in end:
		if i - d1 in beg:
			c += 1
	return c
import os
import sys
from io import BytesIO, IOBase

def DecimalToBinary(n):

	def helper(n):
		if n == 0:
			return ''
		else:
			if n % 2 == 1:
				binaryDigit = '1'
			else:
				binaryDigit = '0'
			return helper(n // 2) + binaryDigit
	if n == 0:
		result = '0'
	else:
		result = helper(n)
	return result

def p(board):
	for i in range(8):
		s = ''
		for j in range(8):
			s += board[i][j]
		print(s)

def binaryToDecimal(n):
	return int(n, 2)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def solve(a, b):
	x = DecimalToBinary(a)
	y = DecimalToBinary(b)
	z = x + y
	l = y + x
	r = binaryToDecimal(z) - binaryToDecimal(l)
	return r

def mostFrequent(arr, n):
	arr.sort()
	max_count = 1
	res = arr[0]
	curr_count = 1
	for i in range(1, n):
		if arr[i] == arr[i - 1]:
			curr_count += 1
		else:
			if curr_count > max_count:
				max_count = curr_count
				res = arr[i - 1]
			curr_count = 1
	if curr_count > max_count:
		max_count = curr_count
		res = arr[n - 1]
	return res
from bisect import bisect_right, bisect_left

def lds(arr, n):
	lds = [0] * n
	max = 0
	for i in range(n):
		lds[i] = 1
	for i in range(1, n):
		for j in range(i):
			if arr[i] < arr[j] and lds[i] < lds[j] + 1:
				lds[i] = lds[j] + 1
	for i in range(n):
		if max < lds[i]:
			max = lds[i]
	return max
import math

def prefix(a):
	pre = []
	pre.append(a[0])
	for i in range(1, len(a)):
		pre.append(pre[i - 1] + a[i])
	return pre

def solve(n, x, size):
	res = 10000000
	if n == 0:
		return 0
	if size == 0:
		return 0
	for i in x:
		res = 1 + min(res, solve(n - i, x, size - 1))
		return res

def main():
	for _ in range(inp()):
		(n, m) = invr()
		flag = 0
		for i in range(n):
			(a, b) = invr()
			(c, d) = invr()
			if c == b:
				flag = 1
		if m % 2 != 0 or flag == 0:
			print('NO')
		else:
			print('YES')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, m) = map(int, sys.stdin.readline().split())
	ji = 0
	for i in range(n):
		k = []
		for j in range(2):
			k.append(list(map(int, sys.stdin.readline().split())))
		if k[0][-1] == k[1][0]:
			ji += 1
	if ji and m & 1 == 0:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
case_total = inp()
for case_no in range(case_total):
	(n, m) = invr()
	list = []
	rev_list = []
	flag = False
	for i in range(n):
		(a, b) = invr()
		(c, d) = invr()
		x = a * 1000 + b * 100 + c * 10 + d
		y = a * 1000 + c * 100 + b * 10 + d
		if x == y:
			flag = True
		list.append(x)
		rev_list.append(y)
	if m % 2 != 0 or not flag:
		print('NO')
	else:
		for i in range(len(list)):
			if list[i] in rev_list:
				break
		if flag:
			print('YES')
		else:
			print('NO')


import math
t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	matrix = []
	s = 0
	for j in range(n):
		(x, y) = list(map(int, input().split()))
		(u, v) = list(map(int, input().split()))
		if y == u:
			s += 1
	if m % 2 == 1:
		print('NO')
	elif s > 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	mat = []
	for i in range(n):
		x = [list(map(int, input().split())) for i in range(2)]
		mat.append(x)
	ok = False
	for i in range(n):
		ok = ok or mat[i][0][1] == mat[i][1][0]
	if ok and m % 2 == 0:
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	condition = False
	for j in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			condition = True
	if m % 2 != 0:
		condition = False
	if condition == True:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
for _ in range(int(stdin.readline().strip())):
	(n, m) = map(int, stdin.readline().strip().split())
	possible = False
	for i in range(n):
		(a1, a2) = map(int, stdin.readline().strip().split())
		(a3, a4) = map(int, stdin.readline().strip().split())
		if a2 == a3:
			possible = True
	if m % 2 != 0:
		print('NO')
	elif possible:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	check = 0
	for i in range(n):
		(x1, y1) = map(int, input().split())
		(x2, y2) = map(int, input().split())
		if y1 == x2:
			check = 1
		if m % 2 != 0:
			check = 0
	if check == 0:
		print('NO')
	else:
		print('YES')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	S = ent = [[int(i) for i in input().split()] for j in range(2 * n)]
	if m % 2 != 0:
		print('NO')
	else:
		flag = 0
		for i in range(n):
			if S[2 * i][1] == S[2 * i + 1][0]:
				flag = 1
				break
			else:
				continue
		if flag == 1:
			print('YES')
		else:
			print('NO')


import sys
readline = sys.stdin.readline
T = int(readline())
Ans = [None] * T
for qu in range(T):
	(N, M) = map(int, readline().split())
	ans = 'NO'
	for _ in range(N):
		(a, b) = map(int, readline().split())
		(c, d) = map(int, readline().split())
		if b == c:
			ans = 'YES'
	if M & 1:
		Ans[qu] = 'NO'
		continue
	Ans[qu] = ans
print('\n'.join(Ans))


for i in range(int(input())):
	(n, m) = map(int, input().split())
	flag = False
	for j in range(n):
		(a11, a12) = map(int, input().split())
		(a21, a22) = map(int, input().split())
		if a21 == a12:
			flag = True
	if flag and m % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	t -= 1
	(n, m) = map(int, input().split())
	is_good = False
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if c == b:
			is_good = True
	print('YES' if is_good and m % 2 == 0 else 'NO')


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(n, m) = map(int, input().split())
	flag1 = 0
	flag2 = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if c == b:
			flag1 = 1
	ans = 'YES'
	if m % 2 != 0 or flag1 != 1:
		ans = 'NO'
	print(ans)


def check_symmetric(matrix):
	transpose = []
	for i in range(len(matrix)):
		tmp = []
		for j in range(len(matrix[i])):
			tmp.append(matrix[j][i])
		transpose.append(tmp)
	return transpose == matrix

def solve():
	(n, m) = map(int, input().split())
	tiles = []
	tmp = []
	for _ in range(n * 2):
		if len(tmp) == 2:
			tiles.append(tmp)
			tmp = []
		a = list(map(int, input().split()))
		tmp.append(a)
	tiles.append(tmp)
	if m % 2 == 1:
		print('NO')
	else:
		transpose = False
		for tile in tiles:
			is_transpose = check_symmetric(tile)
			if is_transpose:
				transpose = True
				break
		if is_transpose:
			print('YES')
		else:
			print('NO')
T = int(input())
for _ in range(T):
	solve()


for i in ' ' * int(input()):
	(n, m) = map(int, input().split())
	L = []
	state = False
	for i in ' ' * n:
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			state = True
	if m % 2:
		state = False
	print(['NO', 'YES'][state])


from sys import stdin, stdout
import math
import heapq
import collections
input = stdin.readline

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputstrings():
	return [x for x in input().split()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(n, m) = inputnums()
	a = []
	b = []
	c = []
	d = []
	for i in range(2 * n):
		if i % 2 == 0:
			(A, B) = inputnums()
			a.append(A)
			b.append(B)
		else:
			(C, D) = inputnums()
			c.append(C)
			d.append(D)
	good = False
	for i in range(n):
		if c[i] == b[i]:
			good = True
			break
	if not good or m % 2 == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	f = 0
	for j in range(n):
		(u, v) = map(int, input().split())
		(x, y) = map(int, input().split())
		if v == x:
			f = 1
	if f == 1:
		if m >= 2 and m % 2 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


from math import *
import threading
import sys

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = -1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def graph(n, m):
	adj = dict()
	for i in range(1, n + 1):
		adj.setdefault(i, 0)
	for i in range(m):
		(a, b) = map(int, input().split())
		adj[a] += 1
		adj[b] += 1
	return adj

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	li = []
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, len(prime)):
		if prime[p]:
			li.append(p)
	return li
INF = 1000000000.0
primes = SieveOfEratosthenes(1300000)
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	f = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if f == 0:
			if b == c:
				f = 1
	if m & 1:
		f = 0
	if f:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = [int(_) for _ in input().split()]
	tiles = [[[int(_) for _ in input().split()], [int(_) for _ in input().split()]] for __ in range(n)]

	def minisim(mat):
		return mat[0][1] == mat[1][0]
	if m % 2:
		print('NO')
	elif any((minisim(_) for _ in tiles)):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	tp = []
	(k, sz) = list(map(int, input().split()))
	for i in range(k):
		(a, b) = list(map(int, input().split()))
		(c, d) = list(map(int, input().split()))
		tp.append((a, b, c, d))
	if sz % 2 == 1:
		print('NO')
		continue
	a = False
	b = False
	for i in range(len(tp)):
		for j in range(i, len(tp)):
			if not a and (tp[i][0] == tp[j][0] and tp[i][3] == tp[j][3] and (tp[i][1] == tp[j][2]) and (tp[i][2] == tp[j][1])):
				a = True
				break
		if tp[i][2] == tp[i][1]:
			b = True
		if a and b:
			break
	if a and b:
		print('YES')
	else:
		print('NO')


import sys
import math, bisect
from collections import defaultdict
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, OrderedDict

def neo():
	return map(int, input().split())

def Neo():
	return list(map(int, input().split()))
for _ in range(int(input())):
	(n, m) = neo()
	d = defaultdict(int)
	t = 0
	tup = tuple()
	for i in range(2 * n):
		(a, b) = neo()
		tup += (a, b)
		if t == 1:
			d[tup] += 1
			tup = tuple()
			t = 0
		else:
			t += 1
	f = 0
	for i in d:
		if i[1] == i[2]:
			f = 1
	if f == 1 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


def transpose(mat, tr, N):
	for i in range(N):
		for j in range(N):
			tr[i][j] = mat[j][i]

def isSymmetric(mat, N):
	tr = [[0 for j in range(len(mat[0]))] for i in range(len(mat))]
	transpose(mat, tr, N)
	for i in range(N):
		for j in range(N):
			if mat[i][j] != tr[i][j]:
				return False
	return True
t = int(input())
while t:
	(n, m) = map(int, input().split())
	tile = [[0, 0], [0, 0]]
	flag = False
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		tile[0][0] = a
		tile[0][1] = b
		tile[1][0] = c
		tile[1][1] = d
		if isSymmetric(tile, 2):
			flag = True
	if flag and m % 2 == 0:
		print('YES')
	else:
		print('NO')
	t -= 1


import sys, bisect, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range
R = range

def Golf():
	(n, *t) = map(int, open(0).read().split())

def I():
	return int(input())

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

def MI():
	return map(int, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def NLI(n):
	return [[int(i) for i in input().split()] for i in range(n)]

def NLI_(n):
	return [[int(i) - 1 for i in input().split()] for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RA():
	return map(int, open(0).read().split())

def RLI(n=8, a=1, b=10):
	return [random.randint(a, b) for i in range(n)]

def RI(a=1, b=10):
	return random.randint(a, b)

def INP():
	N = 10
	A = 10
	n = random.randint(1, N)
	a = [random.randint(1, A) for i in range(n)]
	return (n, a)

def Rtest(T):
	(case, err) = (0, 0)
	for i in range(T):
		inp = INP()
		a1 = naive(*inp)
		a2 = solve(*inp)
		if a1 != a2:
			print((a1, a2), inp)
			err += 1
		case += 1
	print('Tested', case, 'case with', err, 'errors')

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in R(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in R(base ** n):
		s = [tb // base ** bt % base for bt in R(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
l_alp = string.ascii_lowercase
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()
show_flg = False
show_flg = True
ans = 0
for _ in range(I()):
	ans = 0
	(n, m) = LI()
	t = []
	for i in range(n):
		a = LI() + LI()
		if a[1] == a[2]:
			ans = (m + 1) % 2
		t += (a,)
	Yn(ans)


t = int(input())

def is_symmetric(matrix):
	for p in range(2):
		for q in range(2):
			if matrix[p][q] != matrix[q][p]:
				return False
	return True
for i in range(t):
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	sit = False
	for j in range(n):
		first_row = input().split()
		sec_row = input().split()
		for k in range(2):
			temp1 = first_row[k]
			first_row[k] = int(temp1)
			temp2 = sec_row[k]
			sec_row[k] = int(temp2)
		mat = [first_row, sec_row]
		if is_symmetric(mat) and m % 2 == 0:
			sit = True
	if sit:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	k = 0
	t = 0
	for i in range(2 * n):
		(a, b) = map(int, input().split())
		if k == 0:
			a1 = a
			b1 = b
			k = 1
		else:
			k = 0
			if a == b1:
				t = 1
	if t and m % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	A = []
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		A.append([a, b, c, d])
	if m % 2 == 1:
		print('NO')
		continue
	(type1, type2) = (0, 0)
	for i in range(n):
		mat = A[i]
		if mat[1] == mat[2]:
			type1 = 1
		for j in range(i, n):
			if mat[1] == A[j][2] and mat[2] == A[j][1]:
				type2 = 1
	if type1 == 1 and (type2 == 1 or m == 2):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = [int(i) for i in input().split()]
	tiles = []
	for _ in range(n):
		tiles.append([[int(i) for i in input().split()] for _ in range(2)])
	if m % 2:
		print('NO')
		continue
	has_diag_tile = False
	for tile in tiles:
		if tile[0][1] == tile[1][0]:
			has_diag_tile = True
			break
	if has_diag_tile:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	if m % 2 != 0:
		for i in range(2 * n):
			(a, b) = map(int, input().split())
		print('NO')
	else:
		arr = [[] for _ in range(n)]
		count = 0
		for i in range(2 * n):
			(a, b) = map(int, input().split())
			arr[count].extend([a, b])
			if i % 2 != 0:
				count += 1
		flag = False
		for i in arr:
			if i[1] == i[2]:
				flag = True
				break
		if flag:
			print('YES')
		else:
			print('NO')


t = int(input())
for test in range(t):
	(n, m) = [int(x) for x in input().split()]
	ans = False
	for i in range(n):
		rc1 = [int(x) for x in input().split()]
		rc2 = [int(x) for x in input().split()]
		if rc1[1] == rc2[0]:
			ans = True
	if m % 2 != 0:
		ans = False
	if ans:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	arr = []
	sub_arr = []
	same = 0
	for i in range(2 * n):
		if i % 2 == 0:
			sub_arr = []
		(x, y) = map(int, input().split())
		sub_sub = [x, y]
		sub_arr.append(sub_sub)
		if i % 2 == 1:
			if sub_arr[0][1] == sub_arr[1][0]:
				same += 1
			arr.append(sub_arr)
	if m % 2 != 0:
		print('NO')
	elif m == 2:
		if same > 0:
			print('YES')
		else:
			print('NO')
	elif same > 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	flag = 0
	(n, m) = map(int, input().split())
	matrix = [[0 for i in range(2)] for j in range(2 * n)]
	for i in range(2 * n):
		matrix[i] = list(map(int, input().split()))
	if m % 2 == 1:
		print('NO')
		t -= 1
		continue
	for i in range(2 * n):
		if i % 2 == 1:
			if matrix[i][0] == matrix[i - 1][1]:
				print('YES')
				t -= 1
				flag = 1
				break
	if flag == 0:
		print('NO')
		t -= 1


for case in range(int(input())):
	(moreCases, squareSize) = map(int, input().split(' '))
	if squareSize % 2 == 1:
		print('NO')
		for s in range(moreCases * 2):
			input()
		continue
	t = False
	for i in range(moreCases):
		lst = []
		lst.append(list(map(int, input().split(' ')))[1])
		lst.append(list(map(int, input().split(' ')))[0])
		if lst[0] == lst[1]:
			t = True
	if t:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(b, a) = map(int, input().split())
	cnt = 0
	for i in range(b):
		(x1, y1) = map(int, input().split())
		(x2, y2) = map(int, input().split())
		if y1 == x2:
			cnt += 1
	if cnt > 0 and a % 2 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	w = []
	for i in range(n):
		s = list(map(int, input().split()))
		r = list(map(int, input().split()))
		if s[1] == r[0]:
			w.append(True)
	if m % 2 != 0:
		print('NO')
	elif w != []:
		print('YES')
	else:
		print('NO')


for _____ in range(int(input())):
	(n, m) = map(int, input().split())
	ch = 0
	for i in range(n):
		(l, r) = map(int, input().split())
		(ll, rr) = map(int, input().split())
		if ll == r:
			ch = 1
	if m % 2 == 1:
		print('NO')
	elif ch == 1:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))
t = ini()
for _ in range(t):
	(n, m) = inm()
	ans = False
	for i in range(n):
		a = inl()
		b = inl()
		if a[1] == b[0]:
			ans = True
	if m % 2 != 0:
		ans = False
	print('YES' if ans else 'NO')


t = int(input())
for i in range(t):
	a = input().split()
	n = int(a[0])
	m = int(a[1])
	state = 0
	if m % 2 != 0:
		print('NO')
		state = 2
	for j in range(n):
		a = input().split()
		b = input().split()
		if a[1] == b[0] and state == 0:
			print('YES')
			state = 1
	if state == 0:
		print('NO')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	x = []
	z = 'NO'
	for i in range(2 * n):
		(a, b) = map(int, input().split())
		x.append([a, b])
	if m % 2 != 0:
		print('NO')
	else:
		for i in range(0, len(x), 2):
			if x[i][1] == x[i + 1][0]:
				z = 'YES'
				break
		print(z)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
sys.setrecursionlimit(100000000)
ii = lambda : int(input())
si = lambda : input()
jn = lambda x, l: x.join(map(str, l))
sl = lambda : list(map(str, input().strip()))
mi = lambda : map(int, input().split())
mif = lambda : map(float, input().split())
lii = lambda : list(map(int, input().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
mod = 1000000007
for _ in range(ii()):
	(n, m) = mi()
	flag = 0
	for i in range(n):
		(a, b) = mi()
		(c, d) = mi()
		if b == c:
			flag = 1
	if m % 2 == 0:
		if flag == 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


from sys import stdin, stdout
import math, sys
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict, Counter
from os import path
import bisect as bi
import heapq
mod = 10 ** 9 + 7

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def inp():
		return int(input())

	def minp():
		return map(int, input().split())
else:

	def inp():
		return int(stdin.readline())

	def minp():
		return map(int, stdin.readline().split())
for i in range(inp()):
	s = 'NO'
	(n, m) = minp()
	for i in range(n):
		(a, b) = minp()
		(c, d) = minp()
		if b == c and m % 2 == 0:
			s = 'YES'
	print(s)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	tile = []
	for i in range(n):
		l = []
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		l.extend([a, b, c, d])
		tile.insert(i, l)
	if m % 2 != 0:
		print('NO')
	else:
		flag = 0
		for j in range(n):
			if tile[j][1] == tile[j][2]:
				flag = 1
			if flag == 1:
				break
			else:
				continue
		if flag:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	ans = 'NO'
	for i in range(n):
		(a, b) = map(int, input().split())
		(x, y) = map(int, input().split())
		if x == b:
			ans = 'YES'
	if m % 2 != 0:
		ans = 'NO'
	print(ans)


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	f = 0
	while n:
		n -= 1
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			f = 1
	if f == 1 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	flag = False
	for q in range(n):
		(x1, y1) = map(int, input().split())
		(x2, y2) = map(int, input().split())
		if x2 == y1:
			flag = True
	print('YES' if flag and m % 2 == 0 else 'NO')


import math
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	sqrs = []
	for i in range(n):
		sqrs.append([])
		sqrs[i].append(list(map(int, input().split())))
		sqrs[i].append(list(map(int, input().split())))
	if m % 2 != 0:
		print('NO')
		continue
	f = 0
	for i in range(n):
		tmp = sqrs[i]
		if tmp[0][1] == tmp[1][0]:
			f = 1
			break
	if f == 0:
		print('NO')
	else:
		print('YES')


from sys import stdin
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())
for _ in range(it()):
	(n, m) = mp()
	v = []
	for i in range(n):
		v.append([[int(i) for i in input().split()] for i in range(2)])
	if m & 1:
		print('NO')
	else:
		flag = 0
		for i in range(n):
			if v[i][0][1] == v[i][1][0]:
				flag = 1
		if flag:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	tiles = [[input().split() for j in range(2)] for i in range(n)]
	if m % 2:
		print('NO')
	else:
		flag = False
		for i in range(n):
			if tiles[i][0][1] == tiles[i][1][0]:
				flag = True
				break
		if flag:
			print('YES')
		else:
			print('NO')


import sys
input = sys.stdin.buffer.readline

def solution():
	(n, m) = map(int, input().split())
	flag = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if c == b:
			flag = 1
	if m % 2 != 0:
		flag = 0
	if flag == 0:
		print('NO')
	else:
		print('YES')
t = int(input())
for _ in range(t):
	solution()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	x = 0
	while a != 0:
		(c, d) = map(int, input().split())
		(e, f) = map(int, input().split())
		if d == e:
			x = 1
		a -= 1
	if b % 2 != 0:
		print('NO')
		continue
	if x == 1:
		print('YES')
		continue
	else:
		print('NO')
		continue


import sys
import math as mt
import bisect
input = sys.stdin.readline
t = int(input())

def ncr_util():
	inv[0] = inv[1] = 1
	fact[0] = fact[1] = 1
	for i in range(2, 300001):
		inv[i] = inv[i % p] * (p - p // i) % p
	for i in range(1, 300001):
		inv[i] = inv[i - 1] * inv[i] % p
		fact[i] = fact[i - 1] * i % p

def solve():
	if m % 2 != 0:
		return 'NO'
	if ch == 0:
		return 'NO'
	return 'YES'
for _ in range(t):
	(n, m) = map(int, input().split())
	ch = 0
	for i in range(n):
		(x1, y1) = map(int, input().split())
		(x2, y2) = map(int, input().split())
		if x2 == y1:
			ch = 1
	print(solve())


test = int(input())
for k in range(test):
	(n, m) = list(map(int, input().split()))
	check = False
	for j in range(n):
		(a1, b1) = list(map(int, input().split()))
		(a2, b2) = list(map(int, input().split()))
		if b1 == a2:
			check = True
	if m % 2 == 0 and check == True:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
from collections import deque
import bisect
R = lambda : stdin.readline().strip()
RL = lambda f=None: list(map(f, R().split(' '))) if f else list(R().split(' '))
output = lambda x: stdout.write(str(x) + '\n')
output_list = lambda x: output(' '.join(map(str, x)))
T = int(input())
for _ in range(T):
	(n, m) = RL(int)
	flag = 0
	for i in range(n):
		(a, b) = RL(int)
		(c, d) = RL(int)
		if b == c:
			flag = 1
	if m % 2:
		print('NO')
		continue
	if flag:
		print('YES')
	else:
		print('NO')


import math
import bisect
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
I = lambda : int(input())
tup = lambda : map(int, input().split())
lst = lambda : list(map(int, input().split()))
t = I()
while t:
	(n, m) = tup()
	arr_n = []
	for i in range(n):
		top = lst()
		bottom = lst()
		arr_n.append([top, bottom])
	if m < 2:
		print('NO')
	elif m % 2 != 0:
		print('NO')
	else:
		flag = False
		for i in range(n):
			b = arr_n[i][0][1]
			c = arr_n[i][1][0]
			if b == c:
				flag = True
				break
		if flag:
			print('YES')
		else:
			print('NO')
	t -= 1


import copy

def symmetric(matrix):
	return matrix[0][1] == matrix[1][0] and matrix[0][0] == matrix[1][1]

def reflexive(matrix1, matrix2):
	if matrix1[0][0] == matrix2[0][0] and matrix1[1][1] == matrix2[1][1]:
		return matrix1[0][1] == matrix2[1][0] and matrix1[1][0] == matrix2[0][1]
	return False

def solve(n, m):
	found = False
	for _ in range(n):
		row1 = list(map(int, input().split()))
		row2 = list(map(int, input().split()))
		if row1[1] == row2[0]:
			found = True
	if m % 2 != 0:
		return 'NO'
	if found:
		return 'YES'
	return 'NO'
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	print(solve(n, m))


for _ in range(int(input())):
	[n, m] = list(map(int, input().split()))
	c = 0
	A = []
	for i in range(0, 2 * n, 2):
		x = []
		x.append(list(map(int, input().split())))
		x.append(list(map(int, input().split())))
		A.append(x)
	if m % 2 == 1:
		print('NO')
		continue
	for i in A:
		if i[0][1] == i[1][0]:
			print('YES')
			break
		c += 1
	if c == n:
		print('NO')


t = int(input())

def isdia(tu):
	(ro, col) = tu
	(a1, a2) = ro
	(b1, b2) = col
	if b1 == a2:
		return True
	return False

def findT(tu):
	(ro, col) = tu
	(a1, a2) = ro
	(b1, b2) = col
	return ((a1, b1), (a2, b2))
while t:
	t -= 1
	(n, m) = list(map(int, input().split(' ')))
	a = n
	mat = []
	d = dict()
	while a:
		a -= 1
		(a1, a2) = list(map(int, input().split(' ')))
		(b1, b2) = list(map(int, input().split(' ')))
		tu = ((a1, a2), (b1, b2))
		d[tu] = 1
	if m % 2 == 1:
		print('NO')
	else:
		flag1 = 0
		flag2 = 0
		for i in d:
			if isdia(i):
				flag1 = 1
				break
		for tu in d:
			ab = findT(tu)
			if d.get(tu) != None:
				flag2 = 1
				break
		if flag1 and flag2:
			print('YES')
		else:
			print('NO')


t = int(input())
while t:
	t = t - 1
	(n, m) = map(int, input().split())
	l = []
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		l.append([a, b, c, d])
	if m % 2 != 0:
		print('NO')
	else:
		f = 0
		for w in range(len(l)):
			if l[w][1] == l[w][2]:
				print('YES')
				f = 1
				break
		if f == 0:
			print('NO')


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	flag = False
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if c == b:
			flag = True
	print('YES' if flag and (not x & 1) else 'NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [[[0, 0], [0, 0]] for i in range(n)]
	f1 = False
	f2 = False
	f3 = False
	for i in range(n):
		(x1, x2) = map(int, input().split())
		(y1, y2) = map(int, input().split())
		if y1 == x2:
			f2 = True
		if y1 == x2 and x1 == y2:
			f1 = True
		a[i][0][0] = x1
		a[i][0][1] = x2
		a[i][1][0] = y1
		a[i][1][1] = y2
	if m % 2 == 1:
		print('NO')
		continue
	if f2 == True:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	notFound = True
	for _ in range(n):
		(a, b) = list(map(int, input().split()))
		(c, d) = list(map(int, input().split()))
		if c == b:
			notFound = False
	if m % 2 == 1:
		print('NO')
	elif notFound:
		print('NO')
	else:
		print('YES')


import math
from datetime import date
import sys
input = sys.stdin.readline

def main():
	t = int(input())
	while t > 0:
		t -= 1
		line = input().split()
		(n, m) = (int(line[0]), int(line[1]))
		area = m * m
		ok = 'False'
		for i in range(n):
			r1 = input().split()
			r2 = input().split()
			if r1[1] == r2[0]:
				ok = 'True'
		if area % 4 != 0:
			print('NO')
		elif ok == 'True':
			print('YES')
		else:
			print('NO')
main()


def sym(L):
	s = 0
	try:
		while True:
			if L[s + 1] == L[s + 2]:
				return True
			s += 4
	except:
		return False
t = int(input())
for i in range(t):
	ch = input()
	n = int(ch.split()[0])
	m = int(ch.split()[1])
	L = list()
	for i in range(2 * n):
		ch1 = input()
		L.append(ch1.split()[0])
		L.append(ch1.split()[1])
	if sym(L) and m % 2 == 0:
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(0, a):
	b = list(map(int, input().split()))
	d = []
	y = 0
	for j in range(0, b[0]):
		c = list(map(int, input().split()))
		e = list(map(int, input().split()))
		if c[1] == e[0]:
			y = 1
	if y == 1 and b[1] % 2 == 0:
		print('YES')
	else:
		print('NO')


import math
num = int(input())
for i in range(num):
	(n, m) = tuple(map(int, input().split()))
	is_pos = False
	for j in range(n):
		(x, y) = tuple(map(int, input().split()))
		(z, t) = tuple(map(int, input().split()))
		if z == y:
			is_pos = True
	if m % 2 == 1:
		print('NO')
	elif is_pos:
		print('YES')
	else:
		print('NO')


import math

def get_int():
	return int(input())

def get_ints():
	return [int(i) for i in input().split()]
for t in range(0, get_int()):
	(n, m) = get_ints()
	mirrorA = False
	mirrorB = False
	for T in range(0, n):
		tile = get_ints() + get_ints()
		if tile[0] == tile[3]:
			mirrorA = True
		if tile[1] == tile[2]:
			mirrorB = True
	if m % 2 != 0:
		print('No')
		continue
	if mirrorB:
		print('Yes')
	else:
		print('NO')


from sys import stdin, stdout

def read_input():
	lines = []
	for line in stdin:
		if 'exit' == line.lower().rstrip():
			break
		lines.append(line.rstrip())
	return lines

def is_symmetric(matrix):
	return matrix[1] == matrix[2]
data = read_input()
t = int(data[0])
counter = 1
for case in range(1, t + 1):
	(n, m) = [int(x) for x in data[counter].split(' ')]
	counter += 1
	if m % 2 != 0:
		stdout.write('NO\n')
		counter += 2 * n
		continue
	found_symmetric = False
	start = counter
	for i in range(start, start + n):
		matrix = [int(x) for x in data[counter].split(' ')]
		matrix.extend([int(x) for x in data[counter + 1].split(' ')])
		counter += 2
		if is_symmetric(matrix):
			found_symmetric = True
	if found_symmetric:
		stdout.write('YES\n')
	else:
		stdout.write('NO\n')
stdout.flush()


def mat_True(a, b, c, d):
	if b == c:
		return True
	else:
		return False
n = int(input())
m = []
for i in range(n):
	d = ''
	(a, b) = map(int, input().split())
	q1 = 0
	for i in range(a):
		(p1, p2) = map(int, input().split())
		(p3, p4) = map(int, input().split())
		if mat_True(p1, p2, p3, p4) == True:
			q1 = 1
	if q1 == 1:
		d = 'YES'
	else:
		d = 'NO'
	if b % 2 == 1:
		d = 'NO'
	m.append(d)
for i in range(n):
	print(m[i])


t = int(input())
for cases in range(t):
	(n, m) = list(map(int, input().split()))
	count = 0
	for tile in range(n):
		eins = input().split()
		zwei = input().split()
		if eins[1] == zwei[0]:
			count += 1
	if m % 2 == 1:
		print('NO')
	elif count > 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	sss = []
	for i in range(2 * n):
		(a, b) = map(int, input().split())
		if len(sss) > i // 2:
			sss[i // 2].append(a)
			sss[i // 2].append(b)
		else:
			sss.append([])
			sss[i // 2].append(a)
			sss[i // 2].append(b)
	if m % 2 == 1:
		print('NO')
		continue
	f = 1
	for i in range(n):
		if sss[i][2] == sss[i][1]:
			print('YES')
			f = 0
			break
	if f:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	typ = [[] for i in range(n)]
	for i in range(n):
		typ[i].extend([int(x) for x in input().split()])
		typ[i].extend([int(x) for x in input().split()])
	if m % 2 != 0:
		print('NO')
	else:
		fl = False
		for x in typ:
			if x[1] == x[2]:
				fl = True
				break
		if fl:
			print('YES')
		else:
			print('NO')


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	(ok1, ok2) = ('NO', True)
	if m & 1:
		ok2 = False
	while n:
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if ok1 == 'NO' and b == c:
			ok1 = 'YES'
		n -= 1
	ok1 = ok1 if ok2 else 'NO'
	print(ok1)


from collections import defaultdict
from sys import stdin
input = stdin.readline
from math import ceil

def put():
	return map(int, input().split())
t = int(input())
for _ in range(t):
	(n, m) = put()
	ans = 'NO'
	z = False if m % 2 == 1 else True
	for k in range(n):
		(a, b) = put()
		(c, d) = put()
		if z and b == c:
			ans = 'YES'
	print(ans)


def solve():
	(n, m) = [int(x) for x in input().split(' ')]
	found = False
	for i in range(n):
		(a, b) = [int(x) for x in input().split(' ')]
		(c, d) = [int(x) for x in input().split(' ')]
		if b == c:
			found = True
	if m % 2 == 1:
		print('NO')
	elif found:
		print('YES')
	else:
		print('NO')
t = int(input())
for _ in range(t):
	solve()


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c for j in range(b)] for i in range(a)]

def list3d(a, b, c, d):
	return [[[d for k in range(c)] for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** (-10)
for _ in range(INT()):
	(N, M) = MAP()
	ok = False
	for _ in range(N):
		sq = []
		(x, y) = MAP()
		sq.append((x, y))
		(x, y) = MAP()
		sq.append((x, y))
		if sq[0][1] == sq[1][0]:
			ok = True
	if M % 2 == 0 and ok:
		YES()
	else:
		NO()


rn = lambda : int(input())
rns = lambda : map(int, input().split())
rl = lambda : list(map(int, input().split()))
rs = lambda : input()
yn = lambda x: print('YES') if x else print('NO')
for _ in range(rn()):
	(n, m) = rns()
	l = []
	for i in range(n):
		a = []
		a.append(rl())
		a.append(rl())
		l.append(a)
	ans = False
	for i in l:
		if i == [[i[0][0], i[1][0]], [i[0][1], i[1][1]]]:
			ans = True
			break
	for i in l:
		b = [[i[0][0], i[1][0]], [i[0][1], i[1][1]]]
		if b in l:
			ans = True and ans
			break
	if m % 2 == 1:
		ans = False
	yn(ans)


def checkTiles(blocks):
	for tile in blocks:
		if int(tile[1]) == int(tile[2]):
			return True
	return False
numLines = int(input(''))
for i in range(0, numLines):
	n_m = input('')
	n_m = n_m.split(' ')
	n = int(n_m[0])
	m = int(n_m[1])
	tiles = []
	for j in range(0, n):
		firstRow = input('')
		secondRow = input('')
		firstRow = firstRow.split(' ')
		secondRow = secondRow.split(' ')
		tiles.append(firstRow + secondRow)
	if m % 2 == 0 and checkTiles(tiles) == True:
		print('YES')
	else:
		print('NO')


import math
teststring = '6\n3 4\n1 2\n5 6\n5 7\n7 4\n8 9\n9 8\n2 5\n1 1\n1 1\n2 2\n2 2\n1 100\n10 10\n10 10\n1 2\n4 5\n8 4\n2 2\n1 1\n1 1\n1 2\n3 4\n1 2\n1 1\n1 1\n'
online = __file__ != '/home/jhli/py/674/Problem_B.py'
(true, false) = (True, False)
if True:

	def spitout():
		for c in teststring.splitlines():
			yield c
	_ito = spitout()
	if not online:

		def input():
			return next(_ito)

	def build_enum(*a):
		built = dict()
		for (i, c) in enumerate(a):
			built[c] = i
		return lambda x: built[x]
T = int(input())

def symmetric(a):
	return a[1] == a[2]
for ti in range(1, T + 1):
	[n, m] = map(int, input().split(' '))
	sym = False
	for _ in range(n):
		a = []
		a.extend([int(e) for e in input().split(' ')])
		a.extend([int(e) for e in input().split(' ')])
		if symmetric(a):
			sym = True
	if m % 2 == 0 and sym:
		print('YES')
	else:
		print('NO')


def main():
	t = int(input())
	for i in range(t):
		(n, m) = map(int, input().split())
		flag = 0
		for i in range(n):
			(a11, a12) = map(int, input().split())
			(a21, a22) = map(int, input().split())
			if a21 == a12:
				flag = 1
		if m % 2 == 1:
			flag = 0
		if flag:
			print('YES')
		else:
			print('NO')
	return 0
main()


import sys, os, io
input = sys.stdin.readline
T = int(input())
ans = ['NO'] * T
for t in range(T):
	(n, m) = map(int, input().split())
	flag = False
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			flag = True
	if m % 2 == 0 and flag:
		ans[t] = 'YES'
print(*ans, sep='\n')


def iMatrix(matrix):
	if matrix[1] == matrix[2]:
		return True
	return False

def calc(types, n, m):
	if m % 2 == 1:
		return 'NO'
	for item in types:
		if iMatrix(item):
			return 'YES'
	return 'NO'
t = int(input())
for i in range(t):
	types = []
	(n, m) = list(map(int, input().split()))
	for i in range(n):
		part1 = list(map(int, input().split()))
		part2 = list(map(int, input().split()))
		types.append(part1 + part2)
	print(calc(types, n, m))


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz/'
M = 998244353
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	(n, m) = value()
	ans = 'NO'
	for i in range(n):
		a = array()
		b = array()
		if a[1] == b[0]:
			ans = 'YES'
	if m % 2:
		ans = 'NO'
	print(ans)


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = []
	for i in range(2 * n):
		(x, y) = list(map(int, input().split()))
		a.append([x, y])
	if m % 2 != 0:
		print('NO')
	elif n == 1 and a[0][1] != a[1][0]:
		print('NO')
	else:
		f = False
		for i in range(0, n * 2, 2):
			if a[i][1] == a[i + 1][0]:
				f = True
				break
		if f:
			print('YES')
		else:
			print('NO')


import sys, collections, math, itertools

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
mod = 1000000007
for _ in range(int(input())):
	(n, m) = get_ints()
	flag = False
	for i in range(n):
		(a, b) = get_ints()
		(c, d) = get_ints()
		if b == c and m % 2 == 0:
			flag = True
	if flag:
		print('YES')
	else:
		print('NO')


import sys
from copy import *
from bisect import *
from itertools import permutations as prm, product

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def string(s):
	return ''.join(s)

def fori(n):
	return [fi() for i in range(n)]

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def bo(i):
	return ord(i) - ord('A')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < m and (a[i][j] != '.')

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = fi()
while t > 0:
	t -= 1
	(n, m) = mi()
	a = []
	for i in range(n):
		p = [li(), li()]
		a.append(p)
	if m % 2:
		print('NO')
		continue
	flag = 0
	for i in a:
		if i[0][1] == i[1][0]:
			flag = 1
			break
	print('YES' if flag else 'NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [[0] * 2] * (2 * n)
	for i in range(2 * n):
		a[i] = [int(y) for y in input().split()]
	ans = 'NO'
	if m % 2 != 0:
		ans = 'NO'
	else:
		for i in range(0, 2 * n, 2):
			if a[i][1] == a[i + 1][0]:
				ans = 'YES'
				break
	print(ans)


import math
for i in range(int(input())):
	(n, m) = map(int, input().split())
	x = 0
	for j in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			x = 1
	if x == 1 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


def check_symmetry():
	(n, m) = map(int, input().split(' '))
	can_build = False
	for _ in range(n):
		(_, d1) = map(int, input().split(' '))
		(d2, _) = map(int, input().split(' '))
		if d1 == d2 and m % 2 == 0:
			can_build = True
	return can_build
t = int(input())
for _ in range(t):
	can_build = check_symmetry()
	if can_build:
		print('YES')
	else:
		print('NO')


for tc in range(int(input())):
	(tiles, square) = map(int, input().split())
	ans = []
	temp = []
	cnt = 0
	for x in range(0, 2 * tiles):
		(a, b) = map(int, input().split())
		temp.append(a)
		temp.append(b)
		if len(temp) == 4:
			ans.append(temp)
			temp = []
	if square % 2 != 0:
		print('NO')
		continue
	for x in ans:
		if x[1] == x[2]:
			print('YES')
			break
	else:
		print('NO')


outs = []
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	(yes1, yesmore) = (False, False)
	out = 'NO'
	for j in range(n):
		el = []
		(a1, a2) = map(int, input().split())
		(a3, a4) = map(int, input().split())
		if a2 == a3:
			out = 'YES'
	if m % 2 == 1:
		outs.append('NO')
		continue
	else:
		m /= 2
	if m > 1 and yesmore:
		out = 'YES'
	elif m == 1 and yes1:
		out = 'YES'
	outs.append(out)
for out in outs:
	print(out)


import sys
try:
	(sys.stdin, sys.stdout) = (open('in.txt', 'r'), open('out.txt', 'w'))
except:
	pass
ii1 = lambda : int(sys.stdin.readline().strip())
is1 = lambda : sys.stdin.readline().strip()
iia = lambda : list(map(int, sys.stdin.readline().strip().split()))
isa = lambda : sys.stdin.readline().strip().split()
mod = int(1000000000.0 + 7)
from collections import *
from math import *
for _ in range(ii1()):
	(n, m) = iia()
	first = 0
	second = 0
	third = 0
	for i in range(n):
		(a1, a2) = iia()
		(b1, b2) = iia()
		if a1 == a2 == b1 == b2:
			third += 1
		if a2 == b1:
			first += 1
	if m % 2 == 0:
		if first > 0 or third > 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


gi = lambda : list(map(int, input().split()))
for _ in range(gi()[0]):
	(n, m) = gi()
	flag = False
	for __ in range(n):
		(a, b) = gi()
		(c, d) = gi()
		if b == c:
			flag = True
	if m % 2 or not flag:
		print('NO')
	else:
		print('YES')


def transpose(mat, tr, N):
	for i in range(N):
		for j in range(N):
			tr[i][j] = mat[j][i]

def isSymmetric():
	N = 2
	mat = []
	mat.append([int(j) for j in input().split()])
	mat.append([int(j) for j in input().split()])
	tr = [[0 for j in range(len(mat[0]))] for i in range(len(mat))]
	transpose(mat, tr, N)
	for i in range(N):
		for j in range(N):
			if mat[i][j] != tr[i][j]:
				return False
	return True
for i in range(int(input())):
	(n, m) = map(int, input().split())
	flag = 0
	for i in range(n):
		if isSymmetric():
			flag = 1
	if flag == 0 or m % 2 == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	tiles = [0] * n
	for i in range(n):
		l1 = list(map(int, input().split()))
		l2 = list(map(int, input().split()))
		tiles[i] = l1 + l2
	if m % 2 != 0:
		print('NO')
	else:
		flag = 0
		for i in range(n):
			if tiles[i][1] == tiles[i][2]:
				flag = 1
				break
		if flag == 0:
			print('NO')
		else:
			print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	diag = False
	for _ in range(n):
		(a, b) = input().split()
		(c, d) = input().split()
		diag |= b == c
	print('YES' if diag and m % 2 == 0 else 'NO')


p = int(input())
for _ in range(p):
	(n, k) = map(int, input().split())
	flag = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			flag = 1
	if k % 2:
		print('NO')
	elif flag:
		print('YES')
	else:
		print('NO')


def test():
	testcases = int(input())
	for i in range(0, testcases):
		a = False
		(no_of_tiles, tiles_size) = map(int, input().split(' '))
		for j in range(0, no_of_tiles):
			tile1 = input().split(' ')
			tile2 = input().split(' ')
			if tiles_size % 2 == 0:
				if tile1[1] == tile2[0]:
					a = True
		if not a:
			print('NO')
		else:
			print('YES')
test()


t = int(input())
ans = []
for i in range(t):
	(n, m) = map(int, input().split())
	flag = 0
	if m % 2 != 0:
		ans.append('NO')
		flag = 1
	for i in range(n):
		tiletop = list(map(int, input().split()))
		tilebot = list(map(int, input().split()))
		if tiletop[1] == tilebot[0] and flag != 1:
			ans.append('YES')
			flag = 1
	if flag != 1:
		ans.append('NO')
for i in ans:
	print(i)


def is_sym(array):
	for i in range(len(array)):
		for j in range(len(array)):
			if array[i][j] != array[j][i]:
				return False
	else:
		return True

def solve():
	new_in = list(map(int, input().split()))
	n = new_in[0]
	m = new_in[1]
	list_array = []
	for i in range(n):
		array = []
		for j in range(2):
			line = list(map(int, input().split()))
			array.append(line)
		list_array.append(array)
	if m % 2 != 0:
		print('NO')
		return
	answer = 'NO'
	for i in range(n):
		if is_sym(list_array[i]):
			answer = 'YES'
	print(answer)
	return
t = int(input())
while t > 0:
	t -= 1
	solve()


for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	(a, b, c, d) = (0, 0, 0, 0)
	found = False
	for i in range(2 * n):
		if i % 2 == 0:
			(a, b) = [int(x) for x in input().split()]
		else:
			(c, d) = [int(x) for x in input().split()]
			if b == c:
				found = True
	if m % 2 != 0:
		found = False
	if found:
		print('YES')
	else:
		print('NO')


t = int(input())

def issym(a):
	if a[0][1] == a[1][0]:
		return True
	else:
		return False
for _ in range(t):
	(n, k) = map(int, input().split())
	m = []
	for _ in range(n):
		a = []
		a.append(list(map(int, input().split())))
		a.append(list(map(int, input().split())))
		m.append(a)
	if k % 2 != 0:
		print('NO')
	else:
		flag = False
		for a in m:
			if issym(a):
				flag = True
		if flag:
			print('Yes')
		else:
			print('NO')


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(n, sz) = list(map(int, stdin.readline().split()))
	flag = 0
	for i in range(n):
		(a, b) = list(map(int, stdin.readline().split()))
		(c, d) = list(map(int, stdin.readline().split()))
		if b == c:
			flag = 1
	if sz & 1 or flag == 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	temp = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(x, y) = map(int, input().split())
		if x == b:
			temp = 1
	if m % 2 != 0:
		print('NO')
		continue
	if temp == 1:
		print('YES')
	else:
		print('NO')


from sys import stdin

def ip():
	return [int(i) for i in stdin.readline().split()]

def sp():
	return [str(i) for i in stdin.readline().split()]
t = int(input())

def solve(n, m, A):
	if m % 2 != 0:
		return 'NO'
	for (a, b, c, d) in A:
		if b == c:
			return 'YES'
	return 'NO'
for _ in range(t):
	(n, m) = ip()
	A = []
	for _ in range(n):
		t = []
		for _ in range(2):
			(x, y) = ip()
			t.extend([x, y])
		A.append(t)
	print(solve(n, m, A))


def is_symmetric(matrix):
	if len(matrix) == 0:
		return True
	for i in range(len(matrix)):
		for j in range(len(matrix[0])):
			if matrix[i][j] != matrix[j][i]:
				return False
	return True
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	symmetrics = 0
	ans = 'NO'
	for __ in range(n):
		tile = []
		for ___ in range(2):
			tile.append(input().split())
		if m % 2 == 0:
			if is_symmetric(tile):
				ans = 'YES'
	print(ans)


from sys import stdin, stdout, setrecursionlimit
import heapq
from math import gcd, ceil, sqrt
from collections import Counter, deque
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
setrecursionlimit(100000)
mod = 1000000007
tc = ii1()
for _ in range(tc):
	(n, m) = iia()
	flag = False
	for i in range(n):
		a = iia()
		b = iia()
		if a[1] == b[0]:
			flag = True
	if flag and m % 2 == 0:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(n, m) = [int(i) for i in input().split()]
	x = 0
	for i in range(n):
		(a, b) = [int(i) for i in input().split()]
		(c, d) = [int(i) for i in input().split()]
		if b == c:
			x = 1
	if m % 2 != 0:
		print('NO')
	elif x == 1:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(n, m) = [int(i) for i in input().split()]
	res = False
	for j in range(n):
		(a, b) = [int(k) for k in input().split()]
		(c, d) = [int(k) for k in input().split()]
		if b == c:
			res = True
	print('YES' if res and m % 2 == 0 else 'NO')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	f = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			f = 1
	if f == 1 and m * m % 4 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	base = 0
	ans = 0
	top = {}
	bot = {}
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		top[a, b] = 1
		bot[c, d] = 1
		if a == b and b == c and (c == d):
			ans = 1
		if c == b:
			base = 1
	if m & 1:
		ans = 0
	elif ans == 0:
		if base:
			ans = 1
	if ans:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	(n, m) = map(int, input().split())
	flag = 0
	for i in range(n):
		M = [tuple(map(int, input().split())) for i in range(2)]
		if M[0][1] == M[1][0]:
			flag = 1
	if m % 2 == 1:
		print('NO')
		continue
	if flag:
		print('YES')
	else:
		print('NO')


def func():
	temp = True
	(n, m) = map(int, input().split())
	if m % 2 != 0:
		temp = False
	flag = False
	for _ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			flag = True
	if temp == False:
		return 'NO'
	if flag:
		return 'YES'
	return 'NO'
t = int(input())
for _ in range(t):
	print(func())


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = []
	count = 0
	for i in range(1, 2 * n + 1):
		p = list(map(int, input().split()))
		a.append(p)
		if i % 2 == 0:
			if a[0][1] == a[1][0]:
				count += 1
			a.clear()
	if m % 2 != 0:
		print('NO')
	elif count > 0:
		print('YES')
	else:
		print('NO')


def get(n):
	ans = 0
	for i in range(n):
		(q, w) = map(int, input().split())
		(e, r) = map(int, input().split())
		if w == e:
			ans = max(ans, 1)
	if m % 2:
		ans = 0
	return ('NO', 'YES')[ans]
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	print(get(n))


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	arr = []
	result = False
	for k in range(2 * n):
		(t1, t2) = map(int, input().split())
		arr.append(t1)
		arr.append(t2)
	for j in range(len(arr) // 4):
		if arr[j * 4 + 1] == arr[j * 4 + 2]:
			result = True
	if result and m % 2 == 0:
		print('YES')
	else:
		print('NO')


import sys
import math

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	(n, m) = get_ints()
	z = []
	for i in range(2 * n):
		z.append(get_array())
	if m % 2 != 0:
		print('NO')
	else:
		ans = 0
		flag = 0
		for i in range(0, 2 * n, 2):
			ans = 0
			for j in range(1):
				if z[i][1 - j] == z[i + 1][j]:
					ans = ans + 1
					break
			if ans == 1:
				flag = 1
				break
		if flag == 1:
			print('YES')
		else:
			print('NO')


import bisect
import array
import functools
import math
T = int(input())
for Tid in range(T):
	(n, m) = map(int, input().split())
	fl1 = 0
	for i in range(n):
		(a11, a12) = map(int, input().split())
		(a21, a22) = map(int, input().split())
		if a12 == a21:
			fl1 = 1
	if m % 2:
		print('NO')
	elif fl1:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t += -1
	(n, m) = map(int, input().split())
	check = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			check = 1
	if m % 2:
		print('NO')
	elif check:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for _ in range(t):
	lis = []
	(n, m) = [int(i) for i in input().split()]
	for i in range(2 * n):
		lis.append([int(i) for i in input().split()])
	if m % 2 != 0:
		print('NO')
	else:
		flag = 0
		for i in range(0, 2 * n, 2):
			if lis[i][1] == lis[i + 1][0]:
				flag = 1
				break
		if flag == 1:
			print('YES')
		else:
			print('NO')


num_tests = int(input())
for i in range(num_tests):
	test_info = input()
	test_info = test_info.split(' ')
	num_tiles = int(test_info[0])
	matrix_size = int(test_info[1])
	tiles_array = []
	for x in range(num_tiles):
		tile_info = input().split(' ')
		ul = int(tile_info[0])
		ur = int(tile_info[1])
		tile_info = input().split(' ')
		bl = int(tile_info[0])
		br = int(tile_info[1])
		tiles_array.append((ul, ur, bl, br))
	symmetric = False
	for (ul, ur, bl, br) in tiles_array:
		if ur == bl:
			symmetric = True
	if matrix_size % 2:
		symmetric = False
	if symmetric:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	ok = False
	for __ in range(n):
		(a, b) = [int(x) for x in input().split()]
		(c, d) = [int(x) for x in input().split()]
		if b == c:
			ok = True
	if m % 2 == 0 and ok:
		print('YES')
	else:
		print('NO')


no_cases = int(input())
for i in range(no_cases):
	inp = input()
	(n, m) = inp.split()
	(n, m) = (int(n), int(m))
	tiles = []
	found = False
	for i in range(n):
		tile = []
		first_line = input()
		first_line = first_line.split()
		for i in range(len(first_line)):
			first_line[i] = int(first_line[i])
		second_line = input()
		second_line = second_line.split()
		for i in range(len(second_line)):
			second_line[i] = int(second_line[i])
		tile = [first_line, second_line]
		if tile[0][1] == tile[1][0]:
			found = True
	if m % 2 != 0:
		print('NO')
		continue
	if not found:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	count = 0
	for i in range(n):
		lst = []
		for j in range(2):
			lst.append(list(map(int, input().split())))
		if lst[0][-1] == lst[1][0]:
			count += 1
	if m < 2:
		print('NO')
	elif m % 2 != 0:
		print('NO')
	elif count == 0:
		print('NO')
	else:
		print('YES')


for case in range(int(input())):
	(n, m) = [int(n) for n in input().split()]
	tiles = []
	flag = 0
	for t in range(n):
		if m % 2 == 1:
			(a, b) = [int(n) for n in input().split()]
			(c, d) = [int(n) for n in input().split()]
			ans = 'NO'
			flag = 1
		else:
			(a, b) = [int(n) for n in input().split()]
			(c, d) = [int(n) for n in input().split()]
			tile = (a, b, c, d)
			tiles.append(tile)
			if tile[1] == tile[2]:
				ans = 'YES'
				flag = 2
			else:
				ans = 'NO'
	if flag == 1:
		print('NO')
	elif flag == 2:
		print('YES')
	else:
		print(ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	f = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			f = 1
	if m % 2:
		print('NO')
	else:
		print('YES') if f else print('NO')


import math
from decimal import *
import random
mod = int(1000000000.0) + 7
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ok = False
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			ok = True
	if k % 2 or not ok:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.readline

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input().strip()

def listStr():
	return list(input().strip())
import collections as col
import math, itertools

def solve():
	(N, M) = getInts()
	pairs = col.defaultdict(int)
	symmetric = 0
	num_pairs = 0
	symmetric_pair = 0
	for i in range(N):
		(A, B) = getInts()
		(C, D) = getInts()
		if C == B:
			symmetric += 1
	if M % 2 == 1:
		return 'NO'
	if symmetric > 0:
		return 'YES'
	return 'NO'
for _ in range(getInt()):
	print(solve())


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	pos = False
	for i in range(n):
		(x, y) = map(int, input().split())
		(p, q) = map(int, input().split())
		if y == p:
			pos = True
	if k % 2 == 1:
		print('NO')
	elif pos:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	y = 0
	for i in range(n):
		tmp = input().split()
		tmp2 = input().split()
		data = [tmp, tmp2]
		if data[0][1] == data[1][0]:
			y = 1
	if y == 0 or m % 2 == 1:
		print('NO')
	else:
		print('YES')


T = int(input())
for case in range(T):
	(n, m) = map(int, input().split())
	types = []
	for temp in range(n):
		type_temp = []
		type_temp.append(list(map(int, input().split())))
		type_temp.append(list(map(int, input().split())))
		types.append(type_temp)
	if m % 2 != 0:
		print('NO')
		continue
	transpose_exist = False
	lbrt = False
	for type_temp in types:
		if type_temp[1][0] == type_temp[0][1]:
			lbrt = True
			break
	if not lbrt:
		print('NO')
		continue
	if n == 1:
		print('YES')
		continue
	for type_temp in types:
		for type_temp2 in types:
			if type_temp[0][1] == type_temp2[1][0] and type_temp[1][0] == type_temp2[0][1]:
				transpose_exist = True
				break
	if not transpose_exist:
		print('NO')
		continue
	print('YES')


t = int(input())
values = []
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	s = 'NO'
	for i in range(n):
		(a, b) = [int(x) for x in input().split()]
		(c, d) = [int(x) for x in input().split()]
		if c == b and m % 2 == 0:
			s = 'YES'
	values.append(s)
for i in range(t):
	print(values[i])


import sys
T = int(input())
while T:
	T -= 1
	flag = False
	(n, m) = map(int, input().split())
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if not flag:
			flag = b == c
	if m % 2 != 0:
		print('NO')
	elif flag:
		print('YES')
	else:
		print('NO')


T = int(input())
ans_ls = [''] * T
for t in range(T):
	(N, M) = map(int, input().split())
	res = False
	for _ in range(N):
		grid = [[0, 0], [0, 0]]
		for i in range(2):
			row = list(map(int, input().split()))
			grid[i] = row
		if grid[0][1] == grid[1][0]:
			res = True
	if res:
		ans_ls[t] = 'YES'
	else:
		ans_ls[t] = 'NO'
	if M % 2 == 1:
		ans_ls[t] = 'NO'
for ans in ans_ls:
	print(ans)


def solve(n, m, tails):
	if m % 2 == 1:
		return 'NO'
	for tail in tails:
		if tail[0][1] == tail[1][0]:
			return 'YES'
	return 'NO'
t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	tails = []
	for i in range(n):
		tails.append([[int(x) for x in input().split()] for i in range(2)])
	print(solve(n, m, tails))


t = int(input())
for _ in range(t):
	(n, m) = [int(i) for i in input().split()]
	out = 'NO'
	for j in range(n):
		a = [list(map(int, input().split())) for i in range(2)]
		if a[0][1] == a[1][0]:
			out = 'YES'
	if m % 2 != 0:
		out = 'NO'
	print(out)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	ok = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		ok |= c == b
	if m % 2 != 0 or not ok:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	(n, m) = [int(num) for num in input().split()]
	c = 0
	for i in range(n):
		(x, y) = [int(num) for num in input().split()]
		(z, w) = [int(num) for num in input().split()]
		if y == z:
			c = c + 1
	if c == 0:
		print('NO')
	elif m % 2 != 0:
		print('NO')
	else:
		print('YES')


import math
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ans = False
	if m % 2 == 1:
		ans = True
	c = 0
	mat = []
	for i in range(2 * n):
		p = list(map(int, input().split()))
		mat.append(p)
	for i in range(0, 2 * n, 2):
		if mat[i][1] == mat[i + 1][0]:
			c += 1
	if ans or c == 0:
		print('NO')
	else:
		print('YES')


from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math
rl = lambda : stdin.readline()
rll = lambda : stdin.readline().split()
rli = lambda : map(int, stdin.readline().split())
rlf = lambda : map(float, stdin.readline().split())
(INF, NINF) = (float('inf'), float('-inf'))
MOD = 10 ** 9 + 7

def solv():
	(n, m) = rli()
	area = m * m
	pseud_symm = lambda T: T[0][1] == T[1][0]
	flag = False
	for _ in range(n):
		tile = [[], []]
		tile[0] = list(rli())
		tile[1] = list(rli())
		if pseud_symm(tile):
			flag = True
	(q, r) = divmod(area, 4)
	if r > 0:
		print('NO')
		return
	if flag:
		print('YES')
	else:
		print('NO')

def main():
	T = int(rl())
	for _ in range(T):
		solv()
	stdout.close()
main()


import math
import sys

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	(n, m) = Read.list_int()
	t = 1
	v = 0
	for i in range(n):
		(lt, rt) = Read.list_int()
		(lb, rb) = Read.list_int()
		if lb == rt:
			v = 1
	print('YES' if t == 1 and v == 1 and (m % 2 == 0) else 'NO')
query_count = Read.int()
while query_count:
	query_count -= 1
	solve()


t = int(input())
for l in range(t):
	(n, m) = map(int, input().split())
	a = [[int(j) for j in input().split()[:2]] for i in range(2 * n)]
	if m % 2 != 0:
		print('NO')
	else:
		cnt1 = 0
		for k in range(2 * n):
			if k % 2 == 0:
				if a[k][1] == a[k + 1][0]:
					cnt1 += 1
					break
		if cnt1 > 0:
			print('YES')
		else:
			print('NO')


t = int(input())
while t > 0:
	(n, m) = list(map(int, input().split()))
	List = []
	for i in range(n):
		a = []
		a.append(list(map(int, input().split())))
		a.append(list(map(int, input().split())))
		List.append(a)
	ans = 0
	for i in List:
		if i[0][1] == i[1][0]:
			ans = 1
	ans = m % 2 == 0 and ans
	if ans:
		print('YES')
	else:
		print('NO')
	t = t - 1


def symmetric(mat):
	if mat[0][1] == mat[1][0]:
		return True
	else:
		return False

def solution():
	(n, m) = map(int, input().split())
	l = [[list(map(int, input().split())) for z in range(2)] for _ in range(n)]
	if m % 2 == 1:
		return 'NO'
	l2 = [symmetric(i) for i in l]
	if any(l2):
		return 'YES'
	else:
		return 'NO'
N = int(input())
for _ in range(N):
	print(solution())


t = int(input())
for q in range(t):
	(n, m) = map(int, input().split())
	flag = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			flag = 1
	if m % 2 == 1:
		print('NO')
	elif not flag:
		print('NO')
	else:
		print('YES')


import sys
t = sys.stdin.readline()
t = int(t)
s = 1
while s < t + 1:
	n = 0
	n = sys.stdin.readline().split()
	op1 = 0
	for i in range(int(n[0])):
		a1 = []
		a1 = sys.stdin.readline().split()
		a2 = []
		a2 = sys.stdin.readline().split()
		if a1[1] == a2[0]:
			op1 = 1
	if int(n[1]) % 2 != 0:
		print('NO')
	elif op1 == 0:
		print('NO')
	else:
		print('YES')
	s += 1


a = int(input())
for x in range(a):
	h = []
	(b, c) = map(int, input().split())
	t = -1
	for y in range(b):
		d = list(map(int, input().split()))
		e = list(map(int, input().split()))
		h.append(d)
		h.append(e)
	if c % 2 != 0:
		print('NO')
	else:
		for x in range(0, 2 * b, 2):
			if h[x][1] == h[x + 1][0]:
				t = 0
				break
		if t == 0:
			print('YES')
		else:
			print('NO')


t = int(input())
while t > 0:
	(n, m) = map(int, input().split())
	c = 0
	for i in range(n):
		l = [int(x) for x in input().split()]
		l1 = [int(x) for x in input().split()]
		if l[1] == l1[0]:
			c += 1
	if m % 2 != 0:
		print('NO')
	elif c >= 1:
		print('YES')
	else:
		print('NO')
	t = t - 1


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def sumDigits(no):
	return 0 if no == 0 else int(no % 10) + sumDigits(int(no / 10))
MOD = 1000000007
PMOD = 998244353
N = 10 ** 9 + 7
LOGN = 30
T = 1
T = int(stdin.readline())
for _ in range(T):
	(n, m) = list(map(int, stdin.readline().rstrip().split()))
	N = 2 * n
	a = []
	while N > 0:
		r = list(map(int, stdin.readline().rstrip().split()))
		a.append(r)
		N -= 1
	if m % 2 == 1:
		print('NO')
		continue
	isOk = False
	for i in range(0, 2 * n, 2):
		(x1, y1) = a[i]
		(x2, y2) = a[i + 1]
		if x2 == y1:
			isOk = True
			break
	if isOk:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	found = False
	for i in range(n):
		q = []
		q.append(list(map(int, input().split())))
		q.append(list(map(int, input().split())))
		if q[0][1] == q[1][0]:
			found = True
	if m % 2 == 1:
		print('NO')
	elif found:
		print('YES')
	else:
		print('NO')


import sys
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda : list(map(int, input().strip().split()))
MOD = 998244353

def f(n):
	s = int(sqrt(n))
	for i in range(s, s + 3):
		if i ** 2 == n:
			return s * 2 - 2
		a = s + 1
		b = s
		return a - 1 + b - 1

def f1(mat):
	return mat[0][1] == mat[1][0]

def main():
	ans = []
	for _ in range(int(input())):
		(n, m) = read()
		flag = 0
		for i in range(n):
			mat = []
			mat.append(read())
			mat.append(read())
			flag |= f1(mat)
		if m % 2 == 1:
			ans.append('NO')
			continue
		ans.append('YNEOS'[flag == 0::2])
	print('\n'.join(ans))
main()


t = int(input())
for i in range(t):
	(n, m) = [int(i) for i in input().split()]
	peca = [[0, 0], [0, 0]]
	estado = 'NO'
	for j in range(n):
		(peca[0][0], peca[0][1]) = [int(i) for i in input().split()]
		(peca[1][0], peca[1][1]) = [int(i) for i in input().split()]
		if peca[0][1] == peca[1][0] and m % 2 == 0:
			estado = 'YES'
	print(estado)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
from math import ceil
for _ in range(int(input()) if True else 1):
	(n, k) = map(int, input().split())
	pos = False
	for __ in range(n):
		(x, y) = map(int, input().split())
		(p, q) = map(int, input().split())
		if y == p:
			pos = True
	if k % 2:
		print('NO')
		continue
	print('YES' if pos else 'NO')


n = int(input())
for i in range(n):
	(inp, x) = [int(i) for i in input().split()]
	if x % 2 == 1:
		for j in range(inp * 2):
			input()
		print('NO')
	else:
		o = 0
		for j in range(inp):
			a = [int(i) for i in input().split()]
			b = [int(i) for i in input().split()]
			if a[1] == b[0]:
				o = 1
		if o:
			print('YES')
		else:
			print('NO')


T = int(input())
for i in range(T):
	(n, m) = map(int, input().split())
	flag = 0
	for j in range(n):
		(A1, A2) = map(int, input().split())
		(A3, A4) = map(int, input().split())
		if A2 == A3:
			flag = 1
	if m % 2 == 1:
		print('NO')
	elif flag == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	if m % 2 != 0:
		for k in range(n):
			(a, b) = map(int, input().split())
			(c, d) = map(int, input().split())
		print('NO')
	else:
		flag = True
		for k in range(n):
			(a, b) = map(int, input().split())
			(c, d) = map(int, input().split())
			if b == c and flag:
				flag = False
		if not flag:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	p = []
	q = []
	flag = 0
	for __ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		p.append(b)
		q.append(c)
	for i in range(n):
		if p[i] == q[i]:
			flag = 1
			break
	if m % 2 != 0:
		print('NO')
	elif flag == 1:
		print('YES')
	else:
		print('NO')


def transpose(a, b):
	return a == b
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	status = False
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if not status:
			status = transpose(b, c)
	if m % 2 == 1:
		print('NO')
	else:
		print('YES' if status else 'NO')


t = int(input())
for i in range(t):
	k = 0
	(n, m) = map(int, input().split())
	if m % 2 != 0:
		for j in range(n):
			(lv, pv) = map(int, input().split())
			(ln, pn) = map(int, input().split())
		print('NO')
	else:
		for j in range(n):
			(lv, pv) = map(int, input().split())
			(ln, pn) = map(int, input().split())
			if pv == ln:
				k = 1
		if k == 1:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	ans = False
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			ans = True
	if m % 2 == 1 or not ans:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	flag = False
	for i in range(n):
		M = [0] * 2
		(a, b) = map(int, input().split())
		M[0] = (a, b)
		(a, b) = map(int, input().split())
		M[1] = (a, b)
		if M[0][1] == M[1][0]:
			flag = True
	if m % 2 == 1:
		print('NO')
		continue
	if flag:
		print('YES')
	else:
		print('NO')


3
import sys
input = lambda : sys.stdin.readline().strip()
for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	tiles = [[[int(x) for x in input().split()] for _ in range(2)] for i in range(n)]
	print('YES' if m % 2 == 0 and any((tile[0][1] == tile[1][0] for tile in tiles)) else 'NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ans = 'NO'
	for i in range(n):
		(x, y) = map(int, input().split())
		(z, w) = map(int, input().split())
		if z == y and m % 2 == 0:
			ans = 'YES'
	print(ans)


import sys
import math as m

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l
mod = int(1000000000.0) + 7

def sinp():
	return sys.stdin.readline().strip()

def iinp():
	return int(input())

def ninp():
	return map(int, sys.stdin.readline().strip().split())

def linp():
	return list(map(int, sys.stdin.readline().strip().split()))

def p(a):
	print(a)

def p2(a, b):
	print(a, b)
for _ in range(iinp()):
	(n, m) = ninp()
	l = []
	f = 0
	f1 = 0
	for i in range(2 * n):
		(a, b) = ninp()
		if len(l) != 0:
			if a == l[1]:
				f = 1
			l = []
		else:
			l.append(a)
			l.append(b)
	if f == 0 or m % 2 == 1:
		print('NO')
	else:
		print('YES')


def do():
	q = int(input())
	for _ in range(q):
		(n, m) = map(int, input().split())
		allf = True
		if m & 1 == 1:
			allf = False
		f = False
		for i in range(n):
			a = list(input().split())
			b = list(input().split())
			if a[1] == b[0]:
				f = True
		print('YES' if allf & f else 'NO')
do()


t = int(input())
for _ in range(t):
	flag = False
	(n, m) = map(int, input().split())
	for _ in range(n):
		(topleft, topright) = map(int, input().split())
		(bottomleft, bottomright) = map(int, input().split())
		if topright == bottomleft:
			flag = True
	if m % 2 == 0 and flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = []
	for i in range(2 * n):
		x = list(map(int, input().split()))
		l.append(x)
	if k % 2 == 1:
		print('NO')
	else:
		i = 0
		flag = 0
		while i < 2 * n:
			if l[i][1] == l[i + 1][0]:
				flag = 1
				break
			else:
				i += 2
		if flag:
			print('YES')
		else:
			print('NO')


for j in range(0, int(input())):
	(n, m) = map(int, input().split())
	ans = 'NO'
	for j in range(0, n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			ans = 'YES'
	if ans == 'YES' and m % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	flag = 0
	for i in range(n):
		s = input()
		r = input()
		a = [int(k) for k in s.split(' ')]
		b = [int(k) for k in r.split(' ')]
		if a[1] == b[0] and m % 2 == 0:
			flag = 1
	if flag:
		print('YES')
	else:
		print('NO')


T = int(input())
for t in range(T):
	(n, m) = [int(x) for x in input().split()]
	arr = []
	for i in range(n):
		r1 = [int(x) for x in input().split()]
		r2 = [int(x) for x in input().split()]
		tile = r1 + r2
		arr.append(tile)
	if m % 2 != 0:
		print('NO')
	else:
		flag = 0
		for e in arr:
			if e[1] == e[2]:
				print('YES')
				flag = 1
				break
		if flag == 0:
			print('NO')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	if m % 2 != 0:
		for j in range(n):
			(a1, b1) = map(int, input().split())
			(a2, b2) = map(int, input().split())
		print('NO')
		continue
	for_diagonal = False
	for_symmetry = False
	list_for_sym = []
	for j in range(n):
		(a1, b1) = map(int, input().split())
		(a2, b2) = map(int, input().split())
		if b1 == a2 or (b1, a2) in list_for_sym:
			for_symmetry = True
		else:
			list_for_sym.append((a2, b1))
		if a2 == b1:
			for_diagonal = True
	if for_diagonal and for_symmetry:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	dec = []
	for x in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			dec.append('YES')
	if m % 2 != 0:
		print('NO')
	elif dec.count('YES') > 0:
		print('YES')
	else:
		print('NO')


T = int(input())
for t in range(T):
	(n, m) = map(int, input().split())
	tiles = list()
	for i in range(n):
		new_tile = list()
		new_tile.append(list(map(int, input().split())))
		new_tile.append(list(map(int, input().split())))
		tiles.append(new_tile)
	for tile in tiles:
		is_self_symm = True
		for x in [0, 1]:
			for y in [0, 1]:
				if tile[x][y] != tile[y][x]:
					is_self_symm = False
		if is_self_symm:
			break
	if is_self_symm and m % 2 == 0:
		print('YES')
	else:
		print('NO')


a = int(input())
for c in range(a):
	(q, w) = map(int, input().split())
	i = 0
	j = 0
	for y in range(q):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if c == b:
			i += 1
	re = w * w
	if re % 2 == 0:
		j += 1
	if j == 1 and i >= 1:
		print('YES')
	else:
		print('NO')


def solve(ar):
	if ar[0][1] == ar[1][0]:
		return True
	else:
		return False
for t in range(int(input())):
	(n, m) = map(int, input().split())
	super = False
	if m % 2 != 0:
		super = True
	ar = []
	flag = False
	for _ in range(n):
		for i in range(2):
			ar.append(list(map(int, input().split())))
		if solve(ar):
			flag = True
		ar = []
	if super:
		print('NO')
	elif flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = []
	f = 0
	f2 = 0
	for i in range(n):
		(x1, y1) = map(int, input().split())
		(x2, y2) = map(int, input().split())
		l.append([[x1, y1], [x2, y2]])
		if x2 == y1:
			f2 = 1
	if m % 2 == 0:
		if f2 == 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for x in range(int(input())):
	a = list(map(int, input().split()))
	n = a[0]
	m = a[-1]
	count = 0
	s = 0
	for x in range(n):
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		if a[1] == b[0] and a[0] == b[1]:
			count += 1
			s += 1
		elif a[1] == b[0] and a[0] != b[1]:
			count += 1
		else:
			pass
	if m % 2 != 0:
		print('NO')
	elif count > 0:
		print('YES')
	else:
		print('NO')


def miis():
	return map(int, input().split())
for _ in range(int(input())):
	(n, m) = miis()
	a = []
	for i in range(2 * n):
		if i % 2:
			a[-1].append(list(miis()))
		else:
			a.append([list(miis())])
	if m % 2:
		print('NO')
		continue
	for i in a:
		if i[0][1] == i[1][0]:
			print('YES')
			break
	else:
		print('NO')


tc = int(input())
times = 0
while times < tc:
	(n, m) = list(input().split(' '))
	n = int(n)
	m = int(m)
	tiles = []
	for i in range(n):
		t = []
		(a, b) = list(input().split(' '))
		t.append([int(a), int(b)])
		(c, d) = list(input().split(' '))
		t.append([int(c), int(d)])
		tiles.append(t)
	if m % 2 == 0:
		v = False
		for t in tiles:
			if t[1][0] == t[0][1]:
				v = True
		if v == False:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')
	times += 1


def solve():
	(n, m) = map(int, input().split())
	is_yes = False
	for i in range(n):
		(x11, x12) = map(int, input().split())
		(x21, x22) = map(int, input().split())
		if x12 == x21:
			is_yes = True
	return is_yes and m % 2 == 0
for _ in range(int(input())):
	if solve():
		print('YES')
	else:
		print('NO')


import sys
from sys import stdin, stdout, setrecursionlimit
MOD = 1000000007
PMOD = 998244353
N = 10 ** 9 + 7
LOGN = 30
T = 1
T = int(stdin.readline())
for _ in range(T):
	(n, m) = list(map(int, stdin.readline().rstrip().split()))
	N = 2 * n
	a = []
	cnt = 0
	while N > 0:
		r = list(map(int, stdin.readline().rstrip().split()))
		a.append(r)
		N -= 1
	if m % 2 == 1:
		print('NO')
		continue
	isOk = False
	for i in range(0, 2 * n, 2):
		(x1, y1) = a[i]
		(x2, y2) = a[i + 1]
		if x2 == y1:
			isOk = True
			break
	if isOk:
		print('YES')
	else:
		print('NO')


t = int(input())
for t0 in range(t):
	(n, m) = list(map(int, input().split()))
	boo = False
	for i in range(n):
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		if a[1] == b[0]:
			boo = True
	if boo and m % 2 == 0:
		print('YES')
	else:
		print('NO')


def main():
	for t in range(int(input())):
		(n, m) = map(int, input().split())
		f = 0
		for i in range(n):
			(x, y) = map(int, input().split())
			(u, v) = map(int, input().split())
			if y == u:
				f = 1
		if m % 2 == 1:
			print('NO')
		elif f == 1:
			print('YES')
		else:
			print('NO')
main()


t = int(input())
ans = []
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	a = []
	for i in range(n):
		tile = []
		tile.append(input().split())
		tile.append(input().split())
		a.append(tile)
	if m & 1:
		ans.append('NO')
	else:
		good = False
		for tile in a:
			if tile[0][1] == tile[1][0]:
				good = True
				break
		ans.append('YES' if good else 'NO')
print('\n'.join(ans))


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	flag = 0
	for j in range(n):
		(a1, a2) = map(int, input().split())
		(a3, a4) = map(int, input().split())
		if a2 == a3:
			flag = 1
	if m % 2 != 0:
		print('NO')
		continue
	if flag == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().rstrip().split()))
	s = 'NO'
	for x in range(n):
		(n1, n2) = list(map(int, input().rstrip().split()))
		(n3, n4) = list(map(int, input().rstrip().split()))
		if n2 == n3:
			s = 'YES'
	if m % 2 == 1:
		s = 'NO'
	print(s)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	tile = []
	for i in range(n):
		(tl, tr) = map(int, input().split())
		(bl, br) = map(int, input().split())
		tile.append([tl, tr, bl, br])
	f1 = False
	for i in range(n):
		xx = tile[i]
		if xx[1] == xx[2]:
			f1 = True
			break
	if m % 2 != 0:
		print('NO')
	elif f1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	if m % 2 == 1:
		for v in range(n):
			(a, b) = map(int, input().split())
			(c, d) = map(int, input().split())
		print('NO')
		continue
	flag = 0
	for v in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if c == b:
			flag = 1
	if flag == 1:
		print('YES')
		continue
	print('NO')


def check_sym(arr):
	ans = True
	for i in range(2):
		for j in range(2):
			if arr[i][j] != arr[j][i]:
				ans = False
				break
	return ans
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr = []
	for i in range(2 * n):
		temp = list(map(int, input().split()))
		arr.append(temp)
	if m % 2 != 0:
		print('No')
	else:
		val = False
		i = 0
		while i < 2 * n:
			temp = arr[i:i + 2]
			val = check_sym(temp)
			if val:
				break
			i += 2
		if val:
			print('Yes')
		else:
			print('No')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	flg = False
	for j in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if a == b and b == c and (c == d):
			flg = True
		if b == c:
			flg = True
	if m % 2 == 1:
		print('NO')
		continue
	if flg == True:
		print('YES')
		continue
	print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	flag = False
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			flag = True
	if m % 2 != 0:
		print('NO')
	elif flag:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline

def main():
	(n, m) = map(int, input().split())
	lst = [[list(map(int, input().split())) for _ in range(2)] for _ in range(n)]
	if m % 2 == 1:
		print('NO')
		return
	for blk in lst:
		if blk[0][1] == blk[1][0]:
			print('YES')
			return
	print('NO')
for _ in range(int(input())):
	main()


for i in range(int(input())):
	(n, m) = map(int, input().split())
	k = 0
	for j in range(n):
		(x1, y1) = map(int, input().split())
		(x2, y2) = map(int, input().split())
		if x2 == y1:
			k = 1
	if m % 2 == 1:
		print('NO')
	elif k == 1:
		print('YES')
	else:
		print('NO')


from sys import stdin
input = lambda : stdin.readline().strip()
lin = lambda : list(map(int, input().split()))
iin = lambda : int(input())
main = lambda : map(int, input().split())
from math import ceil, sqrt, factorial, log
from collections import deque
from bisect import bisect_left

def gcd(a, b):
	(a, b) = (max(a, b), min(a, b))
	while a % b != 0:
		(a, b) = (b, a % b)
	return b
mod = 998244353

def solve(we):
	(n, m) = main()
	l = []
	x = 0
	for i in range(n):
		a = tuple(lin() + lin())
		l.append(a)
	if m % 2 != 0:
		print('NO')
	else:
		t = m // 2
		d = {}
		for i in l:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
		flag = 0
		for i in d:
			if i[1] == i[2]:
				flag = 1
		if flag:
			print('YES')
		else:
			print('NO')
qwe = 1
qwe = int(input())
for _ in range(qwe):
	solve(_ + 1)


n = int(input())
for i in range(n):
	sch = list(map(int, input().split()))
	n = sch[0]
	m = sch[1]
	flag = False
	for i in range(n):
		sch1 = list(map(int, input().split()))
		a = sch1[1]
		sch1 = list(map(int, input().split()))
		b = sch1[0]
		if a == b:
			flag = True
	if m % 2 == 1:
		flag = False
	if flag:
		print('YES')
	else:
		print('NO')


x = int(input())
ansl = []
for i in range(x):
	nice = 0
	(y, z) = map(int, input().split())
	for i in range(y):
		s1 = list(map(int, input().split()))
		s2 = list(map(int, input().split()))
		if s2[0] == s1[1]:
			nice += 1
	if nice > 0 and z % 2 == 0:
		ansl.append('YES')
	else:
		ansl.append('NO')
for i in ansl:
	print(i)


import sys
input = sys.stdin.readline
from bisect import bisect_left
from bisect import bisect_right
from math import ceil, factorial

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k, modulus=1):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
		res %= modulus
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	(n, m) = int_array()
	tiles = []
	a1 = a2 = False
	for __ in range(n):
		tile = []
		tile.append(int_array())
		tile.append(int_array())
		tiles.append(tile)
		if tile[0] == [tile[0][0], tile[1][0]]:
			if tile[1] == [tile[0][1], tile[1][1]]:
				a1 = True
	if m % 2:
		print('NO')
		continue
	if a1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	check = True
	for j in range(n):
		L = []
		for z in range(2):
			l = []
			(x, y) = map(int, input().split())
			l.append(x)
			l.append(y)
			L.append(l)
		if L[0][1] == L[1][0]:
			check = False
	if check == True or m % 2 != 0:
		print('NO')
	else:
		print('YES')


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	(cnt, cnt1) = (0, 0)
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if a == b == c == d:
			cnt1 += 1
		if b == c:
			cnt += 1
	if k % 2 != 0:
		print('NO')
	elif cnt1 != 0:
		print('YES')
	elif cnt >= 1:
		print('YES')
	else:
		print('NO')


t = int(input())

def magh(now):
	return [now[0], now[2], now[1], now[3]]
for i in range(t):
	(n, m) = list(map(int, input().split()))
	lis = []
	for i in range(n):
		x = list(map(int, input().split()))
		x1 = list(map(int, input().split()))
		lis += [x + x1]
	v = True
	o = True
	if m == 1:
		v = False
	i = -1
	while (o or v) and i + 1 != n:
		i += 1
		now = lis[i]
		if now[1] == now[2]:
			o = False
		nat = magh(now)
		if nat in lis:
			v = False
	if not (v or o) and m % 2 == 0:
		print('YES')
	else:
		print('NO')


import sys

def solve(arr):
	if m % 2 == 1:
		return 'NO'
	for h in range(len(arr)):
		if arr[h][1] == arr[h][2]:
			return 'YES'
	return 'NO'
t = int(sys.stdin.readline())
ans_arr = []
for i in range(t):
	[n, m] = [int(j) for j in sys.stdin.readline().split()]
	arr = []
	for h in range(n):
		(top_left, top_right) = [int(k) for k in sys.stdin.readline().split()]
		(bottom_left, bottom_right) = [int(k) for k in sys.stdin.readline().split()]
		arr.append([top_left, top_right, bottom_left, bottom_right])
	ans = solve(arr)
	ans_arr.append(str(ans))
print('\n'.join(ans_arr))


t = int(input())
for _ in range(t):
	out = 'NO'
	(n, m) = map(int, input().split())
	for __ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c and m % 2 == 0:
			out = 'YES'
	print(out)


MOD = 1000000007
from collections import defaultdict as dd, Counter, deque

def si():
	return input()

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def mi():
	return map(int, input().split())

def out(v):
	print(v)

def spout():
	print(v, end=' ')

def d2b(n):
	return bin(n).replace('0b', '')

def twod(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def vow():
	return ['a', 'e', 'i', 'o', 'u']

def let():
	return [chr(i) for i in range(97, 123)]

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ispow2(x):
	return x and (not x & x - 1)

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)
t = ii()
while t:
	t -= 1
	(n, m) = mi()
	f = 0
	while n:
		n -= 1
		(t1, t2) = mi()
		(t3, t4) = mi()
		if t2 == t3:
			f = 1
	if f == 1 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for test in range(t):
	(n, m) = [int(i) for i in input().split(' ')]
	res = 'NO'
	for i in range(n):
		(a1, a2) = [int(i) for i in input().split(' ')]
		(a3, a4) = [int(i) for i in input().split(' ')]
		if a3 == a2:
			res = 'YES'
	if m % 2 == 1:
		res = 'NO'
	print(res)


import sys
input = sys.stdin.readline
(inp, ip) = (lambda : int(input()), lambda : [int(w) for w in input().split()])
for _ in range(inp()):
	(n, m) = ip()
	flag = 1
	for i in range(n):
		a = ip()
		b = ip()
		if a[1] == b[0]:
			flag = 0
	if m & 1:
		print('NO')
		continue
	if flag:
		print('NO')
	else:
		print('YES')


T = int(input())

def solve(n, m, tiles):
	if m % 2 == 1:
		print('NO')
		return
	for (t0, t1) in tiles:
		(a, b) = t0
		(c, d) = t1
		if b == c:
			print('YES')
			return
	print('NO')
for _ in range(T):
	(n, m) = map(int, input().split())
	tiles = []
	for _ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		tiles.append([[a, b], [c, d]])
	solve(n, m, tiles)


t = int(input())
output = []
for q in range(t):
	(n, m) = [int(i) for i in input().split()]
	flag = False
	for i in range(n):
		(a, b) = [int(k) for k in input().split()]
		(c, d) = [int(k) for k in input().split()]
		if b == c:
			flag = True
	if flag and m % 2 == 0:
		output.append('YES')
	else:
		output.append('NO')
for i in output:
	print(i)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ok = False
	for i in range(n):
		(x, y) = map(int, input().split())
		(p, q) = map(int, input().split())
		if y == p:
			ok = True
	if m % 2 == 0:
		if ok:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	(TILE_COUNT, SQUARE_SIZE) = map(int, input().split())
	tiles = list()
	rez = 'NO'
	for t in range(TILE_COUNT):
		(e00, e01) = map(int, input().split())
		(e10, e11) = map(int, input().split())
		if e01 == e10:
			rez = 'YES'
	if SQUARE_SIZE % 2 == 1:
		print('NO')
	else:
		print(rez)


import os
import sys
from io import BytesIO, IOBase

def solution():
	pass

def main():
	for _ in range(r_int()):
		(n, m) = r_array()
		ok = False
		for _ in range(n):
			tile = []
			for _ in range(2):
				(x, y) = r_array()
				tile.append([x, y])
			if tile[0][1] == tile[1][0]:
				ok = True
		if m & 1:
			write('NO')
			continue
		if ok:
			write('YES')
		else:
			write('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(str(args[-1]))
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


for i in range(int(input())):
	(n, m) = [int(i) for i in input().split()]
	a = False
	for i in range(n):
		tile = [int(i) for i in input().split()] + [int(j) for j in input().split()]
		if tile[1] == tile[2]:
			a = True
	print('YES' if a and m % 2 == 0 else 'NO')


import os
import math
true = True
false = False
from functools import reduce
is_dev = 'vscode' in os.environ
if is_dev:
	inF = open('in.txt', 'r')
	outF = open('out.txt', 'w')

def ins():
	return list(map(int, input_().split(' ')))

def inss():
	return list(input_().split(' '))

def input_():
	if is_dev:
		return inF.readline()[:-1]
	else:
		return input()

def ranin():
	return range(int(input_()))

def print_(data):
	if is_dev:
		outF.write(str(data) + '\n')
	else:
		print(data)
for _ in ranin():
	(t, n) = ins()
	symmetric = false
	for _ in range(t):
		(t1, t2) = ins()
		(t3, t4) = ins()
		if t2 == t3:
			symmetric = true
	if symmetric and n % 2 == 0:
		print_('YES')
	else:
		print_('NO')
if is_dev:
	outF.close()

	def compare_file():
		print(open('out.txt', 'r').read() == open('outactual.txt', 'r').read())
	compare_file()


from sys import stdin, stdout
input = stdin.readline
print = lambda x: stdout.write(str(x) + '\n')
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ans = None
	for _ in range(n):
		(i, j) = map(int, input().split())
		(k, l) = map(int, input().split())
		if k == j:
			ans = 'YES'
	if m % 2:
		print('NO')
	elif ans:
		print('YES')
	else:
		print('NO')


import sys
import math
from functools import reduce
import bisect

def getN():
	return int(input())

def getNM():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def input():
	return sys.stdin.readline().rstrip()

def index(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	return False
for _ in range(int(input())):
	(n, m) = getNM()
	check = False
	for _ in range(n):
		(x1, y1) = getNM()
		(x2, y2) = getNM()
		if y1 == x2:
			check = True
	print('YES' if check and (not m & 1) else 'NO')


t = int(input())
while t:
	(n, m) = map(int, input().split())
	count = 0
	for i in range(1, n + 1):
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		if a[1] == b[0]:
			count += 1
	if m % 2 == 1:
		print('NO')
	elif count >= 1:
		print('YES')
	else:
		print('NO')
	t = t - 1


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	(n, m) = sp()
	mat = []
	for i in range(2 * n):
		mat.append(l())
	if m & 1:
		out('NO')
		continue
	r = False
	for i in range(n):
		if mat[2 * i][1] == mat[2 * i + 1][0]:
			r = True
	out(('NO', 'YES')[r])


from bisect import bisect_left, bisect_right
import os
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import deque, defaultdict
import math
import heapq
import re

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
LOW = 'abcdefghijklmnopqrstuvwxyz'
UP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def main():
	for _ in range(iin()):
		(n, m) = ain()
		ans = 0
		for i in range(n):
			(x, y) = ain()
			(p, q) = ain()
			if y == p:
				ans += 1
		if ans >= 1 and m % 2 == 0:
			print('YES')
		else:
			print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split(' ')]
	yes = False
	for i in range(n):
		(a, b) = [int(x) for x in input().split(' ')]
		(c, d) = [int(x) for x in input().split(' ')]
		if c == b:
			yes = True
	if yes and k % 2 == 0:
		print('YES')
	else:
		print('NO')


T = int(input())
res = list()
for _ in range(T):
	(a, b) = tuple(map(int, input().split()))
	r = list()
	for j in range(a * 2):
		x = list(map(int, input().split()))
		r.append(x)
	if b % 2 != 0:
		res.append('NO')
		continue
	ok = False
	for i in range(0, len(r), 2):
		if r[i][1] == r[i + 1][0]:
			ok = True
			break
		else:
			ok = False
	if ok:
		res.append('YES')
	else:
		res.append('NO')
for i in res:
	print(i)


for I in range(int(input())):
	(n, m) = map(int, input().split())
	type1 = False
	for i in range(n):
		(a1, a2) = map(int, input().split())
		(a3, a4) = map(int, input().split())
		if a2 == a3:
			type1 = True
	if type1 and m % 2 != 1:
		print('YES')
	else:
		print('NO')


def listin():
	return [int(x) for x in input().split()]
t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	(count1, count2) = (0, 0)
	for j in range(n):
		X = listin()
		Y = listin()
		if X[1] == Y[0]:
			count1 += 1
	if m % 2 == 1:
		print('NO')
	elif count1 == 0:
		print('NO')
	else:
		print('YES')


from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()
for _ in range(int(I1())):
	(n, m) = I()
	s = 0
	di = 0
	for i in range(n):
		(a, b) = I()
		(c, d) = I()
		if b == c:
			di += 1
		if b == c and a == d:
			s += 1
	if m % 2 != 0:
		print('NO')
	elif di >= 1:
		print('YES')
	else:
		print('NO')


def isSym(a):
	if a[0][1] == a[1][0]:
		return True
	else:
		return False

def valid(a, m):
	flag = 0
	if m % 2 == 0:
		for i in range(a):
			arr = []
			arr.append(list(map(int, input().split())))
			arr.append(list(map(int, input().split())))
			if isSym(arr):
				flag = 1
	else:
		for i in range(a):
			arr = []
			arr.append(list(map(int, input().split())))
			arr.append(list(map(int, input().split())))
	return flag
t = int(input())
while t:
	(a, m) = map(int, input().split())
	if valid(a, m):
		print('YES')
	else:
		print('NO')
	t -= 1


import sys, os.path
from collections import *
from copy import *
import math
mod = 10 ** 9 + 7
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for t in range(int(input())):
	(n, m) = map(int, input().split())
	mat = []
	mat1 = []
	for i in range(n):
		for j in range(2):
			l = list(map(int, input().split()))
			mat1.append(l)
		mat.append(mat1)
	if m % 2 == 1:
		print('NO')
	else:
		flag = 0
		n1 = len(mat1)
		for i in range(0, n1, 2):
			if mat1[i][1] == mat1[i + 1][0]:
				flag = 1
				break
		if flag == 1:
			print('YES')
		else:
			print('NO')


def solve(n):
	if n == 1:
		return 0
	if n == 2:
		return 1
	if n % 2 == 0:
		return 1 + n // 2
	return 1 + findCount(n - 1)
t = int(input())
while t:
	(n, m) = list(map(int, input().split()))
	ans = False
	for _ in range(n):
		matrix = []
		for i in range(2):
			intermediate = list(map(int, input().split()))
			matrix.append(intermediate)
		if matrix[0][1] == matrix[1][0]:
			ans = True
	if ans and m % 2 == 0:
		print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())
while t:
	(n, m) = map(int, input().split())
	ans = False
	while n:
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		ans = ans or c == b
		n -= 1
	if ans and m % 2 == 0:
		print('YES')
	else:
		print('NO')
	t -= 1


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
from collections import deque, Counter, OrderedDict, defaultdict
from itertools import permutations, combinations
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split())

def msi():
	return map(str, input().strip().split())

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
from collections import deque, Counter, OrderedDict, defaultdict
from math import *
from itertools import permutations, combinations
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
vow = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def expo(x, y, m):
	if y == 0:
		return 1
	elif y % 2 == 0:
		return expo(x * x % m, y / 2, m)
	else:
		return x * expo(x * x % m, (y - 1) / 2, m) % m

def gcd(a, b):
	if a == 0:
		return (b, 0, 1)
	(gc, x1, y1) = gcd(b % a, a)
	x = y1 - b // a * x1
	y = x1
	return (gc, x, y)

def sieve(n):
	arr = [True] * (n + 1)
	arr[0] = False
	arr[1] = False
	for i in range(4, n + 1, 2):
		arr[i] = False
	for i in range(3, int(sqrt(n)) + 1, 2):
		if arr[i] == True:
			for j in range(i * i, n + 1, i):
				arr[j] = False
	return arr

def modInverse(x, y):
	(gc, x1, y1) = gcd(x, y)
	return (y1 + y) % y

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	for _ in range(ii()):
		(n, k) = mi()
		arr = []
		for i in range(n):
			l = li()
			b = li()
			arr.append([l, b])
		if k % 2 == 1:
			print('NO')
		else:
			count = 1
			for i in range(n):
				if arr[i][0][1] == arr[i][1][0]:
					count -= 1
					if count == 0:
						break
			print('YES') if count == 0 else print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


T = int(input())
for _ in range(T):
	(n, m) = map(int, input().split())
	c = 0
	for i in range(n):
		(u, v) = map(int, input().split())
		(x, y) = map(int, input().split())
		if v == x:
			c += 1
	if m % 2 == 0 and c:
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(0, a):
	(b, c) = map(int, input().split())
	p = 0
	for j in range(0, b):
		(d, e) = map(int, input().split())
		(f, g) = map(int, input().split())
		if e == f:
			p += 1
	if p >= 1 and c % 2 == 0:
		print('Yes')
	else:
		print('No')


t = int(input())
while t > 0:
	t = t - 1
	l = input().split()
	n = int(l[0])
	m = int(l[1])
	f = 0
	for i in range(n):
		a1 = input().split()
		a2 = input().split()
		a3 = int(a1[1])
		a4 = int(a2[0])
		if a3 == a4:
			f = 1
	if m % 2 != 0:
		print('NO')
	elif f == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().strip().split())
	types = []
	for i in range(n):
		arr = []
		for i in range(2):
			arr.append(input().strip().split())
		if arr[0][1] == arr[1][0]:
			types.append(1)
	if m % 2 != 0:
		print('NO')
	elif len(types) >= 1:
		print('YES')
	else:
		print('NO')


import math
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	if m % 2 == 1:
		for i in range(n):
			(a, b) = map(int, input().split())
			(c, d) = map(int, input().split())
		print('NO')
		continue
	flag = False
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if c == b:
			flag = True
	if flag:
		print('YES')
	else:
		print('NO')


import math
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(100000)

def put():
	return map(int, stdin.readline().split())
for _ in range(int(input())):
	(n, m) = put()
	f = 0
	for i in range(n):
		(a, b) = put()
		(c, d) = put()
		if b == c:
			f = 1
	if m % 2 == 1 or f == 0:
		print('NO')
	else:
		print('YES')


def tiles_checker(tiles, n, m):
	if m % 2:
		return 'NO'
	for i in range(n):
		tile = tiles[i]
		if tile[1] == tile[2]:
			return 'YES'
	return 'NO'
t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	tiles = [[0] * 4 for _ in range(n)]
	for j in range(n):
		tiles[j][0:1] = [int(x) for x in input().split()]
		tiles[j][2:3] = [int(x) for x in input().split()]
	val = tiles_checker(tiles, n, m)
	print(val)


for __ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	ans = 'NO'
	for i in range(n):
		(a, b) = list(map(int, input().split()))
		(c, d) = list(map(int, input().split()))
		if b == c:
			ans = 'YES'
	if m % 2 == 1:
		ans = 'NO'
	print(ans)


t = int(input())
for i in range(t):
	temp = [int(x) for x in input().split()]
	n = temp[0]
	m = temp[1]
	s = []
	for j in range(2 * n):
		s.append([int(x) for x in input().split()])
	if m == 1:
		print('NO')
	elif m == 2:
		bool = True
		for j in range(0, 2 * n, 2):
			if s[j][1] == s[j + 1][0]:
				bool = False
				print('YES')
				break
		if bool:
			print('NO')
	else:
		bool = True
		for j in range(0, 2 * n, 2):
			if m % 2 == 0 and s[j][1] == s[j + 1][0]:
				bool = False
				print('YES')
				break
		if bool:
			print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ans = 'NO'
	for _ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			ans = 'YES'
	if m % 2:
		ans = 'NO'
	print(ans)


for _ in [0] * int(input()):
	(n, m) = map(int, input().split())
	a = 0
	for i in range(n):
		(L1, L2) = map(int, input().split())
		(r1, r2) = map(int, input().split())
		if L2 == r1:
			a = 1
	if m % 2 == 1:
		a = 0
	if a:
		print('Yes')
	else:
		print('No')


import os
import sys
from io import BytesIO, IOBase
import math
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(n, m) = map(int, input().split(' '))
	r = 'NO'
	for i in range(n):
		(x1, y1) = map(int, input().split(' '))
		(x2, y2) = map(int, input().split(' '))
		if y1 == x2:
			r = 'YES'
	if m % 2:
		print('NO')
	else:
		print(r)


def cmp(key):
	return key[0]
t = int(input())
for i in range(t):
	(n, m) = [int(i) for i in input().split()]
	soloton = 0
	a = [[[int(column) for column in input().split()] for string in range(2)] for i in range(n)]
	if m % 2 != 0:
		print('NO')
	else:
		for matrix in a:
			if matrix[0][1] == matrix[1][0]:
				soloton = 1
		if soloton == 1:
			print('YES')
		else:
			print('NO')


def print_result(ans):
	print(ans)

def solve(tile):
	return tile[0][1] == tile[1][0]
t = int(input())
for i in range(1, t + 1):
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	ans = 'NO'
	for i in range(n):
		tile_1 = list(map(int, input().split()))
		tile_2 = list(map(int, input().split()))
		tile = [tile_1, tile_2]
		if solve(tile):
			ans = 'YES'
	if m % 2 != 0:
		ans = 'NO'
	print_result(ans)


t = int(input())
for _ in range(t):
	inp = list(map(int, input().split()))
	n = inp[0]
	m = inp[1]
	flag = 0
	for i in range(n):
		arr1 = list(map(int, input().split()))
		arr2 = list(map(int, input().split()))
		if arr1[1] == arr2[0]:
			flag = 1
	if flag == 1 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


from collections import *
from functools import *
import math
import sys
inp = sys.stdin.readline
out = sys.stdout.write

def mi():
	return map(int, inp().split())

def li():
	return list(mi())

def ii():
	return int(inp())

def main():
	for _ in range(ii()):
		(n, m) = mi()
		f = 0
		for _ in range(n):
			(a, b) = mi()
			(c, d) = mi()
			if b == c:
				f = 1
		if m % 2 != 0:
			print('NO')
		elif f == 1:
			print('YES')
		else:
			print('NO')
main()


from collections import defaultdict
import sys
import math

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	(n, k) = get_ints()
	flag = False
	for i in range(n):
		(a, b) = get_ints()
		(x, y) = get_ints()
		if b == x:
			flag = True
	if k & 1 or not flag:
		print('NO')
	else:
		print('YES')


def solve():
	(n, m) = list(map(int, input().split()))
	sym = False
	for i in range(n):
		(x, y) = list(map(int, input().split()))
		(z, w) = list(map(int, input().split()))
		if y == z:
			sym = True
	if m % 2 == 0 and sym:
		print('YES')
	else:
		print('NO')
	return

def main():
	T = int(input())
	for i in range(T):
		solve()
	return

def __starting_point():
	main()
__starting_point()


import math
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	solve = False
	for _ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			solve = True
	if m % 2 > 0:
		solve = False
	print('YES' if solve else 'NO')


import sys
input = sys.stdin.readline
for test in range(int(input())):
	(n, m) = map(int, input().split())
	answer = 0
	for _ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			answer = 1
	if m & 1:
		answer = 0
	print('YES' if answer else 'NO')


def read_int() -> int:
	return int(input())

def read_ints():
	return map(int, input().split(' '))

def test_case():
	(n, m) = read_ints()
	found = False
	for _ in range(n):
		(a, b) = read_ints()
		(c, d) = read_ints()
		if b == c:
			found = True
	print('YES' if found and m % 2 == 0 and (m > 1) else 'NO')
for _ in range(read_int()):
	test_case()


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from collections import *
import math
for _ in range(ii()):
	(n, k) = f()
	cl = 0
	for i in range(0, n):
		(a, b) = f()
		(c, d) = f()
		if b == c:
			cl = cl + 1
	if k % 2 != 0 or cl == 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(0, t):
	(m, n) = map(int, input().split())
	ct1 = 0
	if n % 2 != 0:
		str1 = 'NO'
		ct1 = 1
	ct = 0
	for i in range(0, m):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			ct += 1
	if ct1 == 0:
		if ct == 0:
			str1 = 'NO'
		else:
			str1 = 'YES'
	print(str1)


T = int(input())
for i in range(T):
	(n, m) = map(int, input().split())
	a = []
	for j in range(n):
		a.append([[int(x) for x in input().split()] for j in range(2)])
	ok = False
	for k in range(n):
		ok |= a[k][0][1] == a[k][1][0]
	ok &= m % 2 == 0
	print('YES' if ok else 'NO')


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	(n, k) = R()
	flg = False
	for i in range(n):
		(x, y) = R()
		(a, b) = R()
		if y == a:
			flg = True
	if flg and k % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	found = False
	for z in range(n):
		current_block = []
		for j in range(2):
			current_block.append([int(elem) for elem in input().split()])
		if current_block[0][1] == current_block[1][0]:
			found = True
	if found and m % 2 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	ss = 0
	for i in range(n):
		(a, b) = [int(x) for x in input().split()]
		(c, d) = [int(x) for x in input().split()]
		if b == c:
			ss = 1
	if k % 2 == 0 and ss:
		print('YES')
	else:
		print('NO')


tc = int(input())
for _ in range(tc):
	(n, m) = [int(x) for x in input().split()]
	has_valid_diagonal_tile = False
	for _ in range(n):
		l1 = [int(i) for i in input().split()]
		l2 = [int(e) for e in input().split()]
		if l1[1] == l2[0]:
			has_valid_diagonal_tile = True
	if m & 1 or not has_valid_diagonal_tile:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	f = False
	for a in range(n):
		lst1 = list(map(int, input().split()))
		lst2 = list(map(int, input().split()))
		if m % 2 == 1:
			continue
		if lst1[1] == lst2[0]:
			f = True
	if f == True:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	(n, m) = list(map(int, input().split()))
	a = []
	for i in range(2 * n):
		a.append(list(map(int, input().split())))
	if m % 2 == 0:
		p = 0
		for i in range(0, 2 * n, 2):
			if a[i][1] == a[i + 1][0]:
				print('YES')
				break
		else:
			print('NO')
	else:
		print('NO')
	t -= 1


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
for _ in range(iinput()):
	(n, m) = rinput()
	tiles = []
	for i in range(n):
		(tl, tr) = rinput()
		(bl, br) = rinput()
		tiles.append([[tl, tr], [bl, br]])
	if m % 2 != 0:
		print('NO')
		continue
	flag = ld = rd = False
	for t in range(n):
		if tiles[t][0][0] == tiles[t][0][1] == tiles[t][1][0] == tiles[t][1][1]:
			flag = True
			break
		if tiles[t][0][0] == tiles[t][1][1]:
			ld = True
		if tiles[t][0][1] == tiles[t][1][0]:
			rd = True
	if flag == True or rd == True:
		print('YES')
	else:
		print('NO')


import sys
import math
from collections import defaultdict, Counter
input = sys.stdin.readline

def print(x):
	sys.stdout.write(str(x) + '\n')
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	flag = 1
	for j in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if c == b:
			flag = 0
	if m % 2 != 0 or flag:
		print('NO')
	else:
		print('YES')


import sys, io, os, time
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
input = sys.stdin.readline
for ii in range(int(input())):
	(n, m) = map(int, input().split())
	arr = []
	for i in range(n):
		arr.append([])
		arr[-1].append(list(map(int, input().split())))
		arr[-1].append(list(map(int, input().split())))
	if m % 2 != 0:
		print('NO')
		continue
	else:
		f = 0
		for i in range(n):
			if arr[i][0][1] == arr[i][1][0]:
				f = 1
		if f:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	ans = 'NO'
	(n, m) = [int(i) for i in input().split()]
	for i in range(n):
		mat = [[int(i) for i in input().split()], [int(i) for i in input().split()]]
		if mat[0][1] == mat[1][0]:
			ans = 'YES'
	if m % 2 == 1:
		ans = 'NO'
	print(ans)


for i in range(int(input())):
	(n, m) = list(map(int, input().split()))
	flag1 = 0
	for i in range(n):
		(one, two) = list(map(int, input().split()))
		(three, four) = list(map(int, input().split()))
		if two == three:
			flag1 = 1
	if m % 2 == 0 and flag1 == 1:
		print('YES')
	else:
		print('NO')


from __future__ import division, print_function
import bisect
import math
import heapq
import itertools
import sys
from collections import deque
from atexit import register
from collections import Counter
from functools import reduce
if sys.version_info[0] < 3:
	from io import BytesIO as stream
else:
	from io import StringIO as stream
if sys.version_info[0] < 3:

	class dict(dict):

		def items(self):
			return dict.iteritems(self)

		def keys(self):
			return dict.iterkeys(self)

		def values(self):
			return dict.itervalues(self)
	input = raw_input
	range = xrange
	filter = itertools.ifilter
	map = itertools.imap
	zip = itertools.izip

def sync_with_stdio(sync=True):
	global input, flush
	if sync:
		flush = sys.stdout.flush
	else:
		sys.stdin = stream(sys.stdin.read())
		input = lambda : sys.stdin.readline().rstrip('\r\n')
		sys.stdout = stream()
		register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))

def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		flag = 0
		for i in range(n):
			(a, b) = map(int, input().split())
			(c, d) = map(int, input().split())
			if c == b:
				flag = 1
		if m % 2 == 1:
			print('NO')
			continue
		print('YES' if flag == 1 else 'NO')
sync_with_stdio(False)
main()


def check(flst, size):
	if size <= 0:
		return 'NO'
	elif size % 2 == 0:
		for each in flst:
			if each[1] == each[2]:
				return 'YES'
		return 'NO'
	else:
		return 'NO'
tsts = int(input())
for i in range(tsts):
	init = input().split(' ')
	types = int(init[0])
	size = int(init[1])
	flst = []
	for j in range(types):
		r1 = input().split(' ')
		r2 = input().split(' ')
		flst.append([int(r1[0]), int(r1[1]), int(r2[0]), int(r2[1])])
	print(check(flst, size))


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	done = 0
	for i in range(n):
		(tl, tr) = map(int, input().split())
		(bl, br) = map(int, input().split())
		if done:
			pass
		elif bl == tr:
			done = 1
	if m % 2:
		done = 0
	if done:
		print('YES')
	else:
		print('NO')


import sys
import math
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	ok = 0
	for _ in range(n):
		(a, b) = list(map(int, input().split()))
		(c, d) = list(map(int, input().split()))
		if b == c and m % 2 == 0:
			ok = 1
	if ok == 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	switch = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			switch = 1
	if m % 2 != 0:
		print('NO')
	elif switch == 0:
		print('NO')
	elif switch == 1:
		print('YES')


c = int(input())
while c:
	c -= 1
	(n, m) = map(int, input().split())
	cases = n
	pair_one = False
	pair_two = False
	while cases:
		cases -= 1
		(a, b) = map(int, input().split())
		(b2, a2) = map(int, input().split())
		if a == a2:
			pair_one = True
		if b2 == b:
			pair_two = True
	if pair_two and m % 2 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	c = 0
	for i in range(n):
		(l1, l2) = map(int, input().split())
		(l3, l4) = map(int, input().split())
		if l2 == l3:
			c = c + 1
	if c > 0 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	boo = False
	for i in range(n):
		a = [int(i) for i in input().split()]
		b = [int(i) for i in input().split()]
		if a[1] == b[0]:
			boo = True
	ans = 'YES' if boo and m % 2 == 0 else 'NO'
	print(ans)


def process(M, m):
	if m % 2 == 1:
		return 'NO'
	for matrix in M:
		if matrix[0][1] == matrix[1][0]:
			return 'YES'
	return 'NO'
t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	M = []
	for i in range(n):
		r1 = [int(x) for x in input().split()]
		r2 = [int(x) for x in input().split()]
		M.append([r1, r2])
	print(process(M, m))


import sys
for i in range(0, int(sys.stdin.readline())):
	nm = list(map(int, sys.stdin.readline().split()))
	matrices = []
	canDo = False
	for j in range(0, nm[0]):
		cm = []
		cm.extend(list(map(int, sys.stdin.readline().split())))
		cm.extend(list(map(int, sys.stdin.readline().split())))
		if cm[1] == cm[2]:
			canDo = True
	if canDo and nm[1] % 2 == 0:
		sys.stdout.write('YES\n')
	else:
		sys.stdout.write('NO\n')


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a
from collections import defaultdict

def solve():
	(n, m) = sep()
	t = 0
	for _ in range(n):
		ar = []
		ar.append(lis())
		ar.append(lis())
		if ar[1][0] == ar[0][1] and m % 2 == 0:
			t = 1
	if t == 1:
		print('YES')
	else:
		print('NO')
testcase(int(inp()))


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	nums = []
	for k in range(n):
		nums.append([[int(x) for x in input().split()] for a in range(2)])
	b = False
	for d in range(n):
		b |= nums[d][0][1] == nums[d][1][0]
	b &= m % 2 == 0
	print('YES' if b else 'NO')


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from heapq import *
from math import gcd, factorial, floor, ceil
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 10 ** 9 + 7

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	(n, m) = sep()
	a = False
	b = False
	for i in range(n):
		x = lis()
		y = lis()
		if x[0] == y[1]:
			a = True
		if y[0] == x[1]:
			b = True
	if m % 2 == 1:
		print('NO')
		return
	if b:
		print('YES')
	else:
		print('NO')
testcase(int(inp()))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	min_req = m // 2
	cnt = 0
	if m % 2 != 0:
		for i in range(n):
			(top_left, top_right) = map(int, input().split())
			(bottom_left, bottom_right) = map(int, input().split())
		print('NO')
	else:
		for i in range(n):
			top_right = 0
			top_left = 0
			bottom_left = 0
			bottom_right = 0
			(top_left, top_right) = map(int, input().split())
			(bottom_left, bottom_right) = map(int, input().split())
			if top_right == bottom_left:
				cnt += 1
		if cnt >= 1:
			print('YES')
		else:
			print('NO')


inp = lambda : int(input())
seq = lambda : list(map(int, input().strip().split()))

def results(n, m, arr):
	if m % 2:
		return 'NO'
	else:
		for x in arr:
			if x[0][1] == x[1][0]:
				return 'YES'
	return 'NO'

def main():
	t = inp()
	for _ in range(t):
		nm = seq()
		(n, m) = (nm[0], nm[1])
		temp = []
		for i in range(n):
			tmp = []
			tmp.append(seq())
			tmp.append(seq())
			temp.append(tmp)
		result = results(n, m, temp)
		print(result)
main()


T = int(input())
for i in range(T):
	(n, m) = map(int, input().split())
	lst = []
	flag = 0
	for i in range(n):
		(x, y) = map(int, input().split())
		(w, z) = map(int, input().split())
		if y == w:
			flag = 1
	if flag == 1:
		if m % 2 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	threeD = []
	for i in range(n):
		temp = [list(map(int, input().split())), list(map(int, input().split()))]
		threeD.append(temp)
	if m == 1:
		print('NO')
		continue
	if m % 2 != 0:
		print('NO')
		continue
	for twoD in threeD:
		(row1, row2) = (twoD[0], twoD[1])
		if row2[0] == row1[1]:
			print('YES')
			break
	else:
		print('NO')


def get_all_test_cases():
	n = int(input())
	cases = []
	for i in range(0, n):
		cases.append(get_single_test_case())
	return cases

def get_single_test_case():
	(n, m) = map(int, input().split())
	matricies = []
	for i in range(0, n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		matrix = [a, b, c, d]
		matricies.append(matrix)
	return (m, matricies)

def can_tile(test):
	m = test[0]
	matricies = test[1]
	n = len(matricies)
	if m % 2 != 0:
		return False
	for i in range(0, n):
		if matricies[i][1] == matricies[i][2]:
			return True
	return False
tests = get_all_test_cases()
for i in range(0, len(tests)):
	if can_tile(tests[i]):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	chek = 0
	for i in range(n):
		(a1, a2) = map(int, input().split())
		(b1, b2) = map(int, input().split())
		if b1 == a2:
			chek = chek + 1
	if chek >= 1 and m % 2 == 0:
		print('Yes')
	else:
		print('No')


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(n, m) = map(int, stdin.readline().split())
	shan = 0
	for i in range(0, 2 * n, 2):
		(a, b) = map(int, stdin.readline().split())
		(x, y) = map(int, stdin.readline().split())
		if b == x:
			shan = 1
	if shan and m % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
list1 = []
for i in range(t):
	num = 0
	(n, m) = map(int, input().split())
	list3 = []
	for a in range(n):
		list2 = []
		for b in range(2):
			(x, y) = map(int, input().split())
			list2.extend([x, y])
		list3.append(list2)
	if m % 2 == 1:
		list1.append('NO')
	else:
		for r in list3:
			if r[1] == r[2]:
				list1.append('YES')
				num += 1
				break
		if num == 0:
			list1.append('NO')
for i in list1:
	print(i)


import math
t = int(input())
for k in range(t):
	(n, m) = map(int, input().split())
	flag = 0
	for i in range(n):
		(p, q) = map(int, input().split())
		(r, s) = map(int, input().split())
		if q == r:
			flag = 1
	if m % 2 == 1:
		print('NO')
	elif flag == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	c = 0
	arr = list(map(int, input().rstrip().split()))
	for _ in range(arr[0]):
		arr2 = []
		for _ in range(2):
			arr1 = list(map(int, input().rstrip().split()))
			arr2.append(arr1)
		if arr2[0][1] == arr2[1][0]:
			c += 1
	if c > 0 and arr[1] % 2 == 0:
		print('YES')
	else:
		print('NO')


o = int(input())
for i in range(o):
	pr = 0
	(n, m) = map(int, input().split())
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if c == b:
			pr = 1
	if pr and m % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split(' ')))
	if m % 2 == 1:
		for h in range(n):
			_ = input()
			_ = input()
		print('NO')
	else:
		flag = False
		for j in range(n):
			(_, s12) = list(map(int, input().split(' ')))
			(s21, _) = list(map(int, input().split(' ')))
			if s12 == s21:
				flag = True
				continue
		print('YES' if flag else 'NO')


import sys
read = sys.stdin.readline

def solution(n, m, tiles):
	if m % 2 != 0:
		return False
	for tile in tiles:
		if tile[0][1] == tile[1][0]:
			return True
	return False
t = int(read())
for _ in range(t):
	(n, m) = list(map(int, read().split()))
	tiles = []
	for _ in range(n):
		tile = []
		tile.append(list(map(int, read().split())))
		tile.append(list(map(int, read().split())))
		tiles.append(tile)
	print('Yes' if solution(n, m, tiles) else 'No')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	ans = 0
	for _ in range(n):
		s1 = list(input().split())
		s2 = list(input().split())
		if s1[1] == s2[0]:
			ans = 1
	if m % 2 != 0:
		ans = 0
	print(['NO', 'YES'][ans])


from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from fractions import Fraction
from decimal import Decimal
import math
mod = pow(10, 9) + 7

def sp():
	return map(int, input().split())

def sli():
	return list(sp())

def fun(x):
	return sum((int(i) for i in str(x)))

def find(n):
	if n == 3:
		return 3
	while 1:
		flag = 0
		for i in range(2, int(sqrt(n)) + 1):
			if n % i == 0:
				n += 1
				break
			if i == int(sqrt(n)):
				flag = 1
				break
		if flag:
			break
	return n
t = int(input())
for _ in range(t):
	(n, m) = sp()
	l = [[0] * 4 for i in range(n)]
	for i in range(n):
		(a, b) = sp()
		(c, d) = sp()
		l[i][0] = a
		l[i][1] = b
		l[i][2] = c
		l[i][3] = d
	if m % 2:
		print('NO')
	elif m == 2:
		f = 1
		for i in range(n):
			if l[i][1] == l[i][2]:
				f = 0
				print('YES')
				break
		if f:
			print('NO')
	else:
		f = 1
		for i in range(n):
			if l[i][1] == l[i][2]:
				f = 0
				print('YES')
				break
		if f:
			print('NO')


for _ in range(int(input())):
	(tiles, size) = map(int, input().split())
	di = False
	for _ in range(tiles):
		(a, b) = input().split()
		(c, d) = input().split()
		di |= c == b
	if not di or size & 1:
		print('NO')
	else:
		print('YES')


def solve(tiles, n):
	isdiag = False
	for ith_tile in range(tiles):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			isdiag = True
	max_tiles = n * (n + 1) // 2
	if isdiag and n % 2 == 0:
		return 'YES'
	return 'NO'
for case in range(int(input())):
	(a, b) = map(int, input().split())
	ans = solve(a, b)
	print(ans)


t = int(input())
for t0 in range(t):
	bool1 = False
	(n, m_rasmer) = map(int, input().split())
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if c == b and m_rasmer % 2 == 0 or bool1:
			bool1 = True
	if bool1:
		print('YES')
	else:
		print('NO')


for run in range(int(input())):
	doIt = False
	(n, m) = map(int, input().split())
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c and m % 2 == 0:
			doIt = True
	if doIt:
		print('YES')
	else:
		print('NO')


t = int(input())
ans = []
for i in range(t):
	(n, m) = map(int, input().split())
	current = 'NO'
	for j in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			current = 'YES'
	if m % 2 == 1:
		current = 'NO'
	ans.append(current)
print(*ans, sep='\n')


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from itertools import accumulate

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	for _ in range(Int()):
		(n, m) = Mint()
		c = 0
		for i in range(n):
			(p, q) = Mint()
			(x, y) = Mint()
			if x == q:
				c += 1
		if c == 0 or m % 2 == 1:
			print('NO')
		else:
			print('YES')
solution()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	n_tiles = []
	for _ in range(n):
		tile = []
		r1 = list(map(int, input().split()))
		tile.append(r1)
		r2 = list(map(int, input().split()))
		tile.append(r2)
		n_tiles.append(tile)
	if m % 2 == 0:
		for mat in n_tiles:
			if mat[0][1] == mat[1][0]:
				print('YES')
				break
		else:
			print('NO')
	else:
		print('NO')


import math

def solve():
	(n, x) = [int(x) for x in input().split()]
	a = []
	for i in range(n):
		a.append([[int(x) for x in input().split()] for y in range(2)])
	bo = False
	if x % 2 == 1:
		print('NO')
		return 0
	for i in range(n):
		if a[i][1][0] == a[i][0][1]:
			bo = True
			break
	if bo == True:
		print('YES')
	else:
		print('NO')
t = int(input())
for _ in range(t):
	solve()


from sys import stdin, stdout
input = stdin.readline
from collections import defaultdict as dd
import math

def geti():
	return list(map(int, input().strip().split()))

def getl():
	return list(map(int, input().strip().split()))

def gets():
	return input()

def geta():
	return int(input())

def print_s(s):
	stdout.write(s + '\n')

def solve():
	for _ in range(geta()):
		(n, m) = geti()
		ok = False
		for i in range(n):
			(a, b) = geti()
			(c, d) = geti()
			if b == c:
				ok = True
		if ok and m & 1 == 0:
			print('YES')
		else:
			print('NO')

def __starting_point():
	solve()
__starting_point()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	ans = []
	flag = 0
	for i in range(2 * n):
		lol = [int(n) for n in input().split()]
		ans.append(lol)
	for j in range(0, 2 * n, 2):
		if ans[j][1] == ans[j + 1][0]:
			flag = 1
			break
	if flag == 0:
		print('NO')
	elif flag == 1 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	flag = False
	for j in range(n):
		(x, y) = map(int, input().split())
		(z, r) = map(int, input().split())
		if z == y:
			flag = True
	if flag and m % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	t -= 1
	(n, m) = input().split()
	(n, m) = (int(n), int(m))
	flag = 0
	for i in range(n):
		(x1, x2) = input().split()
		(x3, x4) = input().split()
		if x2 == x3:
			flag = 1
	if m % 2 == 1:
		flag = 0
	if flag:
		print('YES')
	else:
		print('NO')


from sys import *
input = stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ch = 0
	if m % 2 == 1:
		ch = -1
	for i in range(n):
		(x1, y1) = map(int, input().split())
		(y2, x2) = map(int, input().split())
		if ch == 0 and y1 == y2:
			ch = 1
	if ch == -1 or ch == 0:
		stdout.write('NO\n')
	else:
		stdout.write('YES\n')


def check(m):
	if m[0][1] == m[1][0]:
		return True
	return False
for i in range(int(input())):
	(n, m) = map(int, input().split())
	b = True
	k = True
	if m % 2 == 1:
		k = False
	for j in range(n):
		mat = [list(map(int, input().split())), list(map(int, input().split()))]
		if check(mat) and k:
			print('YES')
			b = False
			k = False
	if b:
		print('NO')


import math
import sys
t = int(input())
for cs in range(t):
	(n, m) = map(int, input().split())
	flag = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if c == b:
			flag = 1
	if m % 2:
		flag = 0
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = [int(i) for i in input().split()]
	nd = 0
	lst = []
	for __ in range(2 * n):
		lst.append([int(i) for i in input().split()])
		if len(lst) == 2:
			if lst[1][0] == lst[0][1]:
				nd = 1
			lst = []
	if m % 2 == 0 and nd == 1:
		print('YES')
	else:
		print('NO')


FunLL = lambda lis: lis[0][0] == lis[1][1]
FunRR = lambda lis: lis[0][1] == lis[1][0]
for tt in range(int(input())):
	(n, m) = map(int, input().split())
	(LL, RR, LR) = (False, False, False)
	arrays = [[list(map(int, input().split()))] + [list(map(int, input().split()))] for _ in range(n)]
	if m % 2 != 0:
		print('NO')
		continue
	for array in arrays:
		if FunLL(array) and FunRR(array):
			LR = 1
			break
		elif FunRR(array):
			RR = True
	print('YES' if LR == 1 or RR == 1 else 'NO')


def main():
	(n, m) = list(map(int, input().split()))
	ans = 'NO'
	for j in range(n):
		A = []
		for i in range(2):
			A.append(list(map(int, input().split())))
		if A[0][1] == A[1][0]:
			ans = 'YES'
	if m % 2 == 1:
		return print('NO')
	print(ans)
for i in range(int(input())):
	main()


import math
t = int(input())
m_arr = []
pre_tile_arr = []
tile_arr = []
n_arr = []
for i in range(t):
	temp = list(map(int, input().split(' ')))
	n = temp[0]
	n_arr.append(n)
	m_arr.append(temp[1])
	pre_tile_arr = []
	for j in range(n):
		pre_tile_arr.append([list(map(int, input().split(' '))), list(map(int, input().split(' ')))])
	tile_arr.append(pre_tile_arr)
for i in range(len(tile_arr)):
	symmetric_ct = 0
	for j in range(n_arr[i]):
		if tile_arr[i][j][0][1] == tile_arr[i][j][1][0]:
			symmetric_ct += 1
	if symmetric_ct > 0:
		if m_arr[i] * m_arr[i] % 4 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def main():
	t = int(input())
	for _ in range(t):
		(n, m) = list(map(int, input().split()))
		ans = 'NO'
		for i in range(n):
			(a, b) = list(map(int, input().split()))
			(c, d) = list(map(int, input().split()))
			if b == c and m % 2 == 0:
				ans = 'YES'
		print(ans)
main()


import sys
r = sys.stdin.readline
for _ in range(int(r())):
	(N, M) = map(int, r().split())
	L = []
	for i in range(2 * N):
		ex = list(map(int, r().split()))
		if i % 2 == 1:
			L.append(a + ex)
		else:
			a = ex
	if M % 2 != 0:
		print('NO')
		continue
	flag = 0
	for i in L:
		if i[1] == i[2]:
			flag = 1
			break
	if flag:
		print('YES')
	else:
		print('NO')


def check(a):
	return a[0][0] == a[1][1] and a[1][0] == a[0][1]

def checkd(a):
	return a[0][1] == a[1][0]

def invert(a):
	temp = [[None, None], [None, None]]
	temp[0][0] = a[0][0]
	temp[1][1] = a[1][1]
	temp[0][1] = a[1][0]
	temp[1][0] = a[0][1]
	return temp

def compare(a, b):
	for i in range(2):
		for j in range(2):
			if a[i][j] != b[i][j]:
				return False
	return True
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ls = []
	gd = 0
	dg = 0
	bd = 0
	inv = 0
	for i in range(n):
		a = [list(map(int, input().split())), list(map(int, input().split()))]
		ls.append(a)
		if check(a):
			gd += 1
		elif checkd(a):
			dg += 1
		else:
			bd += 1
	if m % 2 == 1 or (gd == 0 and dg == 0):
		print('NO')
		continue
	elif gd:
		print('YES')
	else:
		f = True
		for i in range(n):
			if not f:
				break
			inverted = invert(ls[i])
			for j in range(n):
				if compare(inverted, ls[j]):
					f = False
					break
		if f:
			print('NO')
		else:
			print('YES')


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	(N, M) = map(int, sys.stdin.readline().split())
	canImake = 0
	for _ in range(N):
		(a, b) = map(int, sys.stdin.readline().split())
		(c, d) = map(int, sys.stdin.readline().split())
		if c == b:
			canImake = 1
	if M % 2 or not canImake:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inara():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for _ in range(t):
	(n, m) = invr()
	flag = False
	for i in range(n):
		(a, b) = invr()
		(c, d) = invr()
		if b == c:
			flag = True
	flag &= m % 2 == 0
	if flag:
		print('YES')
	else:
		print('NO')


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdarr = lambda : map(int, stdstr().split())
mod = 1000000007
for _ in range(stdint()):
	(n, m) = stdarr()
	tiles = []
	f = False
	for i in range(n):
		(a, b) = stdarr()
		(c, d) = stdarr()
		if b == c:
			f = True
	if f and m & 1 == 0:
		print('YES')
	else:
		print('NO')


def solve(n, m):
	f = True
	for i in range(n):
		p = list(map(int, input().split()))
		q = list(map(int, input().split()))
		if p[1] == q[0]:
			f = False
	if not f and m % 2 == 0:
		return 'YES'
	return 'NO'
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	print(solve(n, m))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	flag = 0
	for i in range(n):
		l = []
		for i in range(2):
			row = list(map(int, input().split()))
			l.append(row)
		if l[0][1] == l[1][0] and m % 2 == 0:
			flag = 1
	if flag == 1:
		print('YES')
	else:
		print('NO')


from enum import *
from copy import *
from sys import *
from collections import *
from itertools import *
from functools import *
from math import *

def l2i(fr=None):
	return map_type_to_fr(int, fr)[0]

def i2i(fr=None):
	return l2i(fr)

def dbg(*args):
	print(*args, file=stderr)

def dbv(var_name):
	print(f'{var_name} = {eval(var_name)}', file=stderr)

def map_type_to_fr(t, fr):
	global GETLINE_OFFSET
	if fr is None:
		if RUNNING_ON_MY_PC:
			fr = TEST_INP[GETLINE_OFFSET].split()
			GETLINE_OFFSET += 1
		else:
			fr = input().split()
	return list(map(t, fr))

def mis(fr=None):
	return map_type_to_fr(int, fr)

def mbs(fr=None):
	return map_type_to_fr(bool, fr)

def gs(fr=None):
	return map_type_to_fr(str, fr)[0]

def en(col):
	return enumerate(col)

def rn(*args):
	return range(*args)
import os
import sysconfig
RUNNING_ON_MY_PC = os.name == 'nt' and platform == 'win32' and (sysconfig.get_platform() == 'win-amd64')
GETLINE_OFFSET = 0
TEST_INP = '1\n1 6\n1 1\n1 1\n'.split('\n')

def my_r(x):
	c = ceil(x)
	if c - x > 0.5:
		return floor(x)
	return c
CType = namedtuple('CType', 'tl tr bl br')
for _ in range(i2i()):
	(n, m) = mis()
	cs = [None for _ in range(n)]
	sym = False
	for i in range(n):
		t = mis()
		b = mis()
		curr = CType(tl=t[0], tr=t[1], bl=b[0], br=b[1])
		cs[i] = curr
		if curr.tr == curr.bl:
			sym = True
	if m == 2 and sym:
		print('YES')
		continue
	if m % 2 != 0 or m < 4:
		print('NO')
	elif sym:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	t -= 1
	(n, m) = map(int, input().split())
	k = 0
	while n > 0:
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			k = 1
		n -= 1
	if k == 0:
		print('NO')
	elif m % 2 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	tl = []
	cond = False
	for i in range(n):
		(x1, y1) = map(int, input().split())
		(x2, y2) = map(int, input().split())
		if x2 == y1:
			cond = True
	if m & 1 == 0 and cond:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline

def solve():
	(n, m) = map(int, input().split())
	flag = 0
	for i in range(n):
		u = list(map(int, input().split()))
		d = list(map(int, input().split()))
		if u[1] == d[0]:
			flag = 1
	if m & 1 == 1:
		print('NO')
		return
	if flag == 1:
		print('YES')
	else:
		print('NO')
for _ in range(int(input())):
	solve()


def solve(n, m, a):
	if m % 2 != 0:
		return 'NO'
	ok = False
	for i in range(n):
		if a[i][0][1] == a[i][1][0]:
			ok = True
	if ok:
		return 'YES'
	else:
		return 'NO'
t = int(input())
while t:
	a = []
	(n, m) = map(int, input().split(' '))
	for i in range(n):
		a.append([[int(x) for x in input().split()] for i in range(2)])
	print(solve(n, m, a))
	t -= 1


for T in range(int(input())):
	(n, m) = list(map(int, input().split()))
	flag = 0
	for i in range(n):
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		if a[1] == b[0]:
			flag = 1
	if flag and m % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	d = {}
	f = 0
	for i in range(n):
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		if y == a:
			f = 1
	if m % 2 != 0:
		print('NO')
	elif f == 1:
		print('YES')
	else:
		print('NO')


import sys
import math
from operator import itemgetter, attrgetter, methodcaller
input = sys.stdin.readline
ttt = int(input())
for tt in range(ttt):
	(n, m) = map(int, input().split())
	flag = False
	M = []
	for i in range(2 * n):
		cur = [int(x) for x in input().split()]
		M.append(cur)
		if i & 1 and i != 0:
			if M[0][1] == M[1][0]:
				flag = True
			M = []
	if flag and (not m & 1):
		print('YES')
	else:
		print('NO')


from collections import *
from heapq import *
from math import *
t = int(input())
while t:
	t -= 1
	flag = False
	(n, m) = [int(x) for x in input().split()]
	for i in range(n):
		(a, b) = [int(x) for x in input().split()]
		(c, d) = [int(x) for x in input().split()]
		if b == c:
			flag = True
	if m % 2:
		print('NO')
	elif flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	s = input().split(' ')
	n = int(s[0])
	m = int(s[1])
	KeyMajor = 0
	for j in range(n):
		d = input().split(' ')
		LU = int(d[0])
		RU = int(d[1])
		f = input().split(' ')
		LD = int(f[0])
		RD = int(f[1])
		if RU == LD:
			KeyMajor += 1
	if KeyMajor >= 1 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


def solve(tiles, square_size):
	if square_size % 2:
		return False
	return any(map(diagonal_symmetric, tiles)) and set(map(diagonal_mirror, tiles)).intersection(set(tiles))

def diagonal_mirror(tile):
	return tuple(zip(*tile))

def diagonal_symmetric(tile):
	return diagonal_mirror(tile) == tile
t = int(input())
for _ in range(t):
	(n_types, square_size) = map(int, input().split())
	tiles = [(tuple(map(int, input().split())), tuple(map(int, input().split()))) for _ in range(n_types)]
	print('YES' if solve(tiles, square_size) else 'NO')


t = int(input())

def can_tile(tiles, n, m, bingo):
	if m % 2 == 1:
		return 'NO'
	if bingo:
		return 'YES'
	need_tiles = m // 2
result = []
for i in range(t):
	(n, m) = [int(x) for x in input().split(' ')]
	tiles = []
	bingo = False
	for i in range(n):
		tile = []
		tile.append([int(x) for x in input().split(' ')])
		tile.append([int(x) for x in input().split(' ')])
		if tile[0][1] == tile[1][0]:
			bingo = True
	if m % 2 == 1:
		result.append('NO')
	else:
		result.append('YES' if bingo else 'NO')
for i in range(t):
	print(result[i])


test = int(input())
for i in range(test):
	(n, m) = [int(x) for x in input().split(' ')]
	sq = []
	flag = 0
	for i in range(n):
		temp1 = [x for x in input().split(' ')]
		temp2 = [x for x in input().split(' ')]
		if temp2[0] == temp1[1]:
			flag = 1
	if m % 2 != 0:
		print('NO')
	elif flag == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	f = False
	for p in range(n):
		(y, x1) = input().split()
		(x2, z) = input().split()
		f = f or x1 == x2
	if m % 2 == 0 and f:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = []
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		arr.append((a, b, c, d))
	if m % 2 == 1:
		print('NO')
	else:
		(b, x) = (0, 1)
		for i in range(n):
			if arr[i][1] == arr[i][2]:
				b = 1
		if b == 0:
			x = 0
		b = 0
		if m >= 4:
			for i in range(n):
				for j in range(n):
					if arr[i][1] == arr[j][2] and arr[i][2] == arr[j][1] and (arr[i][0] == arr[j][0]) and (arr[i][3] == arr[j][3]):
						b = 1
			if b == 0:
				x = 0
		if x == 0:
			print('NO')
		else:
			print('YES')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	flag = 0
	for i in range(n):
		(a1, a2) = map(int, input().split())
		(b1, b2) = map(int, input().split())
		if b1 == a2:
			flag = 1
	if flag == 1 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


import sys
import os
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def sym_max(n, m, matrices):
	if m % 2 == 1:
		print('NO')
	else:
		cond = 'NO'
		for i in range(n):
			if matrices[i][0][1] == matrices[i][1][0]:
				cond = 'YES'
				break
		print(cond)
testcases = inp()
while testcases > 0:
	int_list = inlt()
	(n, m) = (int_list[0], int_list[1])
	matrices = []
	for i in range(n):
		matrices.append([inlt(), inlt()])
	sym_max(n, m, matrices)
	testcases -= 1


for i in range(int(input())):
	(n, m) = map(int, input().split())
	s = set()
	(flag1, flag2) = (False, False)
	for _ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			flag1 = True
			flag2 = True
		if (a, c, b, d) in s:
			flag2 = True
		s.add((a, b, c, d))
	if m % 2 != 0:
		print('NO')
		continue
	if m > 2:
		if flag1 and flag2:
			print('YES')
		else:
			print('NO')
	elif m == 2:
		if flag1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
ans = []
for i in range(t):
	temp = list(map(int, input().split()))
	n = temp[0]
	m = temp[1]
	if m % 2 == 1:
		for j in range(n):
			temp1 = list(map(int, input().split()))
			temp2 = list(map(int, input().split()))
		ans.append('NO')
	else:
		check = False
		for j in range(n):
			temp1 = list(map(int, input().split()))
			temp2 = list(map(int, input().split()))
			(tl, tr) = (temp1[0], temp1[1])
			(bl, br) = (temp2[0], temp2[1])
			if tr == bl:
				check = True
		if check == True:
			ans.append('YES')
		else:
			ans.append('NO')
for a in ans:
	print(a)


def read_int():
	return int(input())

def read_ints():
	return map(int, input().split(' '))
t = read_int()
for case_num in range(t):
	(n, m) = read_ints()
	diag = False
	for i in range(n):
		(a11, a12) = read_ints()
		(a21, a22) = read_ints()
		curr = [a11, a12, a21, a22]
		if a12 == a21:
			diag = True
	print('NO' if m % 2 == 1 or not diag else 'YES')


def map_int():
	return map(int, input().strip().split())

def solve():
	(n, m) = map_int()
	bottom_left_eq_upper_right = 0
	for _ in range(n):
		(top_left, top_right) = map_int()
		(bottom_left, bottom_right) = map_int()
		if bottom_left == top_right:
			bottom_left_eq_upper_right += 1
	if m & 1:
		return 'NO'
	if bottom_left_eq_upper_right > 0:
		return 'YES'
	return 'NO'
for _ in range(int(input().strip())):
	print(solve())


t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	valid_board = m >= 2 and m % 2 == 0
	valid = False
	for _ in range(n):
		(t1, t2) = [int(x) for x in input().split()]
		(t3, t4) = [int(x) for x in input().split()]
		if t2 == t3:
			valid = True
	print('YES' if valid_board and valid else 'NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	answer = 'NO'
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if c == b and (not m & 1):
			answer = 'YES'
	print(answer)


from math import ceil
for q in range(int(input())):
	(n, m) = map(int, input().split())
	f = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if c == b:
			f = 1
	if m * m % 4 != 0:
		print('NO')
		continue
	print('YES' if f else 'NO')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
from math import ceil, floor, sqrt, pow
for _ in range(N()):
	(n, k) = RL()
	dic = {}
	flag = False
	for _ in range(n):
		teil = RLL() + RLL()
		if teil[1] == teil[2]:
			flag = True
	if k & 1:
		print('NO')
	elif flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	last_l = -1
	last_r = -1
	ans = False
	for i in range(2 * n):
		(l, r) = map(int, input().split())
		if i % 2 == 0:
			last_l = l
			last_r = r
		else:
			if last_r == l:
				ans = True
			last_r = -1
			last_l = -1
	if ans and m % 2 == 0:
		print('YES')
	else:
		print('NO')


import math
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	k = []
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		k.append([[a, b], [c, d]])
	if m % 2 == 1:
		print('NO')
	else:
		for i in k:
			if i[0][1] == i[1][0]:
				print('YES')
				break
		else:
			print('NO')


from sys import stdin, stdout
from math import gcd, log2, log10, floor, ceil, sqrt
import math
from collections import defaultdict, OrderedDict
from bisect import bisect_left

def fun(n, m):
	answer2 = 'YES'
	if m % 2 == 1:
		answer2 = 'NO'
	answer = 'NO'
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			answer = 'YES'
	if answer2 != 'YES':
		return answer2
	return answer
for i in range(int(input())):
	(n, m) = map(int, input().split())
	ans = fun(n, m)
	print(ans)


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')

def ceil(x, y=1):
	return int(-(-x // y))
import math
from collections import defaultdict
for _ in range(ri()):
	(n, m) = ria()
	l = []
	for __ in range(n):
		x = []
		x.append(ria())
		x.append(ria())
		l.append(x)
	if m & 1:
		ws('NO')
	else:
		for i in range(n):
			if l[i][1][0] == l[i][0][1]:
				ws('YES')
				break
		else:
			ws('NO')


def check_sym(mat):
	if mat[0][1] == mat[1][0]:
		return 1
	else:
		return 0
t = int(input())
while t:
	(n, m) = map(int, input().split())
	arr = []
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		temp = [[a, b], [c, d]]
		arr.append(temp)
	flag = 0
	if m % 2 == 1:
		print('NO')
	else:
		for mat in arr:
			if check_sym(mat) == 1:
				flag = 1
				print('YES')
				break
		if flag == 0:
			print('NO')
	t = t - 1


from collections import defaultdict as dd
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	t = m * m
	x = 0
	f = 0
	d = dd(int)
	for _ in range(n):
		(a, b) = map(int, input().split())
		(c, l) = map(int, input().split())
		if a == b == c == l:
			f = 1
		d[tuple([a, b, c, l])] = 1
		if b == c:
			x = 1
	if t % 4 != 0:
		print('NO')
		continue
	if m == 2:
		if f == 1 or x == 1:
			print('YES')
		else:
			print('NO')
		continue
	c = 0
	for (a, b, c, l) in list(d.keys()):
		if d[tuple([a, b, c, l])] == 1 and d[tuple([a, c, b, l])] == 1:
			c = 1
			break
	if f == 1:
		print('YES')
	elif x == 1 and c == 1:
		print('YES')
	else:
		print('NO')


def can_construct():
	if m % 2 == 1:
		for _ in range(n):
			(_, _) = map(int, input().split())
			(_, _) = map(int, input().split())
		print('NO')
		return
	tiles = set()
	for i in range(n):
		(tl, tr) = map(int, input().split())
		(bl, br) = map(int, input().split())
		if tr == bl:
			for _ in range(i + 1, n):
				(_, _) = map(int, input().split())
				(_, _) = map(int, input().split())
			print('YES')
			return
		tiles.add((tl, tr, bl, br))
	print('NO')
	return
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	can_construct()


for _ in range(int(input())):
	(t, s) = list(map(int, input().split()))
	flag = 1
	for j in range(t):
		(a, b) = list(map(int, input().split()))
		(c, d) = list(map(int, input().split()))
		if b == c:
			flag = 0
	if s % 2 != 0:
		print('NO')
	elif flag == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	f = False
	l = []
	for i in range(n):
		l1 = []
		for i in range(2):
			l2 = [int(i) for i in input().split()]
			l1.append(l2)
		l.append(l1)
	for e in l:
		if e[1][0] == e[0][1]:
			f = True
			break
	if m % 2 == 1:
		f = False
	if f:
		print('YES')
	else:
		print('NO')


t = int(input())

def isdiagonal(tup):
	(ro, col) = tup
	(a1, a2) = ro
	(b1, b2) = col
	if b1 == a2:
		return True
	return False

def findTuple(tu):
	(ro, col) = tu
	(a1, a2) = ro
	(b1, b2) = col
	return ((a1, b1), (a2, b2))
while t:
	t -= 1
	(n, m) = list(map(int, input().split(' ')))
	dic = dict()
	while n:
		n -= 1
		(a1, a2) = list(map(int, input().split(' ')))
		(b1, b2) = list(map(int, input().split(' ')))
		tu = ((a1, a2), (b1, b2))
		dic[tu] = 1
	if m % 2 == 1:
		print('NO')
	else:
		f1 = 0
		f2 = 0
		for i in dic:
			if isdiagonal(i):
				f1 = 1
				break
		for tu in dic:
			ab = findTuple(tu)
			if dic.get(tu) != None:
				f2 = 1
				break
		if f1 and f2:
			print('YES')
		else:
			print('NO')


T_ON = 1
DEBUG_ON = 0
MOD = 998244353

def solve():
	(n, m) = read_ints()
	debug(n, m)
	flag = False
	for i in range(n):
		(a, b) = read_ints()
		(c, d) = read_ints()
		debug(i, a, b)
		debug(i, c, d)
		if b == c:
			flag = True
	if flag and m % 2 == 0:
		YES()
	else:
		NO()

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split()))

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def fib_to_n(n):
	f = []
	(a, b) = (0, 1)
	while a <= n:
		f.append(a)
		(a, b) = (b, a + b)
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def lcm(a, b):
	d = gcd(a, b)
	return a * b // d

def is_even(x):
	return x % 2 == 0

def is_odd(x):
	return x % 2 == 1

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P

def is_lucky(n):
	return set(list(str(n))).issubset({'4', '7'})
main()


from sys import stdin, stdout, setrecursionlimit
import threading

class Tail_Recursion_Optimization:

	def __init__(self, RECURSION_LIMIT, STACK_SIZE):
		setrecursionlimit(RECURSION_LIMIT)
		threading.stack_size(STACK_SIZE)
		return None

class SOLVE:

	def solve(self):
		R = stdin.readline
		W = stdout.write
		ans = []
		for i in range(int(R())):
			(n, m) = [int(x) for x in R().split()]
			cnt = 0
			for j in range(n):
				tmp1 = [int(x) for x in R().split()]
				tmp2 = [int(x) for x in R().split()]
				if tmp1[1] == tmp2[0]:
					cnt += 1
			ans.append(['NO', 'YES'][cnt and (not m % 2)])
		W('\n'.join(ans))
		return 0

def main():
	s = SOLVE()
	s.solve()
main()


num = int(input())
status = []
for i in range(num):
	li = []
	(n, m) = map(int, input().split())
	for j in range(n):
		matrix = [[0, 0], [0, 0]]
		(matrix[0][0], matrix[0][1]) = map(int, input().split())
		(matrix[1][0], matrix[1][1]) = map(int, input().split())
		li.append(matrix)
	if m % 2 == 1:
		status.append('NO')
	else:
		leftstatus = False
		rightstatus = False
		for t in li:
			if t[1][0] == t[0][1]:
				rightstatus = True
		if rightstatus == True:
			status.append('YES')
		else:
			status.append('NO')
for i in status:
	print(i)


def check_board(board_size):
	return board_size % 2 == 0

def check_tile(tile_description):
	return tile_description[0][1] == tile_description[1][0]
num_cases = int(input())
for i in range(num_cases):
	line1 = input()
	(tiles, size) = line1.split()
	tiles = int(tiles)
	size = int(size)
	tile_set = []
	for i in range(tiles):
		ab = input()
		cd = input()
		(a, b) = ab.split()
		(c, d) = cd.split()
		a = int(a)
		b = int(b)
		c = int(c)
		d = int(d)
		tile = [[a, b], [c, d]]
		tile_set.append(tile)
	board_passed = False
	tiles_passed = False
	board_passed = check_board(size)
	for tile in tile_set:
		tiles_passed = tiles_passed or check_tile(tile)
	case_passed = board_passed and tiles_passed
	if case_passed:
		print('YES')
	else:
		print('NO')


def main():
	t = int(input())
	for w in range(t):
		(n, m) = map(int, input().split())
		flag = 0
		for i in range(n):
			(x1, x2) = map(int, input().split())
			(x3, x4) = map(int, input().split())
			if x3 == x2:
				flag = 1
		if m % 2 != 0:
			print('NO')
			continue
		if flag:
			print('YES')
		else:
			print('NO')
main()


t = int(input())
for i in range(0, t):
	(n, m) = map(int, input().strip().split(' '))
	flag = 0
	for i in range(0, n):
		(a, b) = map(int, input().strip().split(' '))
		(c, d) = map(int, input().strip().split(' '))
		if c == b:
			flag = 1
	if flag == 1 and m % 2 == 0:
		print('yes')
	else:
		print('no')


t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	flag = 0
	for j in range(n):
		(a1, a2) = [int(x) for x in input().split()]
		(b1, b2) = [int(x) for x in input().split()]
		if a2 == b1:
			flag = True
	if m % 2 != 0:
		print('NO')
	elif flag:
		print('YES')
	else:
		print('NO')


from math import *
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	f = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c and k % 2 == 0:
			f = 1
	if f == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = []
	check = False
	for i in range(n):
		b = []
		b.append(list(map(int, input().split())))
		b.append(list(map(int, input().split())))
		if b[0][1] == b[1][0]:
			check = True
	if check and m % 2 == 0:
		print('YES')
	else:
		print('NO')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		(n, m) = LI()
		ta = []
		for _ in range(n):
			a = LI()
			b = LI()
			ta.append(a + b)
		f = 0
		for i in range(n):
			ti = ta[i]
			if ti[1] == ti[2]:
				f = 1
				break
		rr.append(YES(m % 2 == 0 and f))
	return JA(rr, '\n')
print(main())


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = []
	for j in range(n):
		l += [list(map(int, input().split())) + list(map(int, input().split()))]
	t = 0
	if m % 2 == 0:
		for i in l:
			if i[1] == i[2]:
				t = 1
	if t == 1:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
input = stdin.readline
print = stdout.write
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	(i, j, k) = (0, 0, 0)
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			k = 1
	if m % 2 == 1:
		print('NO' + '\n')
	elif k == 1:
		print('YES' + '\n')
	else:
		print('NO' + '\n')


from bisect import *
from collections import *
from math import *
from heapq import *
from typing import List
from itertools import *
from operator import *
from functools import *
import sys
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	f1 = f2 = False
	s = set()
	for j in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			f1 = True
		if not f2:
			tmp = 10 ** 6 * a + 10 ** 4 * b + 100 * c + d
			s.add(tmp)
			if 10 ** 6 * a + 10 ** 4 * c + 100 * b + d in s:
				f2 = True
	if m & 1:
		print('NO')
	elif m == 2:
		print('YES' if f1 else 'NO')
	else:
		print('YES' if f1 and f2 else 'NO')


for t in range(int(input())):
	(n, m) = list(map(int, input().split()))
	made = 0
	for i in range(0, n):
		a0 = list(map(int, input().split()))
		a1 = list(map(int, input().split()))
		if a0[1] == a1[0]:
			made = 1
	if m % 2 != 0 or made == 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	symmetric = False
	for i in range(n):
		(a, b) = list(map(int, input().split()))
		(c, d) = list(map(int, input().split()))
		if b == c:
			symmetric = True
	if m % 2 != 0:
		print('NO')
	elif symmetric:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	s = 0
	for x in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			s += 1
	if m & 1:
		print('NO')
		continue
	m >>= 1
	if s > 0:
		print('YES')
	else:
		print('NO')


import math
T = int(input())
while T:
	(n, m) = map(int, input().split())
	f = 0
	while n:
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			f = 1
		n -= 1
	if f == 1 and m % 2 == 0:
		print('YES')
	else:
		print('NO')
	T -= 1


def is_valid(tile):
	return tile[1][0] == tile[0][1]
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	flag = 0
	for i in range(n):
		ls = []
		for j in range(2):
			ls.append(list(map(int, input().split())))
		if is_valid(ls):
			flag = 1
	if m % 2 != 0:
		print('NO')
	elif flag == 1:
		print('YES')
	else:
		print('NO')


for tc in range(int(input())):
	mainFlag = False
	pairFlag = False
	(n, m) = map(int, input().split())
	tiles = set()
	for _ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		tile = (a, b, c, d)
		tiles.add(tile)
		if b == c:
			mainFlag = True
			pairFlag = True
		if (a, c, b, d) in tiles:
			pairFlag = True
	if mainFlag and pairFlag and (m % 2 == 0):
		print('YES')
	else:
		print('NO')


for u in range(int(input())):
	(n, m) = map(int, input().split())
	l = []
	for i in range(2 * n):
		l.append(list(map(int, input().split())))
	if m % 2 == 1:
		print('NO')
	else:
		f = 0
		for i in range(0, 2 * n, 2):
			if l[i][1] == l[i + 1][0]:
				f = 1
				break
		if f == 0:
			print('NO')
		else:
			print('YES')


def transpose(mat, tr, N):
	for i in range(N):
		for j in range(N):
			tr[i][j] = mat[j][i]

def isSymmetric(mat, N):
	tr = [[0 for j in range(len(mat[0]))] for i in range(len(mat))]
	transpose(mat, tr, N)
	for i in range(N):
		for j in range(N):
			if mat[i][j] != tr[i][j]:
				return False
	return True
t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	arr = []
	count = 0
	for j in range(n):
		arr.append(list(map(int, input().split())))
		arr.append(list(map(int, input().split())))
		if isSymmetric(arr, 2):
			arr.clear()
			count += 1
		else:
			arr.clear()
			continue
	if count > 0 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	c1 = 0
	c2 = 0
	for i in range(n):
		o = []
		for j in range(2):
			(k1, k2) = list(map(int, input().split()))
			o.append([k1, k2])
		if o[1][0] == o[0][1]:
			c2 += 1
	if m % 2 != 0:
		print('NO')
	elif c2 >= 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	val = 0
	(n, m) = map(int, input().split())
	for i in range(n):
		l1 = list(map(int, input().split()))
		l2 = list(map(int, input().split()))
		if l1[1] == l2[0]:
			val = 1
	if val == 1 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


from bisect import *
from collections import *
from random import *
from decimal import *
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def st():
	return input().rstrip('\n')

def lis():
	return list(map(int, input().split()))

def ma():
	return map(int, input().split())
t = inp()
while t:
	t -= 1
	(n, x) = ma()
	fl = 0
	s = 'NO'
	for i in range(n):
		(a, b) = ma()
		(a1, b1) = ma()
		if b == a1:
			fl = 1
	if x % 2 == 0 and fl:
		s = 'YES'
	print(s)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	flag = False
	for j in range(n):
		(x1, y1) = map(int, input().split())
		(x2, y2) = map(int, input().split())
		flag |= y1 == x2
	print('NO' if flag == False or m & 1 else 'YES')


n = int(input())
for i in range(n):
	(a, t) = map(int, input().split(' '))
	lel = 0
	for i in range(a):
		(r, l) = map(int, input().split(' '))
		(j, k) = map(int, input().split(' '))
		if l == j:
			lel = lel + 1
	if lel > 0 and t % 2 == 0:
		print('Yes')
	else:
		print('No')


import math
amit = int(input())
for _ in range(amit):
	(n, m) = [int(a) for a in input().strip().split()]
	works = 0
	for _ in range(n):
		top = [int(x) for x in input().strip().split()]
		bot = [int(x) for x in input().strip().split()]
		if top[1] == bot[0]:
			works += 1
	if works >= 1 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	solvable = False
	for _ in range(n):
		f = input().split()[1]
		s = input().split()[0]
		if f == s:
			solvable = True
	if solvable and m % 2 == 0:
		print('YES')
	else:
		print('NO')


import sys
from collections import defaultdict, Counter as CC
from math import sqrt, ceil, floor, log2
INF = float('inf')
MOD = 10 ** 9 + 7
read = lambda : [int(s) for s in sys.stdin.readline().split()]

def solve():
	(n, m) = read()
	all_p = []
	for _i in range(n):
		tmp = []
		for _j in range(2):
			r = tmp.append(read())
		all_p.append(tmp)
	flag = False
	for poss in all_p:
		if poss[0][1] == poss[1][0]:
			flag = True
			break
	if flag and m % 2 == 0:
		print('YES')
	else:
		print('NO')
_ = 1
_ = int(input())
while _:
	solve()
	_ -= 1


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	tiles = []
	for i in range(n):
		tiles.append(list(map(int, input().split())) + list(map(int, input().split())))
	if m % 2 == 1:
		print('NO')
	else:
		possible = False
		for tile in tiles:
			if tile[1] == tile[2]:
				print('YES')
				possible = True
				break
		if not possible:
			print('NO')


t = int(input())
for i in range(t):
	arr = [int(i) for i in input().split()]
	n = arr[0]
	m = arr[1]
	res = False
	for j in range(n):
		arr1 = [int(i) for i in input().split()]
		arr2 = [int(i) for i in input().split()]
		if arr1[1] == arr2[0]:
			res = True
	if m % 2 != 0:
		print('NO')
	elif res:
		print('YES')
	else:
		print('NO')


n = int(input())
for _ in range(n):
	main_flag = True
	(pl, size) = tuple(map(int, input().split()))
	if size % 2 != 0:
		main_flag = False
	flag = False
	for _ in range(pl):
		(t1, t2) = tuple(map(int, input().split()))
		(s1, s2) = tuple(map(int, input().split()))
		if t2 == s1:
			flag = True
	if not flag or not main_flag:
		print('NO')
	else:
		print('YES')


from sys import stdin
for _ in range(int(stdin.readline())):
	(n, m) = list(map(int, stdin.readline().split()))
	res = False
	for _ in range(n):
		(a, b) = list(map(int, stdin.readline().split()))
		(x, y) = list(map(int, stdin.readline().split()))
		if m % 2 == 0 and x == b:
			res = True
	print('YES' if res else 'NO')


for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	printed = 'NO'
	for i in range(n):
		(a, b) = [int(x) for x in input().split()]
		(c, d) = [int(x) for x in input().split()]
		if b == c and m % 2 == 0:
			printed = 'YES'
	print(printed)


t = int(float(input()))
while t:
	(n, m) = map(int, input().split())
	f = 0
	for i in range(n):
		(l1, l2) = map(int, input().split())
		(l3, l4) = map(int, input().split())
		if l2 == l3:
			f = 1
	if m % 2:
		print('NO')
	elif f:
		print('YES')
	else:
		print('NO')
	t -= 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	hasType1 = False
	hasType2 = False
	for i in range(n):
		tile = [list(map(int, input().split())) for i in range(2)]
		isType2 = tile[0][1] == tile[1][0]
		if isType2:
			hasType2 = True
	if m & 1:
		print('NO')
	elif hasType2:
		print('YES')
	else:
		print('NO')


from math import log2
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ok = False
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			ok = True
	if m % 2 == 0 and ok:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(0, t):
	(n, m) = map(int, input().split())
	a = []
	for i in range(0, n):
		sq = [int(inp) for inp in input().split()]
		(x, y) = map(int, input().split())
		sq.append(x)
		sq.append(y)
		a.append(sq)
	if m % 2 == 1:
		print('NO')
		continue
	check = False
	for sq in a:
		if sq[1] == sq[2]:
			check = True
			break
	if check:
		print('YES')
	else:
		print('NO')


T = int(input())
for i in range(T):
	(n, m) = map(int, input().split(' '))
	lst = []
	count = 0
	for j in range(n):
		lst1 = []
		(lt, rt) = map(int, input().split(' '))
		(lb, rb) = map(int, input().split(' '))
		lst1.append(lt)
		lst1.append(rt)
		lst1.append(lb)
		lst1.append(rb)
		lst.append(lst1)
	if m % 2 != 0:
		print('NO')
	else:
		for j in lst:
			if j[1] == j[2]:
				count += 1
				print('YES')
				break
		if count == 0:
			print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	check = False
	for _ in range(n):
		(t_x, t_y) = map(int, input().split())
		(b_x, b_y) = map(int, input().split())
		if t_y == b_x and m % 2 == 0:
			check = True
	if check:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	di = False
	for a in range(n):
		(e1, e2) = map(int, input().split())
		(e3, e4) = map(int, input().split())
		di = di or e2 == e3
	if m % 2 == 1:
		print('NO')
		continue
	if di:
		print('YES')
	else:
		print('NO')


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	b = list()
	t = 0
	for i in range(n):
		(a1, a2) = map(int, input().split())
		(a3, a4) = map(int, input().split())
		b.append((a1, a2, a3, a4))
		if a2 == a3:
			t = 1
	c = 0
	if k % 2 == 1:
		print('NO')
		continue
	for i in range(n):
		for j in range(n):
			if b[i][0] == b[j][3] and b[i][1] == b[j][2] and (b[i][2] == b[j][1]) and (b[i][3] == b[j][0]):
				c = 1
	if k == 2:
		if t == 1:
			print('YES')
		else:
			print('NO')
	elif t == 1:
		print('YES')
	else:
		print('NO')


def ans(a, n, m):
	if m == 2:
		for i in a:
			if i[0][1] == i[1][0]:
				return 'YES'
		return 'NO'
	if m % 2 == 1:
		return 'NO'
	for i in a:
		if i[0][1] == i[1][0]:
			return 'YES'
	return 'NO'
m = int(input())
for j in range(m):
	arr = input().split()
	n = int(arr[0])
	m = int(arr[1])
	a = []
	for i in range(n):
		x1 = input().split()
		x2 = input().split()
		x = []
		y = []
		for k in x1:
			x.append(int(k))
		for k in x2:
			y.append(int(k))
		a.append([x, y])
	print(ans(a, n, m))


t = int(input())
for i in range(t):
	(n, m) = [int(i) for i in input().split()]
	s = 0
	for i in range(n):
		(a, b) = [int(i) for i in input().split()]
		(c, d) = [int(i) for i in input().split()]
		if c == b:
			s = 1
	if m % 2 == 0 and s == 1:
		print('YES')
	else:
		print('NO')


import sys
sys.setrecursionlimit(10000000)
mod = 10 ** 9 + 7
INF = float('inf')
from sys import stdin
readline = stdin.readline

def readInts():
	return list(map(int, readline().split()))

def readTuples():
	return tuple(map(int, readline().split()))

def I():
	return int(readline())
q = I()
for _ in range(q):
	(n, m) = readInts()
	v = False
	lt = []
	rt = []
	ld = []
	rd = []
	nya = False
	for i in range(n):
		for j in range(2):
			if j == 0:
				(leftop, rightop) = readInts()
				lt.append(leftop)
				rt.append(rightop)
			else:
				(leftdown, rightdown) = readInts()
				ld.append(leftdown)
				rd.append(rightdown)
		if rightop == leftdown:
			v = True
		if leftop == rightdown and rightop == leftdown:
			nya = True
	ok = False
	for i in range(n):
		for j in range(n):
			if lt[i] == lt[j] and rt[i] == ld[j] and (ld[i] == rt[j]) and (rd[i] == rd[j]):
				ok = True
				break
	if m % 2:
		print('NO')
	elif ok and v:
		print('YES')
	else:
		print('NO')


def tiles(n, m, ele):
	if m % 2 != 0 or m < 2:
		return 'NO'
	for i in range(len(ele)):
		if ele[i][1] == ele[i][2]:
			return 'YES'
	return 'NO'
n = int(input())
res = []
for i in range(n):
	num = list(map(int, input().split()))
	tmp = []
	arr = []
	for i in range(2 * num[0]):
		tmp += list(map(int, input().split()))
		if i % 2 != 0:
			arr.append(tmp)
			tmp = []
	res.append(tiles(num[0], num[1], arr))
for j in res:
	print(j)


import math
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	flag = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, a) = map(int, input().split())
		if b == c:
			flag = 1
	if m & 1:
		print('NO')
	elif flag == 1:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	c = False
	for j in range(n):
		(a, b) = map(int, input().split())
		(x, y) = map(int, input().split())
		if b == x:
			c = True
	if m % 2 != 0:
		print('NO')
	elif c:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	board = [[list(map(int, input().split())), list(map(int, input().split()))] for _ in range(n)]
	if m % 2 == 1:
		print('NO')
		continue
	for i in range(n):
		(a11, a12) = board[i][0]
		(a21, a22) = board[i][1]
		if a12 == a21:
			print('YES')
			break
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = (int(x) for x in input().split())
	skip = False
	for __ in range(n):
		(a1, a2) = (int(x) for x in input().split())
		(b1, b2) = (int(x) for x in input().split())
		if m % 2 != 0 and skip != True:
			print('NO')
			skip = True
		if b1 == a2 and skip != True:
			print('YES')
			skip = True
	else:
		if skip != True:
			print('NO')


import sys
import math
from collections import defaultdict, deque
input = sys.stdin.readline

def inar():
	return [int(el) for el in input().split()]

def main():
	t = int(input())
	for _ in range(t):
		(n, m) = inar()
		check = False
		for i in range(n):
			(x1, x2) = inar()
			(x3, x4) = inar()
			if x3 == x2:
				check = True
		if m % 2 == 0 and check:
			print('YES')
		else:
			print('NO')
main()


from sys import stdin, stdout
input = stdin.buffer.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	f = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			f = 1
	if f and m & 1 == 0:
		print('YES')
	else:
		print('NO')


testcases = int(input())
for testcase in range(testcases):
	temparr = input()
	temparr = temparr.split()
	n = int(temparr[0])
	m = int(temparr[1])
	arr = []
	sym = 0
	for line in range(n):
		grid = []
		temparr = input()
		temparr = temparr.split()
		grid.append(int(temparr[0]))
		grid.append(int(temparr[1]))
		temparr = input()
		temparr = temparr.split()
		grid.append(int(temparr[0]))
		grid.append(int(temparr[1]))
		arr.append(grid[:])
		if grid[0] == grid[3] and grid[1] == grid[2]:
			sym = 1
		elif grid[1] == grid[2]:
			sym = 1
	if m & 1:
		print('NO')
	elif sym:
		print('YES')
	else:
		print('NO')


T = int(input())

def sym(tile):
	if tile[0][1] == tile[1][0]:
		return True
	return False

def mate(tile):
	return [tile[0][0], tile[1][0], tile[0][1], tile[1][1]]
for t in range(T):
	(n, m) = [int(x) for x in input().strip().split()]
	tiles = []
	for j in range(n):
		nt = []
		nt.append([int(x) for x in input().strip().split()])
		nt.append([int(x) for x in input().strip().split()])
		tiles.append(nt)
	if m % 2 != 0:
		print('NO')
		continue
	symflag = False
	for tile in tiles:
		if sym(tile):
			symflag = True
			break
	if symflag:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	(n, m) = map(int, input().split())
	mat = []
	poss = False
	for _ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			poss = True
	if poss and m % 2 == 0:
		print('YES')
	else:
		print('NO')
	t -= 1


from sys import stdin
n = int(stdin.readline())
for case in range(n):
	(n, m) = map(int, stdin.readline().split())
	flag1 = False
	if m % 2 == 1:
		print('NO')
		for i in range(2 * n):
			stdin.readline()
		continue
	for tile in range(n):
		temp = [list(map(int, stdin.readline().split())), list(map(int, stdin.readline().split()))]
		if temp[0][1] == temp[1][0]:
			flag1 = True
	if flag1:
		print('YES')
	else:
		print('NO')


import sys
import math
T = int(input())
res = []
userIn = []
for i in range(T):
	(n, x) = input().split()
	n = int(n)
	x = int(x)
	matrices = []
	for i0 in range(int(n)):
		(tL, tR) = input().split()
		(bL, bR) = input().split()
		matrices.append([tL, tR, bL, bR])
	if x % 2 != 0:
		res.append('NO')
	elif x % 2 == 0:
		verdict = False
		for i in range(len(matrices)):
			tL = int(matrices[i][0])
			tR = int(matrices[i][1])
			bL = int(matrices[i][2])
			bR = int(matrices[i][3])
			if tR == bL:
				verdict = True
				break
		if verdict == True:
			res.append('YES')
		elif verdict == False:
			res.append('NO')
for i in res:
	print(i)


t = int(input())
for i in range(t):
	flag = False
	(n, m) = map(int, input().split())
	for j in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		flag = c == b or flag
	if m % 2:
		print('NO')
	elif flag:
		print('YES')
	else:
		print('NO')


import math

def good(l):
	if l[0][1] == l[1][0]:
		return True
	else:
		return False
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	d = []
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, e) = map(int, input().split())
		d.append([[a, b], [c, e]])
	if m % 2 != 0:
		print('NO')
	else:
		f = 1
		for j in range(n):
			if good(d[j]):
				f = 0
				break
		if f == 0:
			print('YES')
		else:
			print('NO')


import sys

def solve(x):
	print(x)
	return x
IN = [x.strip() for x in sys.stdin.readlines()]
T = int(IN[0])
cur = 1
for ti in range(T):
	(n, m) = [int(x) for x in IN[cur].split(' ')]
	cur += 1
	tiles = []
	for i in range(n):
		l1 = [int(x) for x in IN[cur + 0].split(' ')]
		l1.extend([int(x) for x in IN[cur + 1].split(' ')])
		cur += 2
		tiles.append(l1)
	if m % 2 == 1:
		cando = False
	else:
		cando = sum([1 if t[1] == t[2] else 0 for t in tiles]) > 0
	print('YES' if cando else 'NO')


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)
for xyz in range(0, int(input())):
	(n, m) = map(int, input().split())
	f = False
	if m % 2 == 1:
		print('NO')
		for i in range(0, n):
			a = list(map(int, input().split()))
			b = list(map(int, input().split()))
	else:
		ans = False
		for i in range(0, n):
			a = list(map(int, input().split()))
			b = list(map(int, input().split()))
			if a[1] == b[0]:
				ans = True
		if ans:
			print('YES')
		else:
			print('NO')


import sys, math
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))

def chk(i, j):
	if mat[i][0][0] == mat[j][0][0] and mat[i][1][1] == mat[j][1][1]:
		if mat[i][0][1] == mat[j][1][0] and mat[i][1][0] == mat[j][0][1]:
			return True
	return False
for _ in range(inp()):
	(n, m) = inpl()
	mat = []
	f = False
	for i in range(n):
		(a, b) = inpl()
		(c, d) = inpl()
		if b == c:
			f = True
		mat.append([[a, b], [c, d]])
	if not f or m % 2:
		print('NO')
		continue
	f = False
	for i in range(n):
		for j in range(n):
			if chk(i, j):
				f = True
	print('YES' if f else 'NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	count = 0
	for _ in range(n):
		(a, b) = list(map(int, input().split()))
		(c, d) = list(map(int, input().split()))
		if c == b:
			count += 1
	if m % 2 != 0 or count == 0:
		print('NO')
	elif count > 0:
		print('YES')


for i in range(int(input())):
	x = 0
	k = 0
	(n, m) = map(int, input().split())
	if m % 2 != 0:
		x = 1
	for j in range(n):
		a = int(input().split()[-1])
		b = int(input().split()[0])
		if a == b:
			k = 1
	if k == 1 and x == 0:
		print('YES')
	else:
		print('NO')


import sys
t = int(input().strip())
for a0 in range(t):
	l = [int(i) for i in input().split()]
	n = l[0]
	m = l[1]
	odd = 0
	if m % 2 != 0:
		odd = 1
	symm = 0
	for i in range(n):
		l1 = [int(i) for i in input().split()]
		l2 = [int(i) for i in input().split()]
		if l1[1] == l2[0]:
			symm = 1
	if odd == 1 or symm == 0:
		print('NO')
	else:
		print('YES')


import os, sys
from io import IOBase, BytesIO
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def solve():
	t = int(input())
	for _ in range(t):
		(n, m) = map(int, input().split())
		res = False
		for _ in range(n):
			(a, b) = map(int, input().split())
			(c, d) = map(int, input().split())
			if c == b:
				res = True
		if m % 2 == 1:
			cout << 'NO' << endl
		elif res:
			cout << 'YES' << endl
		else:
			cout << 'NO' << endl

def main():
	solve()
main()


for nt in range(int(input())):
	(n, m) = map(int, input().split())
	tiles = []
	ans = 'NO'
	for i in range(n):
		a = []
		a.append(list(map(int, input().split())))
		a.append(list(map(int, input().split())))
		tiles.append(a)
		if a[0][1] == a[1][0]:
			ans = 'YES'
	if m % 2:
		print('NO')
		continue
	print(ans)


n1 = int(input())
for _ in range(n1):
	n2 = input()
	(n, m) = (int(n2.split()[0]), int(n2.split()[1]))
	l = [0] * n
	for i in range(n):
		i1 = input()
		i2 = input()
		l[i] = [int(item) for item in i1.split()]
		l[i].append(int(i2.split()[0]))
		l[i].append(int(i2.split()[1]))
	if m % 2 != 0:
		print('NO')
		continue
	c = 0
	for item in l:
		if item[1] == item[2]:
			c += 1
			break
	if c == 0:
		print('NO')
	else:
		print('YES')


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	t = int(input())
	for i in range(t):
		(n, m) = map(int, input().split())
		matrix = []
		for j in range(n):
			temp = [0] * 4
			(a, b) = map(int, input().split())
			(c, d) = map(int, input().split())
			(temp[0], temp[1], temp[2], temp[3]) = (a, b, c, d)
			matrix.append(temp)
		if m % 2 == 1:
			print('NO')
			continue
		f = False
		cnt = 0
		for ma in matrix:
			if ma[1] == ma[2]:
				f = True
				break
		if f:
			print('YES')
		else:
			print('NO')
main()


for tt in range(int(input())):
	(N, X) = map(int, input().split())
	ans = False
	for _ in range(N):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			ans = True
	if X & 1:
		print('NO')
	elif ans:
		print('YES')
	else:
		print('NO')


n = int(input())
while n:
	l1 = [int(i) for i in input().split()]
	l2 = []
	for i in range(l1[0]):
		l3 = [int(ii) for ii in input().split()]
		l4 = [int(ii) for ii in input().split()]
		l3.extend(l4)
		l2.append(l3)
	flag = 1
	if l1[1] % 2 == 0:
		for l in l2:
			if l[1] == l[2]:
				flag = 1
				break
			else:
				flag = 0
				continue
		if flag == 0:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')
	n -= 1


def solve():
	(n, m) = map(int, input().split())
	ans = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			ans = 1
	if m % 2 == 0 and ans == 1:
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(t):
	solve()


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	lst = []
	for i in range(n):
		temp = [default] * m
		lst.append(temp)
	return lst

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

def solve(n, m, lst):
	if m % 2:
		return 'NO'
	for i in lst:
		if i[1] == i[2]:
			return 'YES'
	return 'NO'
for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	lst = []
	for i in range(n):
		temp = []
		for j in range(2):
			(a, b) = list(map(int, input().split()))
			temp.append(a)
			temp.append(b)
		lst.append(temp)
	print(solve(n, m, lst))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list()
	for _ in range(2 * n):
		l.append(list(map(int, input().split())))
	ans = 'NO'
	if m % 2 == 0:
		for i in range(0, 2 * n, 2):
			if l[i][1] == l[i + 1][0]:
				ans = 'YES'
				break
	print(ans)


for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = [0] * n
	f = 0
	for i in range(n):
		(x, y) = map(int, input().split())
		(w, z) = map(int, input().split())
		if y == w:
			a[i] = 1
	if m % 2 != 0:
		print('NO')
	else:
		for i in range(n):
			if a[i] == 1:
				print('YES')
				f = 1
				break
		if f == 0:
			print('NO')


for i in range(int(input())):
	(n, m) = [int(i) for i in input().split()]
	tiles = []
	cnt = 0
	prev = 0
	flag = 0
	for k in range(2 * n):
		curr = [int(i) for i in input().split()]
		if not prev:
			prev = curr
		else:
			if curr[0] == prev[-1]:
				flag = 1
			prev = 0
	if flag and m % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
i = 0
while i < t:
	a = input().split(' ')
	n = int(a[0])
	m = int(a[1])
	j = 0
	b = []
	while j < n * 2:
		c = input().split(' ')
		b.append(int(c[0]))
		b.append(int(c[1]))
		j += 1
	if m % 2 != 0:
		print('NO')
	else:
		k = 0
		diag1 = False
		while k < n * 4:
			if b[k + 1] == b[k + 2]:
				diag1 = True
				print('YES')
				k = n * 4
			k += 4
		if not diag1:
			print('NO')
	i += 1


import sys
input = sys.stdin.readline
n = int(input())
while n > 0:
	(k, m) = input().split()
	ans = 0
	for i in range(int(k)):
		(a, b) = input().split()
		(c, d) = input().split()
		if b == c:
			ans = 1
	if ans and int(m) % 2 == 0:
		print('YES')
	else:
		print('NO')
	n = n - 1


import math
import sys

class Graph:

	def __init__(self, Nodes, is_directed=False):
		self.nodes = Nodes
		self.adj_list = {}
		self.is_directed = is_directed
		for node in self.nodes:
			self.adj_list[node] = []

	def add_edge(self, u, v):
		self.adj_list[u].append(v)
		if self.is_directed == False:
			self.adj_list[v].append(u)

	def print_graph(self):
		for node in self.nodes:
			print(node, '->', self.adj_list[node])

	def degree_node(self, node):
		return len(self.adj_list[node])

	def dfsUTIL(self, v, visited, parents=[]):
		visited[v] = True
		for i in self.adj_list[v]:
			if visited[i] == False:
				self.dfsUTIL(i, visited, parents)
				parents.append(i)

	def dfs(self, v):
		visited = [False] * (max(self.adj_list) + 1)
		parents = [v]
		self.dfsUTIL(v, visited, parents)
		return len(parents)

def dict_sort(ans):
	ans = sorted(ans.items(), reverse=True, key=lambda kv: kv[1])

def is_prime(n):
	if n == 1:
		return 0
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def seive_primes(n):
	flag = [0] * (n + 10)
	flag[1] = flag[0] = 1
	i = 2
	while i * i <= n + 1:
		if flag[i] == 0:
			j = i * i
			while j <= n + 1:
				flag[j] = 1
				j += i
		i += 1
	return flag

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def alphabates():
	return 'abcdefghijklmnopqrstuvwxyz'

def binary_search(ls, n, flag):
	low = 0
	hi = n - 1
	while low <= hi:
		mid = (low + hi) // 2
		if ls[mid] == flag:
			return mid
		elif ls[mid] > flag:
			hi = mid - 1
		else:
			low = mid + 1
	return -1

def qdrt(x, a, b, c):
	return a * x * x + b * x + c

def inp():
	ls = list(map(int, input().split()))
	return ls

def mult_inp():
	return map(int, input().split())
t = int(input())
for _ in range(t):
	(n, m) = mult_inp()
	ans = 'NO'
	_2 = 'NO'
	for i in range(n):
		(a1, b1) = mult_inp()
		(a2, b2) = mult_inp()
		if a2 == b1:
			ans = 'YES'
		if a1 == b1 == a2 == b2 or (a1 == b2 and a2 == b1) or a2 == b1:
			_2 = 'YES'
	if m % 2 == 1:
		print('NO')
		continue
	if m == 2:
		print(_2)
		continue
	print(ans)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(beauty, s, n, count):
	pass

def sortSecond(val):
	return val[1]
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
alphs = 'abcdefghijklmnopqrstuvwxyz'
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect
import functools as fnt

def solve():
	(n, m) = read()
	f = 0
	for i in range(n):
		(x, y) = read()
		(z, w) = read()
		if y == z:
			f = 1
	if m & 1:
		print('NO')
	elif f == 1:
		print('YES')
	else:
		print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = scanner()
for i in range(t):
	solve()


t = int(input())
w = []
for i in range(t):
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	boo = False
	bo = False
	for g in range(n):
		(a, b) = input().split()
		a = int(a)
		b = int(b)
		(c, d) = input().split()
		c = int(c)
		d = int(d)
		if b == c:
			bo = True
	if m % 2 == 0:
		boo = True
	if bo and boo:
		w.append('YES')
	else:
		w.append('NO')
for i in w:
	print(i)


import os
import sys
from io import BytesIO, IOBase
import math

def main1():
	for _ in range(int(input())):
		(n, x) = map(int, input().split())
		if n <= 2:
			print(1)
		else:
			n -= 2
			print(1 + math.ceil(n / x))

def main2():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		flag = 0
		for i in range(n):
			mat = []
			for j in range(2):
				mat.append(list(map(int, input().split())))
			if mat[0][1] == mat[1][0]:
				flag = 1
		if m % 2 or flag == 0:
			print('NO')
		else:
			print('YES')

def main3():
	for _ in range(int(input())):
		n = int(input())
		ans = float('inf')
		for i in range(1, math.floor(math.sqrt(n)) + 1):
			ans = min(ans, i - 1 + (n - i + i - 1) // i)
		print(ans)

def main4():
	n = int(input())
	a = list(map(int, input().split()))
	ls = [0] * n
	ls[0] = a[0]
	for i in range(1, n):
		ls[i] = ls[i - 1] + a[i]
	ans = 0
	d = dict()
	d[0] = 0
	d[ls[0]] = 0
	prev_pos = 0
	for i in range(1, n):
		if ls[i] in d:
			pos = d[ls[i]] + 1
			if pos >= prev_pos:
				prev_pos = i
				ans += 1
		d[ls[i]] = i
	print(ans)

def main5():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	max_win = min(a[0], b[1]) + min(a[1], b[2]) + min(a[2], b[0])
	min_win = max(0, a[0] - b[0] - b[2]) + max(0, a[1] - b[1] - b[0]) + max(0, a[2] - b[2] - b[1])
	print(min_win, max_win)

def main6():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main2()


from collections import defaultdict, Counter
import copy, math
from copy import deepcopy
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	cc = 0
	for __ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			cc = 1
	if cc == 1 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = [int(_) for _ in input().split()]
	X = []
	for _ in range(n):
		(a, b) = [int(_) for _ in input().split()]
		(c, d) = [int(_) for _ in input().split()]
		X.append([a, b, c, d])
	if m % 2 == 0:
		for _ in X:
			if _[1] == _[2]:
				print('YES')
				break
		else:
			print('NO')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	NO = True
	(N, M) = list(map(int, input().split()))
	for n in range(N):
		(a, b) = list(map(int, input().split()))
		(c, d) = list(map(int, input().split()))
		if b == c:
			NO = False
	if M % 2 != 0:
		NO = True
	if NO:
		print('NO')
	else:
		print('YES')


def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
n = inp()
for _ in range(n):
	l = inlt()
	m = l[0]
	z = l[1]
	flag = 1
	for i in range(m):
		grid = []
		l1 = inlt()
		l2 = inlt()
		grid.append(l1)
		grid.append(l2)
		if grid[0][1] == grid[1][0]:
			flag = 0
	if z % 2 == 1:
		flag = 1
	if flag:
		print('NO')
	else:
		print('YES')


def main():
	caseNum = int(input())
	for _ in range(caseNum):
		(n, m) = list(map(int, input().split(' ')))
		matrix = []
		for _ in range(n):
			tmp = []
			for _ in range(2):
				tmp.append(list(map(int, input().split(' '))))
			matrix.append(tmp)
		if m % 2 == 1:
			print('NO')
		elif isSymmetrical(matrix):
			print('YES')
		else:
			print('NO')

def isSymmetrical(matrix):
	for elem in matrix:
		if elem[0][1] == elem[1][0]:
			return True
	return False
main()


t = int(input())
while t > 0:
	t -= 1
	l = []
	flag = 0
	k = 1
	(n, m) = map(int, input().split())
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if flag == 0 and k == 1 and (b == c):
			flag = 1
			k += 1
	if m % 2 == 0 and flag == 1:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	l = list(map(int, input().split()))
	result = 'NO'
	for j in range(l[0]):
		f = list(map(int, input().split()))
		s = list(map(int, input().split()))
		if f[1] == s[0] and l[1] % 2 == 0:
			result = 'YES'
	print(result)


t = int(input())
for i in range(t):
	(n, m) = [int(j) for j in input().split()]
	flag = 0
	for j in range(n):
		(x, y) = [int(k) for k in input().split()]
		(a, b) = [int(k) for k in input().split()]
		if y == a:
			flag = 1
	if m * m % 4 != 0:
		print('NO')
		continue
	if flag == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	flag = 0
	for row in range(n):
		top = [int(i) for i in input().split()]
		bottom = [int(i) for i in input().split()]
		if flag == 1:
			pass
		elif top[1] == bottom[0]:
			flag = 1
	print('NO' if flag == 0 or m % 2 == 1 else 'YES')


def check(arr):
	return arr[0][1] == arr[1][0]

def diagr(arr):
	return arr[1][1] == arr[0][0]

def diagl(arr):
	return arr[0][1] == arr[1][0]
T = int(input())
while T:
	(n, t) = map(int, input().split())
	arr = []
	for i in range(n):
		temp = []
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		temp.append(a)
		temp.append(b)
		arr.append(temp)
	if t % 2 != 0:
		print('NO')
		T -= 1
		continue
	flag = False
	for x in arr:
		if check(x):
			flag = True
	if flag:
		print('YES')
	else:
		print('NO')
	T -= 1


t = int(input())
i = 0
while i < t:
	(n, m) = map(int, input().split())
	arr = []
	ans = 'NO'
	for times in range(2 * n):
		arr.append(list(map(int, input().split())))
	if m % 2 == 0:
		for p in range(0, len(arr) - 1, 2):
			index1 = arr[p][1]
			index2 = arr[p + 1][0]
			if index1 == index2:
				ans = 'YES'
				break
	else:
		ans = 'NO'
	print(ans)
	i += 1


def solve():
	(n, m) = map(int, input().split())
	ans = False
	for _ in range(n):
		first = [int(a) for a in input().split()]
		second = [int(a) for a in input().split()]
		if first[1] == second[0]:
			ans = True
	if ans and m % 2 == 0:
		print('YES')
	else:
		print('NO')
t = int(input())
while t:
	solve()
	t -= 1


import sys
t = int(input())
for tc in range(t):
	(n, m) = map(int, input().split())
	flag = m & 1 == 1
	for i in range(n):
		(a, b) = map(int, input().split())
		(x, y) = map(int, input().split())
		if not flag and b == x:
			flag = True
	if m & 1 == 1 or flag is False:
		print('no')
	else:
		print('yes')


symmetric = lambda m: not max([m[i][j] != m[j][i] for i in range(len(m)) for j in range(len(m))])
for _ in range(int(input())):
	(n, m) = (*map(int, input().split()),)
	tiles = []
	for _ in range(n):
		tiles.append([list(map(int, input().split())), list(map(int, input().split()))])
	if m < 2 or m % 2 != 0:
		print('NO')
	else:
		print('YES' if max(map(symmetric, tiles)) else 'NO')


import math
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	flag = 0
	for i in range(n):
		(x, y) = map(int, input().split())
		(z, w) = map(int, input().split())
		if x == y == z == w or y == z:
			flag = 1
	if m % 2 != 0:
		print('NO')
	elif flag == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = []
	for i in range(n):
		(b, c) = map(int, input().split())
		(d, e) = map(int, input().split())
		a += [[b, c, d, e]]
	if m % 2 != 0:
		print('NO')
	else:
		flag = False
		for j in range(n):
			if a[j][1] == a[j][2]:
				flag = True
		if flag:
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	var = 0
	for j in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			var = 1
	if m % 2 == 1:
		print('NO')
	elif var == 0:
		print('NO')
	elif var == 1:
		print('YES')


def test():
	t = int(input())
	for i in range(t):
		(n, m) = input().split()
		(n, m) = (int(n), int(m))
		bal = []
		for j in range(n):
			ac = []
			ac.append(input().split())
			ac.append(input().split())
			bal.append(ac)
		if m % 2 == 1:
			print('NO')
			continue
		bals1 = False
		bals2 = False
		for j in bal:
			if j[0][1] == j[1][0]:
				bals1 = True
				if j[1][1] == j[0][0]:
					bals2 = True
		if bals1 or bals2:
			print('YES')
		else:
			print('NO')
test()


def main():
	(n, m) = map(int, input().split())
	ans = False
	for _ in range(n):
		(_, b) = map(int, input().split())
		(c, _) = map(int, input().split())
		if b == c:
			ans = True
	res = ['NO', 'YES']
	if m % 2:
		ans = False
	print(res[ans])
tn = int(input())
for _ in range(tn):
	main()


def tile_type(row1, row2):
	if row1[1] == row2[0]:
		return True
	else:
		return False
t = int(input())
for _ in range(t):
	(n, m) = tuple(map(int, input().split()))
	tiles = [None] * n
	for i in range(n):
		tiles[i] = tile_type(list(map(int, input().split())), list(map(int, input().split())))
	if m % 2 == 1:
		print('NO')
	elif any(tiles):
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	l2 = []
	l3 = []
	count = 0
	for i in range(2 * n):
		l = [int(x) for x in input().split()]
		l2.append(l)
	l4 = []
	for i in l2:
		if count == 2:
			l3.append(l4)
			l4 = []
			l4.append(i)
			count = 1
		else:
			count += 1
			l4.append(i)
	l3.append(l4)
	if m % 2 != 0:
		print('NO')
	elif n == 1:
		if l3[0][0][1] == l3[0][1][0]:
			print('YES')
		else:
			print('NO')
	else:
		fncount = 0
		pcount = 0
		for i in l3:
			if i[0][1] == i[1][0]:
				ncount = 1
			else:
				ncount = 0
			if ncount == 0:
				fncount += 0
			else:
				fncount += 1
		if fncount > 0:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	a = list(map(int, input().split()))
	tile = []
	flag = 1
	for z in range(2 * a[0]):
		tile.append(list(map(int, input().split())))
	if a[1] % 2 == 0:
		for i in range(0, 2 * a[0], 2):
			if tile[i][1] == tile[i + 1][0]:
				print('YES')
				flag = 0
				break
		if flag:
			print('NO')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	da = 'NO'
	for i in range(n):
		(x11, x12) = map(int, input().split())
		(x21, x22) = map(int, input().split())
		if x12 == x21:
			da = 'YES'
	if m % 2 == 0:
		print(da)
	else:
		print('NO')


for _ in range(int(input())):
	l = []
	ans = 0
	(n, m) = map(int, input().split())
	for x in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		p = [a, b, c, d]
		l.append(p)
	if m % 2 == 0:
		for num in l:
			if num[1] == num[2]:
				print('YES')
				break
		else:
			print('NO')
	else:
		print('NO')


def matrix(n, m, t):
	if m % 2 == 1:
		return 'NO'
	if t == True:
		return 'YES'
	else:
		return 'NO'
test = int(input())
for i in range(test):
	(n, m) = map(int, input().split())
	t = 0
	for j in range(n):
		al = list(map(int, input().split()))
		gl = list(map(int, input().split()))
		if al[1] == gl[0]:
			t = True
	print(matrix(n, m, t))


def makeSq(n, m, tiles):

	def isSym(tile):
		if tile[0][1] == tile[1][0]:
			return True
		return False
	if m % 2 == 1:
		return 'NO'
	for tile in tiles:
		if isSym(tile):
			return 'YES'
	return 'NO'
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	tiles = []
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		tiles.append([[a, b], [c, d]])
	print(makeSq(n, m, tiles))


t = int(input())
for i in range(t):
	st = input().split()
	(n, m) = (int(st[0]), int(st[1]))
	second = False
	for j in range(n):
		arr = []
		arr.append(input().split())
		arr.append(input().split())
		if arr[1][0] == arr[0][1]:
			second = True
	if second and m % 2 == 0:
		print('YES')
	else:
		print('NO')


import math
import sys
import itertools
import fractions
wtf = sys.stdin.read()
wtf = wtf.strip().split('\n')
t = int(wtf[0])
j = 1
for i in range(t):
	(n, m) = map(int, wtf[j].split())
	j += 1
	ta = 0
	tb = 0
	for i in range(n):
		s1 = list(map(int, wtf[j].split()))
		s2 = list(map(int, wtf[j + 1].split()))
		j += 2
		if s2[0] == s1[1]:
			tb += 1
			if s1[0] == s2[1]:
				ta += 1
	print('YES' if m % 2 == 0 and m > 1 and (tb > 0) or (m == 1 and ta > 1) else 'NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = []
	b = []
	l = 0
	for i in range(2 * n):
		if i % 2 == 0:
			a.append(list(map(int, input().split())))
		else:
			b.append(list(map(int, input().split())))
	if m % 2 != 0:
		print('NO')
	else:
		for i in range(n):
			if a[i][1] == b[i][0]:
				l = 1
		if l:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	arr = []
	(n, m) = map(int, input().split())
	for j in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			k = [[a, b], [c, d]]
			arr.append(k)
	if m % 2 or not arr:
		print('NO')
		continue
	else:
		print('YES')


for T in range(int(input())):
	(n, m) = map(int, input().split())
	sem = 0
	a = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		a.append([x, y])
	for i in range(0, 2 * n, 2):
		if a[i][1] == a[i + 1][0]:
			sem = 1
			break
	if m & 1:
		print('NO')
	elif sem:
		print('YES')
	else:
		print('NO')


import sys
import itertools as it
import math as mt
import collections as cc
I = lambda : list(map(int, input().split()))
S = lambda : list(input().split())
for tc in range(int(input())):
	(n, m) = I()
	ar = []
	for i in range(n):
		a = I()
		b = I()
		aa = [a, b]
		ar.append(aa)
	flag = 0
	for i in ar:
		if i[0][1] == i[1][0]:
			flag = 1
			break
	if m % 2 == 1:
		print('NO')
	elif flag == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	flag = 0
	ans = 0
	(a, b) = [int(i) for i in input().split()]
	if b % 2 != 0:
		flag = 1
	for j in range(a):
		(c, d) = [int(i) for i in input().split()]
		(e, f) = [int(i) for i in input().split()]
		if d == e:
			ans = 'YES'
	if ans == 'YES' and flag == 0:
		print(ans)
	else:
		print('NO')


from sys import stdin, stdout
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	f = 0
	for _ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			f = 1
	if m % 2 != 0:
		print('NO')
	elif f == 1:
		print('YES')
	else:
		print('NO')


def check(arr):
	flag = False
	if arr[0][1] == arr[1][0]:
		flag = True
	return flag
for _ in range(int(input())):
	(n, t) = input().split()
	(n, t) = (int(n), int(t))
	arr = []
	for i in range(n):
		arr.append([])
		(a, b) = input().split()
		a = int(a)
		b = int(b)
		arr[i].append([a, b])
		(a, b) = input().split()
		a = int(a)
		b = int(b)
		arr[i].append([a, b])
	if t % 2 != 0:
		print('NO')
	else:
		flag = False
		for i in arr:
			if check(i):
				flag = True
				break
		if flag:
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	tiles = []
	for tile in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		tiles.append([[a, b], [c, d]])
	symTileFound = False
	for tile in tiles:
		if tile[0][1] == tile[1][0]:
			symTileFound = True
			break
	if symTileFound and m % 2 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	f = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		x = [a, b, c, d]
		if len(set(x)) == 1:
			f += 1
		elif a != d and b == c:
			f += 1
		elif a == d and b == c:
			f += 1
	if m % 2 == 1:
		print('NO')
	elif f >= 1:
		print('YES')
	else:
		print('NO')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for j in range(int(input())):
	(n, m) = map(int, input().split())
	found = False
	setty = set([])
	for s in range(n):
		row1 = tuple(map(int, input().split()))
		row2 = tuple(map(int, input().split()))
		setty.add((row1, row2))
		if row1[1] == row2[0]:
			found = True
	if m % 2 == 1:
		print('NO')
	elif found == False:
		print('NO')
	else:
		found2 = False
		for s in setty:
			srow1 = s[0]
			srow2 = s[1]
			trans = ((srow1[0], srow2[0]), (srow1[1], srow2[1]))
			if trans in setty:
				found2 = True
				break
		if found2 == True:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	sym = 'NO'
	for i in range(n):
		tile = [[0, 0], [0, 0]]
		(tile[0][0], tile[0][1]) = map(int, input().split())
		(tile[1][0], tile[1][1]) = map(int, input().split())
		if tile[0][1] == tile[1][0] and m % 2 == 0:
			sym = 'YES'
	print(sym)


import sys
import os
from math import sqrt, log, log2, log10, gcd, floor, pow, sin, cos, tan, pi, inf, factorial, ceil
from copy import copy, deepcopy
import bisect
from sys import exit, stdin, stdout
from collections import Counter, defaultdict, deque
from itertools import permutations
import heapq
mod = 1000000007
iinp = lambda : int(sys.stdin.readline())
inp = lambda : sys.stdin.readline().strip()
strl = lambda : list(inp().strip().split(' '))
intl = lambda : list(map(int, inp().split(' ')))
flol = lambda : list(map(float, inp().split(' ')))
flush = lambda : stdout.flush()
mint = lambda : map(int, inp().split())

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	p = int(sqrt(n))
	for i in range(5, p + 1, 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def solve():
	(n, m) = mint()
	arr = []
	for i in range(n):
		a = intl()
		b = intl()
		a.extend(b)
		arr.append(a)
	if m % 2 == 1:
		print('NO')
	else:
		flag1 = 0
		flag2 = 0
		flag = 0
		for i in range(n):
			if arr[i][1] == arr[i][2]:
				flag = 1
		if flag == 1:
			print('YES')
		else:
			print('NO')
for _ in range(iinp()):
	solve()


def sym_2(s):
	return s[0][1] == s[1][0]

def as_2(s, t):
	return s[0][0] == t[0][0] and s[1][1] == t[1][1] and (s[1][0] == t[0][1]) and (s[0][1] == t[1][0])
t = int(input())
for case in range(t):
	(n, m) = [int(x) for x in input().split(' ')]
	M = []
	for i in range(n):
		v = []
		for j in range(2):
			v.append([int(x) for x in input().split(' ')])
		M.append(v)
	if m % 2 == 1:
		ans = 'NO'
	else:
		sym = False
		asym = False
		for x in M:
			if sym and asym:
				break
			elif sym_2(x):
				sym = True
			for y in M:
				if asym:
					break
				elif as_2(x, y):
					asym = True
		if sym and asym:
			ans = 'YES'
		else:
			ans = 'NO'
	print(ans)


def can_build(m, tiles):
	if m % 2 == 1 or m <= 1:
		return 'NO'
	for tile in tiles:
		if tile[0][1] == tile[1][0]:
			return 'YES'
	return 'NO'
t = int(input())
for i in range(t):
	inpt = list(map(int, input().split(' ')))
	n = inpt[0]
	m = inpt[1]
	tiles = []
	for j in range(n):
		a = list(map(int, input().split(' ')))
		b = list(map(int, input().split(' ')))
		tiles.append([a, b])
	print(can_build(m, tiles))


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	isSymmetric = False
	flag = 1
	for i in range(n * 2):
		(a, b) = map(int, input().split())
		if flag % 2 != 0:
			tocheck = b
		elif a == tocheck:
			isSymmetric = True
		flag += 1
	if m % 2 == 0 and isSymmetric:
		print('YES')
	else:
		print('NO')


t = int(input())
l = []
while t:
	l = []
	(n, m) = list(map(int, input().split()))
	for i in range(0, n):
		g = list(map(int, input().split()))
		h = list(map(int, input().split()))
		l.append([g, h])
	if m % 2 == 0:
		for i in l:
			if i[0][1] == i[1][0]:
				print('YES')
				break
		else:
			print('NO')
	elif m % 2 != 0:
		print('NO')
	t -= 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [[[0, 0], [0, 0]]] * n
	for i in range(n):
		mx = [list(map(int, input().split())), list(map(int, input().split()))]
		a[i] = mx
	if m % 2:
		print('NO')
	else:
		f = 0
		for i in a:
			if i[1][0] == i[0][1]:
				f = 1
				break
		print('YES' if f else 'NO')


t = int(input())
for test in range(1, t + 1):
	(n, m) = [int(i) for i in input().split()]
	flag = False
	for i in range(n):
		(a, b) = [int(j) for j in input().split()]
		(c, d) = [int(j) for j in input().split()]
		if b == c:
			flag = True
	if flag and m % 2 == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	t = 0
	for i in range(a):
		(c, d) = map(int, input().split())
		(e, f) = map(int, input().split())
		if d == e:
			t += 1
	if t == 0 or b % 2 == 1:
		print('NO')
	else:
		print('YES')


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop, heapify
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
from itertools import accumulate
from functools import lru_cache
M = mod = 998244353

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	(n, m) = li()
	l = []
	middle = 0
	for i in range(n):
		(a, b) = li()
		(c, d) = li()
		l.append([a, b, c, d])
		if b == c:
			middle = 1
	if m & 1 or not middle:
		print('NO')
		continue
	done = 0
	for i in range(len(l)):
		for j in range(len(l)):
			if l[i][1] == l[j][2] and l[j][1] == l[i][2]:
				done = 1
	print('YES' if done else 'NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = []
	for i in range(n):
		l = list(map(int, input().split()))
		b = list(map(int, input().split()))
		arr.append([l, b])
	if k % 2 == 1:
		print('NO')
	else:
		count = 1
		for i in range(n):
			if arr[i][0][1] == arr[i][1][0]:
				count -= 1
				if count == 0:
					break
		print('YES') if count == 0 else print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	mat = []
	ans = 'NO'
	for i in range(n):
		(a11, a12) = map(int, input().split())
		(a21, a22) = map(int, input().split())
		mat.append([a11, a12, a21, a22])
		if a12 == a21 and m % 2 == 0:
			ans = 'YES'
	print(ans)


a = int(input())
for i in range(a):
	(b, b1) = map(int, input().split())
	k = False
	gg = []
	ll = 0
	for j in range(b):
		(c, c1) = map(int, input().split())
		(d, d1) = map(int, input().split())
		if c1 == d and b1 >= 2:
			k = True
	if k == True and b1 % 2 == 0:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	sym = 0
	for _ in range(n):
		alist = [[int(x) for x in input().split()] for _ in range(2)]
		if alist[0][1] == alist[1][0]:
			sym = 1
	if m % 2 != 0 or not sym:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ans1 = 'NO'
	ans2 = 'NO'
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if a == d:
			ans1 = 'YES'
		if c == b:
			ans2 = 'YES'
	if ans2 == 'YES' and m % 2 == 0:
		print('YES')
	else:
		print('NO')


def transpose(f):
	for i in range(len(f[0])):
		for j in range(len(f[0])):
			if f[i][j] != f[j][i]:
				return False
	return True
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	myList = list()
	w = x
	while w != 0:
		myList.append([list(map(int, input().split())), list(map(int, input().split()))])
		w -= 1
	if y % 2 != 0:
		print('NO')
	else:
		count = 0
		for i in myList:
			if transpose(i) == True:
				count += 1
				break
		if count > 0:
			print('YES')
		else:
			print('NO')


def main():
	inp = int(input())
	for i in range(inp):
		(n, m) = input().split()
		n = int(n)
		m = int(m)
		c = 2
		for j in range(n):
			(f, s) = input().split()
			(t, l) = input().split()
			f = int(f)
			s = int(s)
			t = int(t)
			l = int(l)
			if s == t:
				c = 1
		if m % 2 != 0:
			print('NO')
			c = 0
		if c == 1:
			print('YES')
		if c == 2:
			print('NO')
main()


import sys, math
input = lambda : sys.stdin.readline().rstrip()

def gcd(n, f):
	if n == 0 or f == 0:
		return max(n, f)
	if n > f:
		return gcd(n % f, f)
	else:
		return gcd(f % n, n)

def division_with_remainder_up(pp, ppp):
	return (pp + ppp - 1) // ppp
for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	mas = []
	ans = 'NO'
	for i in range(n):
		(a, b) = list(map(int, input().split()))
		(v, c) = list(map(int, input().split()))
		if b == v:
			ans = 'YES'
	if m % 2 == 0:
		print(ans)
	else:
		print('NO')


from math import *
from cmath import *
from decimal import *
from fractions import *
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = []
	for i in range(n):
		a.append([[int(x) for x in input().split()] for j in range(2)])
	ok = False
	for i in range(n):
		ok |= a[i][0][1] == a[i][1][0]
	ok &= m % 2 == 0
	print('YES' if ok else 'NO')


import sys
import math
from collections import Counter
from collections import OrderedDict

def inputt():
	return sys.stdin.readline().strip()

def printt(n):
	sys.stdout.write(str(n) + '\n')

def listt():
	return [int(i) for i in inputt().split()]

def gcd(a, b):
	return math.gcd(a, b)

def lcm(a, b):
	return a * b / gcd(a, b)

def dfs(src, visit):
	visit[src] = 1
	for nbr in dic[src]:
		if visit[nbr] == 0:
			dfs(nbr, visit)
t = int(inputt())
for _ in range(t):
	(n, m) = map(int, inputt().split())
	if m * m % 4 != 0:
		printt('NO')
		for i in range(n):
			(a, b) = map(int, inputt().split())
			(c, d) = map(int, inputt().split())
	else:
		count = 0
		for i in range(n):
			(a, b) = map(int, inputt().split())
			(c, d) = map(int, inputt().split())
			if b == c:
				count += 1
		if count == 0:
			printt('NO')
		else:
			printt('YES')


from sys import stdin, stdout
test = int(stdin.readline())
for _ in range(test):
	(n, m) = map(int, stdin.readline().split())
	mat = []
	ch = 1
	for i in range(2 * n):
		(x, y) = map(int, stdin.readline().split())
		if ch:
			mat.append([])
			mat[-1].append([x, y])
			ch ^= 1
		else:
			mat[-1].append([x, y])
			ch ^= 1
	if m & 1:
		print('NO')
		continue
	ans = 0
	for i in range(n):
		t = mat[i]
		if t[0][1] == t[1][0]:
			ans = 1
			break
	print('YES') if ans else print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	if m % 2:
		print('NO')
		for _ in range(n):
			x = input()
			y = input()
		continue
	flag = 0
	for i in range(n):
		temp = []
		temp.append(list(map(int, input().split())))
		temp.append(list(map(int, input().split())))
		if temp[0][1] == temp[1][0]:
			flag = 1
	if flag == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	s = input().split()
	(n, m) = (int(s[0]), int(s[1]))
	a = []
	for i in range(n):
		a.append([[int(x) for x in input().split()] for i in range(2)])
	if m % 2 != 0:
		print('NO')
		continue
	flag = False
	for i in range(n):
		if a[i][0][1] == a[i][1][0]:
			flag = True
			break
	if flag == True:
		print('YES')
	else:
		print('NO')


for j in range(int(input())):
	(n, m) = map(int, input().split())
	s = 0
	for i in range(n):
		(q, w) = map(int, input().split())
		(e, r) = map(int, input().split())
		if e == w:
			s = 1
	print('YES' if s == 1 and m % 2 == 0 else 'NO')


import sys
import math
tests = int(input())
for a in range(tests):
	(n, m) = [int(i) for i in input().split()]
	ok = False
	for b in range(n):
		tile = []
		tile.append([int(i) for i in input().split()])
		tile.append([int(i) for i in input().split()])
		if tile[1][0] == tile[0][1]:
			ok = True
	if m % 2 != 0:
		ok = False
	if ok:
		print('YES')
	else:
		print('NO')


testcases = int(input())
for tc in range(testcases):
	(umber, tr) = map(int, input().split())
	flag = 0
	for ndex in range(umber):
		(u, w) = map(int, input().split())
		(x, y) = map(int, input().split())
		if w == x:
			flag = 1
	if tr % 2 == 0 and flag == 1:
		print('YES')
	else:
		print('NO')


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	good = False
	good1 = False
	for i in range(n):
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		good |= a[1] == b[0]
	print('YES' if good and m % 2 == 0 else 'NO')


t = int(input())
while t:
	t -= 1
	ans = ''
	(n, m) = map(int, input().split())
	if m % 2 == 1:
		ans = 'NO'
	for i in range(n):
		firstline = list(map(int, input().split()))
		secondline = list(map(int, input().split()))
		if firstline[1] == secondline[0]:
			if ans == '':
				ans = 'YES'
	if ans == '':
		ans = 'NO'
	print(ans)


t = int(input())
while t > 0:
	t -= 1
	(n, m) = [int(x) for x in input().split()]
	k = n
	count = 0
	while k > 0:
		k -= 1
		(a, b) = [int(x) for x in input().split()]
		(c, d) = [int(x) for x in input().split()]
		arr = [[a, b], [c, d]]
		arr1 = [[a, c], [b, d]]
		if arr == arr1:
			count += 1
	if m == 2:
		if count > 0:
			print('YES')
		else:
			print('NO')
	elif m % 2 == 1:
		print('NO')
	elif count > 0:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(k, size) = map(int, input().split())
	tiles = [[list(map(int, input().split())), list(map(int, input().split()))] for i in range(k)]
	if size % 2:
		print('NO')
	elif any((a[1] == b[0] for (a, b) in tiles)):
		print('YES')
	else:
		print('NO')


def symmetric(tile):
	return tile[0][1] == tile[1][0]

def any_symmetric(tiles):
	for tile in tiles:
		if symmetric(tile):
			return True
	return False
t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().strip().split()))
	tiles = [[input().strip().split() for i in range(2)] for j in range(n)]
	if m % 2 == 0 and any_symmetric(tiles):
		print('YES')
	else:
		print('NO')


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 998244353
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')

def solve():
	for _ in range(ii()):
		(n, m) = mi()
		a = []
		f = 0
		for i in range(n):
			(x, y) = mi()
			(x1, y1) = mi()
			a.append([x, y, x1, y1])
			if y == x1:
				f = 1
		if m % 2 or f == 0:
			print('NO')
		else:
			print('YES')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
solve()


from collections import Counter, OrderedDict
from itertools import permutations as perm
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()
for _ in range(t):
	(n, m) = gil()
	flag = False
	tiles = []
	for _ in range(n):
		til = []
		til.append(gil())
		til.append(gil())
		tiles.append(til)
		if til[1][0] == til[0][1]:
			flag = True
	if m & 1:
		flag = False
	if flag:
		flag = False
		for til in tiles:
			(a, b, c, d) = (til[0][0], til[0][1], til[1][0], til[1][1])
			if [[a, c], [b, d]] in tiles:
				flag = True
				break
	print('YES' if flag else 'NO')


import math
for ii in range(int(input())):
	(n, m) = map(int, input().split())
	c = 0
	for _ in range(n):
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		if a[1] == b[0]:
			c += 1
	if m % 2 == 0:
		if c > 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = [int(i) for i in input().split()]
	a = []
	for j in range(n):
		a.append([[int(x) for x in input().split()] for j in range(2)])
	flag = False
	for j in range(n):
		flag |= a[j][0][1] == a[j][1][0]
	flag &= m % 2 == 0
	print('YES' if flag else 'NO')


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
decimal.getcontext().prec = 46

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def modefiedSieve():
	mx = 10 ** 7 + 1
	sieve = [-1] * mx
	for i in range(2, mx):
		if sieve[i] == -1:
			sieve[i] = i
			for j in range(i * i, mx, i):
				if sieve[j] == -1:
					sieve[j] = i
	return sieve

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def DFS(n, s, adj):
	visited = [False for i in range(n + 1)]
	stack = []
	stack.append(s)
	while len(stack):
		s = stack[-1]
		stack.pop()
		if not visited[s]:
			visited[s] = True
		for node in adj[s]:
			if not visited[node]:
				stack.append(node)

def maxSubArraySum(a, size):
	maxint = 10 ** 10
	max_so_far = -maxint - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far

def solve():
	(n, m) = num_input()
	flag = False
	for _ in range(n):
		(x1, x2) = num_input()
		(x3, x4) = num_input()
		if x2 == x3:
			flag = True
	if m % 2 != 0 or not flag:
		print('NO')
		return
	print('YES')
t = 1
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	z = False
	(n, m) = map(int, input().strip().split())
	if m != 2:
		for x in range(n):
			(a, b) = map(int, input().strip().split())
			(c, d) = map(int, input().strip().split())
			if b == c:
				z = True
	else:
		for x in range(n):
			(a, b) = map(int, input().strip().split())
			(c, d) = map(int, input().strip().split())
			if b == c:
				z = True
	if z and m % 2 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	mat = [[0, 0, 0, 0] for _ in range(n)]
	sys = []
	for i in range(n):
		(mat[i][0], mat[i][1]) = map(int, input().split())
		(mat[i][2], mat[i][3]) = map(int, input().split())
		if mat[i][1] == mat[i][2]:
			sys.append(True)
		else:
			sys.append(False)
	if m % 2 == 1:
		print('NO')
		continue
	if any(sys) == True:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	flag = 0
	for i in range(n):
		x = list(map(int, input().split()))
		y = list(map(int, input().split()))
		if x[1] == y[0]:
			flag = 1
	if m % 2 != 0:
		print('NO')
	elif flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	flag = True
	if m % 2:
		print('NO')
		for _ in range(n):
			(a1, a2) = map(int, input().split())
			(b1, b2) = map(int, input().split())
	else:
		for _ in range(n):
			(a1, a2) = map(int, input().split())
			(b1, b2) = map(int, input().split())
			if flag and b1 == a2:
				print('YES')
				flag = False
		if flag:
			print('NO')


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	var = 'NO'
	for _ in range(n):
		(x, y) = list(map(int, input().split()))
		if list(map(int, input().split()))[0] == y and m % 2 == 0:
			var = 'YES'
	print(var)


def inp():
	return int(input())

def minp():
	return map(int, input().split())

def linp():
	return list(map(int, input().split()))
for _ in range(inp()):
	(n, m) = minp()
	flag = 0
	for i in range(n):
		l = []
		for j in range(2):
			l.append(linp())
		f = 0
		for x in range(2):
			for y in range(2):
				if l[x][y] != l[y][x]:
					f = 1
					break
			if f:
				break
		if f == 0:
			flag = 1
	if flag == 0:
		print('NO')
	elif m % 2:
		print('NO')
	else:
		print('YES')


T = int(input())
for _ in range(T):
	(N, M) = map(int, input().split())
	flag = 0
	for i in range(2 * N):
		if i % 2 == 0:
			(a, b) = map(int, input().split())
		else:
			(c, d) = map(int, input().split())
			if c == b:
				flag = 1
	if M & 1 == 1:
		ans = 'NO'
	elif flag == 1:
		ans = 'YES'
	else:
		ans = 'NO'
	print(ans)


import math
rifat = int(input())
while rifat:
	ind = [int(x) for x in input().split()]
	f = False
	while ind[0]:
		a = [int(x) for x in input().split()]
		b = [int(x) for x in input().split()]
		if ind[1] % 2 == 0 and a[1] == b[0]:
			f = True
		ind[0] -= 1
	if f:
		print('YES')
	else:
		print('NO')
	rifat -= 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	M = [[0] * 2 for i in range(2 * n)]
	Nb = 0
	for i in range(2 * n):
		M[i] = list(map(int, input().split()))
		if i % 2 == 1:
			if M[i][0] == M[i - 1][1]:
				Nb += 1
	if Nb == 0 or m % 2 == 1:
		print('NO')
	else:
		print('YES')


def is_cover(tiles):
	for tile in tiles:
		if tile[0][1] == tile[1][0]:
			return 'YES'
	return 'NO'
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	tiles = []
	for _ in range(n):
		tile = []
		for _ in range(2):
			tile.append(list(map(int, input().split())))
		tiles.append(tile)
	if m % 2 == 0:
		print(is_cover(tiles))
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	check = 0
	for i in range(n):
		(a1, a2) = map(int, input().split())
		(a3, a4) = map(int, input().split())
		if a3 == a2:
			check = 1
	if m % 2 == 0:
		if check == 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


rw = int(input())
for wewq in range(rw):
	(n, m) = map(int, input().split())
	p = False
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if c == b:
			p = True
	if m % 2 == 1:
		p = False
	if p:
		print('YES')
	else:
		print('NO')


def is_symmetric(m):
	return m[0][1] == m[1][0]

def is_transposed(m1, m2):
	return m1[0][0] == m2[0][0] and m1[1][1] == m2[1][1] and (m1[0][1] == m2[1][0]) and (m1[1][0] == m2[0][1])

def solve_b(n, m, types):
	if m % 2:
		return 'NO'
	has_symmetric = False
	for matrix in types:
		if is_symmetric(matrix):
			has_symmetric = True
			break
	if has_symmetric:
		return 'YES'
	return 'NO'
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	types = []
	for _ in range(n):
		first_line = [int(x) for x in input().split()]
		second_line = [int(x) for x in input().split()]
		types.append([first_line, second_line])
	print(solve_b(n, m, types))


import math

def is_symmetric(a, b) -> [bool, bool]:
	el0 = a[0][0] == b[0][0]
	el1 = a[0][1] == b[1][0]
	el2 = a[1][0] == b[0][1]
	el3 = a[1][1] == b[1][1]
	return [el0 and el1 and el2 and el3, a[0][1] == a[1][0]]

def symmetric_matrix():
	test_cases = int(input())
	for t in range(test_cases):
		(n, m) = [int(x) for x in input().split(' ')]
		tiles = []
		has_symmetric = False
		has_diag = False
		for _ in range(n):
			line = [int(x) for x in input().split(' ')]
			line2 = [int(x) for x in input().split(' ')]
			tiles += [[line, line2]]
		for tile_idx1 in range(len(tiles)):
			for tile_idx2 in range(tile_idx1, len(tiles)):
				(is_sym, is_diag) = is_symmetric(tiles[tile_idx1], tiles[tile_idx2])
				has_symmetric = has_symmetric or is_sym
				has_diag = has_diag or is_diag
		if not has_symmetric or not has_diag or m % 2 != 0:
			print('NO')
		else:
			print('YES')
symmetric_matrix()


def is_symmetric(a):
	return a[0][1] == a[1][0]
for _ in range(int(input())):

	def two_ints():
		return list(map(int, input().split()))
	(n, m) = map(int, input().split())
	tiles = [[two_ints(), two_ints()] for i in range(n)]
	print('YES' if m % 2 == 0 and any([is_symmetric(tile) for tile in tiles]) else 'NO')


import random, math, sys
from copy import deepcopy as dc
from bisect import bisect_left, bisect_right
from collections import Counter
input = sys.stdin.readline

def solution(h, c, t):
	pass

def input_test():
	t = 1
	for _ in range(int(input())):
		t += 1
		(n, m) = map(int, input().strip().split(' '))
		if m & 1:
			print('NO')
			for i in range(n):
				(a, b) = map(int, input().strip().split(' '))
				(c, d) = map(int, input().strip().split(' '))
			continue
		f = False
		for i in range(n):
			(a, b) = map(int, input().strip().split(' '))
			(c, d) = map(int, input().strip().split(' '))
			if b == c:
				f = True
		if f:
			print('YES')
		else:
			print('NO')

def test():
	pass
input_test()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ans = 'NO'
	(p, p1) = (0, 0)
	s = set()
	for i in range(n):
		(x1, x2) = map(int, input().split())
		(x3, x4) = map(int, input().split())
		if x2 == x3:
			p = 1
	if m % 2 != 0:
		print('NO')
		continue
	if p == 1:
		ans = 'YES'
	print(ans)


import math
t = int(input())
for w in range(t):
	(n, m) = (int(i) for i in input().split())
	l = []
	for i in range(n):
		t1 = [int(i) for i in input().split()]
		t2 = [int(i) for i in input().split()]
		l += [[t1, t2]]
	if m % 2 != 0:
		print('NO')
	else:
		c = 0
		for i in range(n):
			if l[i][0][1] == l[i][1][0]:
				c = 1
				break
		if c == 1:
			print('YES')
		else:
			print('NO')


def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		flag = 0
		for _ in range(n):
			(a, b) = map(int, input().split())
			(c, d) = map(int, input().split())
			if b == c:
				flag = 1
		if not m & 1 and flag == 1:
			print('YES')
		else:
			print('NO')
main()


from sys import stdin
input = stdin.readline
T = int(input())
for _ in range(T):
	(N, M) = map(int, input().split())
	flag = False
	A = []
	for _ in range(N):
		A.append([list(map(int, input().split())) for _ in range(2)])
		if A[-1][0][1] == A[-1][1][0]:
			flag = True
	if flag and (not M % 2):
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	(a, b) = map(int, input().split())
	check = False
	for i in range(a):
		(aa, bb) = map(int, input().split())
		(cc, dd) = map(int, input().split())
		if bb == cc:
			check = True
	print('NO' if not check or b % 2 == 1 else 'YES')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	Y = False
	for v in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			Y = True
	if Y and (not m % 2):
		print('YES')
	else:
		print('NO')


def check_symmetry(a, m):
	for i in range(m):
		for j in range(m):
			if a[i][j] != a[j][i]:
				return False
	return True
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	t = 0
	even = True
	if m % 2 != 0:
		even = False
	for _ in range(n):
		a1 = list(map(int, input().split()))
		a2 = list(map(int, input().split()))
		if even:
			a = [a1, a2]
			if check_symmetry(a, 2):
				t += 1
	if t > 0:
		print('YES')
	else:
		print('NO')


import sys
t = int(input())
while t > 0:
	t -= 1
	input = sys.stdin.readline()
	(n, m) = map(int, input.split())
	arr = []
	for i in range(n):
		input = sys.stdin.readline()
		(a, b) = map(int, input.split())
		input = sys.stdin.readline()
		(c, d) = map(int, input.split())
		ar = [a, b, c, d]
		arr.append(ar)
	if m % 2 != 0:
		print('NO')
	else:
		flag = 0
		for i in range(n):
			if arr[i][1] == arr[i][2]:
				print('YES')
				flag = 1
				break
		if flag == 0:
			print('NO')


import sys
import re
import random
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
input = sys.stdin.readline
getS = lambda : input().strip()
getN = lambda : int(input())
getList = lambda : list(map(int, input().split()))
getZList = lambda : [int(x) - 1 for x in input().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
divide = lambda x: pow(x, MOD - 2, MOD)

def solve():
	(n, m) = getList()
	diag = 0
	each = 0
	li = []
	for i in range(n):
		t = getList()
		t += getList()
		if t[1] == t[2]:
			diag += 1
		li.append(t)
		if [t[0], t[2], t[1], t[3]] in li:
			each += 1
	if m % 2 == 1:
		print('NO')
		return
	if diag and each:
		print('YES')
	else:
		print('NO')
	return

def main():
	n = getN()
	for _ in range(n):
		solve()
	return
main()


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt
import math

def main():
	for t in range(int(input())):
		(n, m) = map(int, input().split())
		f = 0
		for i in range(n):
			(x, y) = map(int, input().split())
			(u, v) = map(int, input().split())
			if y == u:
				f = 1
		if m % 2 == 1:
			print('NO')
		elif f == 1:
			print('YES')
		else:
			print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
from collections import Counter, defaultdict, deque

def int1():
	return int(input())

def map1():
	return map(int, input().split())

def list1():
	return list(map(int, input().split()))
mod = pow(10, 9) + 7

def solve():
	(n, m) = map1()
	l1 = []
	for i in range(2 * n):
		l1.append(list1())
	if m % 2 == 1:
		print('NO')
		return
	for i in range(0, 2 * n, 2):
		if l1[i][1] == l1[i + 1][0]:
			print('YES')
			return
	print('NO')
for _ in range(int(input())):
	solve()


for z in range(int(input())):
	(n, m) = map(int, input().split())
	flag = True
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			flag = False
	if flag or m % 2 == 1:
		print('NO')
	else:
		print('YES')


n = int(input())
count = 0
for i in range(n):
	count = 0
	x = input().split()
	if int(x[1]) % 2 != 0:
		print('NO')
		l = []
		for j in range(2 * int(x[0])):
			m = input().split()
			l.append(m[0])
			l.append(m[1])
	else:
		l = []
		for j in range(2 * int(x[0])):
			m = input().split()
			l.append(m[0])
			l.append(m[1])
		c = 0
		while c < len(l) - 2:
			if l[1 + c] == l[2 + c]:
				count += 1
			c += 4
		if count >= 1:
			print('YES')
		if count == 0:
			print('NO')


from sys import *
from math import *
t = int(stdin.readline())
for _ in range(t):
	(n, m) = map(int, stdin.readline().split())
	a = []
	for i in range(2 * n):
		x = list(map(int, stdin.readline().split()))
		a.append(x)
	f = f1 = 0
	for i in range(0, 2 * n, 2):
		if a[i][1] == a[i + 1][0]:
			f = 1
	if m % 2 == 0 and f == 1:
		print('YES')
	else:
		print('NO')


def ans1(a):
	for i in a:
		if i[0][1] == i[1][0]:
			return True
	return False
for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = []
	for i in range(n):
		(x1, y1) = map(int, input().split())
		(x2, y2) = map(int, input().split())
		a.append([[x1, y1], [x2, y2]])
	else:
		if m % 2 == 0 and ans1(a):
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	A = []
	B = []
	for i in range(2 * n):
		B = list(map(int, input().split()))
		A.append(B)
	if m % 2 == 1:
		print('NO')
	else:
		for i in range(0, 2 * n, 2):
			if A[i][1] == A[i + 1][0]:
				print('YES')
				break
		else:
			print('NO')


import math
t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().strip().split(' ')]
	tiles = set()
	for _ in range(n):
		(a, b) = [int(x) for x in input().strip().split(' ')]
		(c, d) = [int(x) for x in input().strip().split(' ')]
		word = (a, b, c, d)
		tiles.add(word)
	if m % 2 == 0:
		dfound = False
		ffound = False
		for x in tiles:
			if x[1] == x[2]:
				dfound = True
				break
		if dfound:
			for x in tiles:
				x1 = (x[0], x[2], x[1], x[3])
				if x1 in tiles:
					ffound = True
					break
		if ffound:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split(' '))
	matrix = []
	for _ in range(n):
		first = list(map(int, input().split(' ')))
		second = list(map(int, input().split(' ')))
		if first[1] != second[0]:
			continue
		else:
			matrix.append([first, second])
	if m % 2 != 0:
		print('NO')
		continue
	if len(matrix) >= 1:
		print('YES')
	else:
		print('NO')


from typing import Counter
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	found = False
	for _ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			found = True
	if m % 2 == 1:
		print('NO')
	else:
		print('YES' if found else 'NO')


from functools import reduce
import os
import sys
from collections import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(2 * n)]
mo = 1000000007
inf = 1e+18
div = 998244353
for _ in range(inn()):
	(n, m) = value()
	flag = 0
	ans = 'YES'
	for i in range(n):
		(a, b) = value()
		(c, d) = value()
		if b == c:
			flag = 1
	if m % 2 == 1:
		ans = 'NO'
	elif flag == 0:
		ans = 'NO'
	print(ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	tiles = [[list(map(int, input().split())) for _ in range(2)] for _ in range(n)]
	if m % 2 == 1:
		print('NO')
		continue
	if any((t[1][0] == t[0][1] for t in tiles)):
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	(n, x) = map(int, input().split())
	poss = False
	for k in range(n):
		(a1, a2) = map(int, input().split())
		(b1, b2) = map(int, input().split())
		if b1 == a2:
			poss = True
	print(['NO', 'YES'][poss and x % 2 == 0])


try:
	for _ in range(int(input())):
		(n, m) = list(map(int, input().split()))
		flag = 1
		if m % 2:
			print('NO')
			for i in range(n):
				(a, b) = list(map(int, input().split()))
				(c, d) = list(map(int, input().split()))
			continue
		for i in range(n):
			(a, b) = list(map(int, input().split()))
			(c, d) = list(map(int, input().split()))
			if c == b:
				flag = 0
		if flag:
			print('NO')
		else:
			print('YES')
except:
	pass


from sys import stdin
tt = int(stdin.readline())
for loop in range(tt):
	(n, m) = map(int, stdin.readline().split())
	ans = 'NO'
	for i in range(n):
		(a, b) = map(int, stdin.readline().split())
		(c, d) = map(int, stdin.readline().split())
		if b == c and m % 2 == 0:
			ans = 'YES'
	print(ans)


from math import ceil
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	flag = True
	for i in range(n):
		(l1, r1) = map(int, input().split())
		(l2, r2) = map(int, input().split())
		if l2 == r1:
			flag = False
	if m & 1 or flag:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ans = False
	while n:
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		ans |= b == c
		n -= 1
	ans &= m & 1 ^ 1
	print('NYOE S'[ans::2])


t = int(input())
for test in range(t):
	(n, m) = map(int, input().split())
	test = False
	for i in range(n):
		(a, s) = map(int, input().split())
		(b, r) = map(int, input().split())
		if b == s:
			test = True
	if m % 2:
		print('NO')
	elif test:
		print('YES')
	else:
		print('NO')


from sys import stdin
input = stdin.readline
for i in range(int(input())):
	(n, m) = map(int, input().split())
	s = 'NO'
	for ik in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c and m & 1 != 1:
			s = 'YES'
	print(s)


def check(a, b, c, d):
	return b == c
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	if m & 1:
		for i in range(n):
			(a, b) = map(int, input().split())
			(c, d) = map(int, input().split())
		print('NO')
		continue
	flag = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if check(a, b, c, d):
			flag = 1
	print('YES') if flag else print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	flag = 0
	if m % 2 == 1:
		for i in range(2 * n):
			(x, y) = map(int, input().split())
	if m % 2 == 0:
		for i in range(2 * n):
			(x, y) = map(int, input().split())
			if i % 2 == 1:
				if x == prev_y:
					flag = 1
			else:
				(prev_x, prev_y) = (x, y)
	if flag == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	s = input().split()
	n = int(s[0])
	m = int(s[1])
	f = False
	for j in range(n):
		s = input().split()
		a = int(s[0])
		b = int(s[1])
		s = input().split()
		a1 = int(s[0])
		b1 = int(s[1])
		if b == a1 and m % 2 == 0:
			f = True
	if f:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	t = t - 1
	s = input().split()
	n = int(s[0])
	m = int(s[1])
	l = []
	for i in range(n):
		p = []
		for j in range(2):
			s = input().split()
			a = int(s[0])
			b = int(s[1])
			p.append([a, b])
		l.append(p)
	if m % 2 != 0:
		print('NO')
	else:
		s = 0
		for i in range(n):
			if l[i][0][1] == l[i][1][0]:
				s = 1
				break
		if s == 1:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	k = True
	ans = False
	i = 0
	while i < 2 * n:
		if k:
			(a, b) = map(int, input().split())
			k = False
		else:
			(a1, b1) = map(int, input().split())
			k = True
			if a1 == b:
				ans = True
		i += 1
	if m % 2 != 0:
		print('NO')
	elif ans:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = input().split()
	(n, m) = (int(n), int(m))
	f = False
	for i in range(n):
		(a, b) = input().split()
		(c, d) = input().split()
		(a, b, c, d) = [int(i) for i in (a, b, c, d)]
		if b == c:
			f = True
	if f and m % 2 == 0:
		print('Yes')
	else:
		print('No')


t = int(input())

def check(Map):
	is_symmetric = True
	for i in range(len(Map)):
		for j in range(len(Map)):
			if Map[i][j] != Map[j][i]:
				is_symmetric = False
				break
	return is_symmetric

def process():
	(n, m) = map(int, input().split())
	has_symmetric = False
	for _ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		Map = [[a, b], [c, d]]
		if check(Map):
			has_symmetric = True
	if has_symmetric == False:
		return 'NO'
	elif m % 2 == 0:
		return 'YES'
	else:
		return 'NO'
for _ in range(t):
	print(process())


import sys, threading
import math
from collections import defaultdict, Counter
input = sys.stdin.readline

def rl(type):
	return [type(w) for w in input().split()]

def reverse(arr):
	return arr[-1::-1]

def mod(a, m):
	return (a % m + m) % m

def check_prime(n):
	temp = int(math.sqrt(n) + 1)
	for i in range(2, temp):
		if n % i == 0:
			return False
	return True

def create_graph(n):
	graph = {}
	for _ in range(n):
		(x, y) = map(int, input().split())
		graph[x].append(y)
		graph[y].append(x)
	return graph

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		poss = False
		arr = []
		d = {}
		for _ in range(n):
			firstrow = list(map(int, input().split()))
			secondrow = list(map(int, input().split()))
			if firstrow[1] == secondrow[0]:
				poss = True
		if k % 2:
			print('NO')
		else:
			print('YES' if poss else 'NO')
sys.setrecursionlimit(10 ** 6)
threading.stack_size(10 ** 8)
t = threading.Thread(target=main)
t.start()
t.join()


for _ in range(int(input())):
	(n, m) = map(int, input().split(' '))
	l = []
	flag = False
	for i in range(n):
		temp = []
		for j in range(2):
			temp.append(list(map(int, input().split(' '))))
		l.append(temp)
	for i in range(n):
		if l[i][0][1] == l[i][1][0]:
			flag = True
			break
	if flag and m % 2 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	tmp = input().split(' ')
	n = int(tmp[0])
	m = int(tmp[1])
	flag = 0
	for i in range(n):
		tmp = input().split(' ')
		tmp1 = input().split(' ')
		if int(tmp[1]) == int(tmp1[0]):
			flag = 1
	if m % 2 == 0 and flag:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split(' '))
	valid_squre = 0
	for j in range(n):
		(a, b) = map(int, input().split(' '))
		(c, d) = map(int, input().split(' '))
		if c == b:
			valid_squre = valid_squre + 1
	if m % 2 != 0:
		print('NO')
		continue
	if valid_squre == 0:
		print('NO')
		continue
	print('YES')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	ok = False
	for i in range(n):
		(l1, r1) = map(int, input().split())
		(l2, r2) = map(int, input().split())
		if l2 == r1:
			ok = True
	if m % 2:
		ok = False
	print('YES' if ok else 'NO')


def readis():
	return map(int, input().strip().split())
T = int(input())

def sym_exists(tiles):
	for tile in tiles:
		[[a, b], [c, d]] = tile
		if b == c and c == b:
			return True
	return False
while T:
	T -= 1
	(n, m) = readis()
	tiles = []
	for _ in range(n):
		(a, b) = readis()
		(c, d) = readis()
		tiles.append([[a, b], [c, d]])
	if m % 2 == 0:
		if sym_exists(tiles):
			print('YES')
			continue
	print('NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().strip().split()))
	flag = False
	for i in range(n):
		(tl, tr) = map(int, input().strip().split())
		(bl, br) = map(int, input().strip().split())
		if tr == bl:
			flag = True
	if m % 2:
		print('NO')
	elif flag:
		print('YES')
	else:
		print('NO')


for q in range(int(input())):
	m = []
	(n, mm) = map(int, input().split())
	for i in range(n):
		for j in range(2):
			a = list(map(int, input().split()))
			m.append(a)
	count = 0
	for i in range(0, len(m), 2):
		if m[i][1] == m[i + 1][0]:
			count = 1
			break
	if count == 1 and mm % 2 == 0:
		print('YES')
	else:
		print('NO')


import os
import heapq
import sys, threading
import math
import operator
from collections import defaultdict, deque
from io import BytesIO, IOBase
sys.setrecursionlimit(10 ** 5)

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		(n, x) = inpt()
		ok = False
		for i in range(n):
			(a, b) = inpt()
			(c, d) = inpt()
			if c == b:
				ok = True
		if x % 2 == 1:
			print('NO')
			continue
		if ok:
			print('YES')
		else:
			print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = input()
t = int(t)
for i in range(t):
	(n, m) = input().split(' ')
	n = int(n)
	m = int(m)
	a1 = []
	b1 = []
	for j in range(2 * n):
		(a, b) = input().split(' ')
		a1.append(int(a))
		a1.append(int(b))
	if m % 2 != 0:
		print('NO')
	elif m < 2:
		print('NO')
	else:
		c = 0
		for k in range(0, len(a1), 4):
			if a1[k + 1] == a1[k + 2]:
				c = 1
				break
			else:
				c = 0
		if c == 1:
			print('YES')
		else:
			print('NO')


from sys import stdin, stdout
from math import ceil
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007

def solve():
	(n, m) = mp()
	f = 0
	for i in range(n):
		(a, b) = mp()
		(c, d) = mp()
		if b == c:
			f = 1
	if m & 1:
		pr('NO')
	elif f:
		pr('YES')
	else:
		pr('NO')
for _ in range(inp()):
	solve()


t = 1
t = int(input())
while t:
	t -= 1
	(n, m) = list(map(int, input().split()))
	symSq = False
	sq = []
	for _ in range(n):
		(a1, a2) = map(int, input().split())
		(a3, a4) = map(int, input().split())
		if a2 == a3:
			symSq = True
	if symSq and m % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
ans = [False for i in range(t)]
for x in range(t):
	(n, m) = map(int, input().split())
	for i in range(n):
		(a, b) = input().split()
		(c, d) = input().split()
		if c == b:
			ans[x] = True
		if m % 2:
			ans[x] = False
for i in ans:
	if i:
		print('YES')
	else:
		print('NO')


def isSymmetric(n, m):
	tiles = []
	for i in range(0, n):
		arr = []
		arr.append(list(map(int, input().split())))
		arr.append(list(map(int, input().split())))
		tiles.append(arr)
	if m % 2:
		return 'NO'
	for tile in tiles:
		if tile[0][1] == tile[1][0]:
			return 'YES'
	return 'NO'
t = int(input())
for i in range(0, t):
	print(isSymmetric(*list(map(int, input().split()))))


n = int(input())
for j in range(0, n):
	(n, m) = map(int, input().split())
	l = []
	for k in range(0, n):
		(a1, a2) = map(int, input().split())
		(a3, a4) = map(int, input().split())
		l.append([a1, a2, a3, a4])
	a = False
	for i in range(0, n):
		if l[i][1] == l[i][2]:
			a = True
			break
	if m % 2 == 1:
		print('NO')
	elif a:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	l = []
	for i in range(n * 2):
		l.append([int(i) for i in input().split()])
	d = 'NO'
	if k % 2 != 0:
		print(d)
	else:
		for i in range(0, n * 2, 2):
			if l[i][1] == l[i + 1][0]:
				d = 'YES'
				break
		print(d)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ans = 'NO'
	two = 'NO'
	for i in range(n):
		first = [int(x) for x in input().split()]
		second = [int(x) for x in input().split()]
		if first[1] == second[0]:
			ans = 'YES'
			two = 'YES'
	if m & 1:
		print('NO')
		continue
	else:
		print(ans)


t = int(input())
while t:
	(n, m) = map(int, input().split())
	lst = []
	for i in range(n):
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		lst.append([a, b])
	if m % 2 != 0:
		print('NO')
		t -= 1
		continue
	present = False
	for matrix in lst:
		if matrix[0][1] == matrix[1][0]:
			present = True
			break
	if present:
		print('YES')
	else:
		print('NO')
	t -= 1


import sys
from collections import defaultdict as dd
from collections import Counter as cc
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = lambda : sys.stdin.buffer.readline().rstrip()
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	q = 0
	w = 0
	r = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if c == b:
			r = 1
	if m % 2 == 1:
		print('NO')
		continue
	if r == 1:
		print('YES')
	else:
		print('NO')


import math
from sys import stdin
for _ in range(int(stdin.readline())):
	(n, M) = map(int, stdin.readline().strip().split())
	l = []
	z = 0
	for i in range(n):
		m = []
		k = []
		for j in range(2):
			temp = list(map(int, stdin.readline().strip().split()))
			k.append(temp)
		l.append(k)
	if M % 2 != 0:
		print('NO')
	else:
		for i in range(len(l)):
			x = l[i]
			if x[0][1] == x[1][0]:
				z = 1
				break
		if z > 0:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	c = 0
	for i in range(n):
		(a, b) = map(int, input().split())
		(a1, b1) = map(int, input().split())
		if a1 == b:
			c = c + 1
	if c > 0 and m % 2 == 0:
		print('Yes')
	else:
		print('No')


t = int(input())
while t != 0:
	square = {}
	diagonal = 0
	t -= 1
	(n, m) = map(int, input().split())
	while n != 0:
		n -= 1
		(tl, tr) = map(int, input().split())
		(bl, br) = map(int, input().split())
		if bl == tr:
			diagonal += 1
	if m % 2 == 0 and diagonal != 0:
		print('YES')
	else:
		print('NO')


pass
all = []
c = 0
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	all.append('NO')
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if c == b and m % 2 == 0:
			all[-1] = 'YES'
counter = 0
for _ in range(int(len(all))):
	print(all[counter])
	counter += 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	res = False
	for _ in range(n):
		matrix = [list(map(int, input().split())) for _ in range(2)]
		if m % 2 == 0 and matrix[0][1] == matrix[1][0]:
			res = True
	print('YES' if res else 'NO')


for i in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	c = 0
	for j in range(0, n):
		(a11, a12) = [int(x) for x in input().split()]
		(a21, a22) = [int(x) for x in input().split()]
		if a12 == a21:
			c += 1
	if m % 2 > 0:
		print('NO')
	elif c >= 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	d = 0
	s = 0
	for j in range(n):
		arr = []
		arr.append(list(map(int, input().split())))
		arr.append(list(map(int, input().split())))
		if arr[0][1] == arr[1][0]:
			s += 1
		if arr[0][0] == arr[1][1] and arr[0][1] == arr[1][0]:
			d += 1
	if m % 2 != 0:
		print('NO')
	elif s != 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	M = []
	L = []
	for i in range(2 * n):
		(x, y) = map(int, input().split())
		L.append(x)
		M.append(y)
	if m % 2 == 1:
		print('NO')
	else:
		for i in range(1, 2 * n, 2):
			if L[i] == M[i - 1]:
				print('YES')
				break
		else:
			print('NO')


import math
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	flag = 0
	for i in range(n):
		(x, y) = map(int, input().split())
		(p, q) = map(int, input().split())
		if y == p:
			flag = 1
	if m % 2:
		flag = 0
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for k in range(t):
	z = list(map(int, input().split()))
	n = z[0]
	m = z[1]
	flag = False
	for i in range(n):
		k = list(map(int, input().split()))
		a = k[1]
		k = list(map(int, input().split()))
		b = k[0]
		if a == b:
			flag = True
	if m % 2 == 1:
		flag = False
	if flag:
		print('YES')
	else:
		print('NO')


import sys

def f(matrix):
	for (a, b) in matrix:
		if b[0] == a[1]:
			return 'YES'
	return 'NO'
t = int(sys.stdin.readline().strip())
for _ in range(t):
	line = sys.stdin.readline().strip().split()
	(n, m) = list(map(int, line))
	matrix = []
	for i in range(n):
		line1 = list(map(int, sys.stdin.readline().strip().split()))
		line2 = list(map(int, sys.stdin.readline().strip().split()))
		matrix.append([line1, line2])
	if m % 2 == 1:
		print('NO')
	else:
		out = f(matrix)
		print(out)


t = int(input())
for w in range(t):
	dic = {}
	(n, m) = map(int, input().strip().split())
	c1 = False
	c2 = False
	if m % 2 == 0:
		for i in range(n):
			(a, b) = map(int, input().strip().split())
			(c, d) = map(int, input().strip().split())
			dic[i] = (a, b, c, d)
			if not c1 and b == c:
				c1 = True
			if (a, c, b, d) in dic.values():
				c2 = True
		if c1 and c2:
			print('YES')
		else:
			print('NO')
	else:
		for i in range(n):
			(a, b) = map(int, input().strip().split())
			(c, d) = map(int, input().strip().split())
		print('NO')


for t in range(int(input())):
	(m, n) = list(map(int, input().split()))
	index = 0
	for i in range(m):
		list1 = input().split()
		list2 = input().split()
		if int(list1[1]) == int(list2[0]):
			index = 1
	if n % 2 == 0 and index == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = [int(p) for p in input().split()]
	done = False
	for i in range(n):
		(x1, y1) = [int(p) for p in input().split()]
		(x2, y2) = [int(p) for p in input().split()]
		if x2 == y1:
			done = True
	if m % 2 != 0:
		print('NO')
		continue
	if not done:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	gaba = False
	for j in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			gaba = True
	if m % 2 == 1:
		print('NO')
	elif gaba:
		print('YES')
	else:
		print('NO')


def symmetric(temp):
	if temp[0][1] == temp[1][0]:
		return 1
	else:
		return 0
t = int(input())
for z in range(t):
	(n, m) = [int(x) for x in input().split()]
	arr = []
	for i in range(2 * n):
		temp = [int(x) for x in input().split()]
		arr.append(temp)
	cnt = 0
	temp = []
	for i in range(0, 2 * n, 2):
		temp.append(arr[i])
		temp.append(arr[i + 1])
		if symmetric(temp):
			cnt += 1
		temp = []
	if m % 2 != 0:
		print('NO')
	elif cnt > 0 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


def main():
	t = int(input())
	for _ in range(t):
		(n, m) = map(int, input().split())
		tiles = set()
		good = False
		for __ in range(n):
			(a, b) = map(int, input().split())
			(c, d) = map(int, input().split())
			if b == c:
				good = True
		if good and m % 2 == 0:
			print('YES')
		else:
			print('NO')
main()


t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	a = [None] * n
	for i in range(n):
		a[i] = [[1, 1], [1, 1]]
		a[i][0] = [int(x) for x in input().split()]
		a[i][1] = [int(x) for x in input().split()]
	if m % 2 != 0:
		print('NO')
		continue
	for i in range(n):
		tile = a[i]
		if tile[0][1] == tile[1][0]:
			print('YES')
			break
	else:
		print('NO')


T = int(input())
for t in range(T):
	(N, M) = [int(x) for x in input().split(' ')]
	tiles = set()
	found_tile = False
	for n in range(N):
		l1 = input().split(' ')
		l2 = input().split(' ')
		if l1[1] == l2[0]:
			found_tile = True
	if M % 2 != 0:
		print('NO')
		continue
	if found_tile:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(a, b) = map(int, input().split())
	flag = False
	for j in range(a):
		l = []
		for _ in range(2):
			l.append(list(map(int, input().split())))
		if l[0][-1] == l[1][0]:
			flag = True
	if flag and b & 1 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	g = 0
	for _ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			g = 1
	if k % 2 == 0 and g == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if k % 2 != 0:
		for _ in range(2 * n):
			x = list(map(int, input().split()))
		print('NO')
	else:
		count = 0
		for i in range(n):
			x = list(map(int, input().split()))
			y = list(map(int, input().split()))
			if x[1] == y[0]:
				count += 1
		if count > 0:
			print('YES')
		else:
			print('NO')


def is_sym(array):
	if array[1] == array[2]:
		return True
	return False
t = int(input())
while t:
	(n, m) = map(int, input().split())
	k = 0
	tiles = []
	while n:
		temp = []
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		temp.append(a)
		temp.append(b)
		temp.append(c)
		temp.append(d)
		tiles.append(temp)
		n -= 1
	if m % 2:
		print('NO')
	else:
		for i in tiles:
			if is_sym(i):
				print('YES')
				k = 1
				break
		if not k:
			print('NO')
	t -= 1


t = int(input())
for o1 in range(t):
	(n, m) = map(int, input().split())
	ans = 'NO'
	for o2 in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			ans = 'YES'
	if m % 2 == 1:
		ans = 'NO'
	print(ans)


for j in range(int(input())):
	(n, k) = map(int, input().split())
	if k % 2 > 0:
		for i in range(n):
			(fi, s) = map(int, input().split())
			(t, fr) = map(int, input().split())
		print('NO')
	else:
		ans = 'NO'
		for i in range(n):
			(fi, s) = map(int, input().split())
			(t, fr) = map(int, input().split())
			if t == s:
				ans = 'YES'
		print(ans)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	f = True
	if not m % 2 == 0:
		print('NO')
		f = False
	s = []
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		l = [a, b, c, d]
		s.append(l)
	if f == False:
		continue
	f = False
	for i in s:
		if i[1] == i[2]:
			f = True
	f2 = False
	f3 = False
	for i in s:
		for j in s:
			if i != j:
				if i[0] == j[0] and i[3] == j[3] and (i[1] == j[2]) and (i[2] == j[1]):
					f2 = True
	for i in s:
		if i[1] == i[2]:
			f3 = True
	if f:
		print('YES')
	elif m == 2:
		if f3:
			print('YES')
		else:
			print('NO')
	elif f2 and f3:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	x = list(map(int, input().split()))
	a = []
	for i in range(x[0]):
		b = []
		for j in range(2):
			c = list(map(int, input().split()))
			b.append(c)
		if '1' not in a:
			if b[1][0] == b[0][1]:
				a.append('1')
	if x[1] % 2 != 0:
		print('No')
		continue
	if '1' in a:
		print('Yes')
	else:
		print('No')


t = int(input())
for test_cases in range(t):
	(n, m) = [int(i) for i in input().split(' ')]
	l = []
	for i in range(n):
		a = [int(i) for i in input().split(' ')]
		b = [int(i) for i in input().split(' ')]
		l.append([a, b])

	def chk_sym(l):
		if l[0][1] == l[1][0]:
			return 0
		return 1
	if m % 2 == 1:
		print('NO')
	else:
		pr = 1
		for i in l:
			pr = pr * chk_sym(i)
		if pr == 0:
			print('YES')
		else:
			print('NO')


for case in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	tile = False
	for i in range(n):
		r1 = [int(x) for x in input().split()]
		r2 = [int(x) for x in input().split()]
		if r1[1] == r2[0]:
			tile = True
	if m % 2 == 0 and tile:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	flag = 0
	for i in range(n):
		arr1 = []
		arr2 = []
		arr1 = list(map(int, input().split()))
		arr2 = list(map(int, input().split()))
		if arr1[1] == arr2[0]:
			flag = 1
	if m % 2 != 0 or flag == 0:
		print('No')
	else:
		print('Yes')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	flag = False
	for __ in range(n):
		l = [list(map(int, input().split()))]
		l.append(list(map(int, input().split())))
		if l[0][1] == l[1][0]:
			flag = True
	if m % 2 == 1:
		flag = False
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	d1swt = False
	d2swt = False
	for i in range(n):
		new = list()
		for j in range(2):
			l = list(map(int, input().split()))
			new.append(l)
		if new[0][0] == new[1][1]:
			d1swt = True
		if new[0][1] == new[1][0]:
			d2swt = True
	if m % 2 != 0:
		print('No')
	elif d2swt:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	(n_matrix, size) = map(int, input().split())
	ans = False
	for __ in range(n_matrix):
		mat = []
		mat.append(list(map(int, input().split())))
		mat.append(list(map(int, input().split())))
		if mat[0][1] == mat[1][0]:
			ans = True
	if ans and size >= 2 and (size % 2 == 0):
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import random
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		(n, X) = In()
		flag = 0
		for x in range(n):
			(a, b) = In()
			(c, d) = In()
			if c == b:
				flag = 1
		if X % 2 != 0:
			no()
			return
		if flag == 1:
			yes()
		else:
			no()
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


import math
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = []
	fl = False
	for i in range(n):
		ar = []
		ar.append(list(map(int, input().split())))
		ar.append(list(map(int, input().split())))
		if ar[0][1] == ar[1][0]:
			fl = True
	if m % 2 != 0:
		print('NO')
	elif fl:
		print('YES')
	else:
		print('NO')


t = int(input())
for x in range(t):
	(n, m) = map(int, input().split())
	tiles = []
	for i in range(n):
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		tiles.append([a, b])
	if m & 1:
		print('NO')
	else:
		can = False
		for tile in tiles:
			if tile[0][1] == tile[1][0] or (tile[0][0] == tile[1][1] and tile[0][1] == tile[1][0]):
				can = True
				break
		if can:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	ans = False
	for _ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		arr = [a, b, c, d]
		all_equal = set(arr)
		if len(all_equal) == 1:
			ans = True
		if b == c:
			ans = True
	if m % 2 == 1:
		print('NO')
	elif m % 2 == 0 and ans == True:
		print('YES')
	elif m % 2 == 0 and ans == False:
		print('NO')


import io, os, math
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
rr = lambda : input()
rri = lambda : int(input())
rrm = lambda : list(map(int, input().split()))
INF = float('inf')

def solve(N, M, tiles):
	if M % 2 == 1:
		return False
	for tile in tiles:
		if tile[1] == tile[2]:
			return True
	return False
t = rri()
for _ in range(t):
	(N, M) = rrm()
	tiles = []
	for _ in range(N):
		top = rrm()
		bottom = rrm()
		top.extend(bottom)
		tiles.append(top)
	if solve(N, M, tiles):
		print('YES')
	else:
		print('NO')


import sys
read = lambda : sys.stdin.readline().strip()
readi = lambda : map(int, read().split())
for _ in range(int(read())):
	(n, m) = readi()
	isSym = False
	isEven = True
	if m % 2 != 0:
		isEven = False
	for _ in range(n):
		(a, b) = readi()
		(c, d) = readi()
		if c == b:
			isSym = True
	if isSym and isEven:
		print('YES')
	else:
		print('NO')


testes = int(input())
for _ in range(testes):
	(n, m) = map(int, input().split())
	res = 'NO'
	for __ in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			res = 'YES'
	if m % 2 != 0:
		res = 'NO'
	print(res)


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	c = 0
	for i in range(n):
		l = [list(map(int, input().split())) for i in range(2)]
		if l[0][1] == l[1][0]:
			c = 1
	if c and m % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, x) = list(map(int, input().split()))
	tiles = list()
	count = 0
	for i in range(n):
		(x1, x2) = list(map(int, input().split()))
		(x3, x4) = list(map(int, input().split()))
		tile = [x1, x2, x3, x4]
		tiles.append(tile)
		if x2 == x3:
			count += 1
	if x % 2 == 0 and count > 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	A = list(map(int, input().split()))
	n = A[0]
	m = A[1]
	B = [list(map(int, input().split())) for j in range(2 * n)]
	if m % 2 == 1:
		print('NO')
	else:
		C = 0
		for k in range(n):
			if B[0 + 2 * k][1] == B[1 + 2 * k][0]:
				C += 1
				break
		if C > 0:
			print('YES')
		else:
			print('NO')


t = int(input())
ans = []
for i in range(t):
	(n, m) = map(int, input().split())
	val = 'No'
	arr = []
	for j in range(n):
		p = list(map(int, input().split()))
		q = list(map(int, input().split()))
		r = p + q
		arr.append(r)
	if m % 2 != 0:
		ans.append('No')
	else:
		for k in arr:
			if k[1] == k[2]:
				val = 'Yes'
				break
		ans.append(val)
for j in ans:
	print(j)


import math

def main():
	t = int(input())
	answers = []
	for i in range(0, t):
		(n, m) = input().split()
		n = int(n)
		m = int(m)
		symmetric = False
		for j in range(0, n):
			matrix = [[int(it) for it in input().split()], [int(it) for it in input().split()]]
			if matrix[0][1] == matrix[1][0]:
				symmetric = True
		if symmetric:
			if m % 2 != 0:
				answers.append('NO')
			else:
				answers.append('YES')
		else:
			answers.append('NO')
	for answer in answers:
		print(answer)
main()


def main():
	T = eval(input())
	for case in range(T):
		(n, m) = map(int, input().split())
		flag = 0
		for i in range(n):
			(a, b) = map(int, input().split())
			(c, d) = map(int, input().split())
			if b == c:
				flag = 1
		if m % 2 == 0 and flag == 1:
			print('YES')
		else:
			print('NO')
main()


tc = int(input())
for _ in range(tc):
	[n, m] = list(map(int, input().split()))
	arr = []
	for _ in range(n):
		inarr = []
		[a0, a1] = list(map(int, input().split()))
		inarr.append(a0)
		inarr.append(a1)
		[a2, a3] = list(map(int, input().split()))
		inarr.append(a2)
		inarr.append(a3)
		arr.append(inarr)
	if m % 2 != 0:
		print('NO')
	else:
		flag = True
		for i in arr:
			if i[1] == i[2]:
				flag = False
				print('YES')
				break
		if flag == True:
			print('NO')


import sys
from collections import defaultdict as dc
import math
from bisect import bisect, bisect_left, bisect_right
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = []
	for i in range(n):
		p = []
		p.extend(list(map(int, input().split())))
		p.extend(list(map(int, input().split())))
		l.append(p)
	if m % 2:
		print('NO')
	else:
		f = 0
		for i in range(n):
			if l[i][1] == l[i][2]:
				f = 1
				break
		if f:
			print('YES')
		else:
			print('NO')


t = int(input())
for z in range(t):
	(n, m) = map(int, input().split())
	ba = m % 2 == 0
	bo = False
	for i in range(n):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			bo = True
	if not bo or not ba:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	tag = False
	for _ in range(n):
		fir = list(map(int, input().split()))
		sec = list(map(int, input().split()))
		if fir[1] == sec[0]:
			tag = True
	if m % 2 == 1 or tag == False:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	cnt = 0
	for i in range(n):
		(a1, b1) = map(int, input().split())
		(a2, b2) = map(int, input().split())
		if a2 == b1:
			cnt = cnt + 1
	if m % 2 == 1:
		print('NO')
		continue
	if cnt == 0:
		print('NO')
		continue
	print('YES')


import sys
for _ in range(int(input())):
	(n, m) = map(int, sys.stdin.readline().split())
	tiles = []
	for i in range(n):
		(a, b) = map(int, sys.stdin.readline().split())
		(c, d) = map(int, sys.stdin.readline().split())
		tiles.append([[a, b], [c, d]])
	flag = False
	if m % 2 == 1:
		pass
	else:
		for i in range(n):
			if tiles[i][0][1] == tiles[i][1][0]:
				flag = True
				break
	if flag == False:
		print('NO')
	else:
		print('YES')


def main(m, tiles):
	if m % 2 != 0:
		return 'NO'
	has_symetric = False
	for tile in tiles:
		if tile[0][1] == tile[1][0]:
			has_symetric = True
			break
	if not has_symetric:
		return 'NO'
	has_paired = False
	for (index, first_tile) in enumerate(tiles):
		for second_tile in tiles[index:]:
			if first_tile[0][0] == second_tile[0][0] and first_tile[0][1] == second_tile[1][0] and (first_tile[1][0] == second_tile[0][1]) and (first_tile[1][1] == second_tile[1][1]):
				has_paired = True
				break
		if has_paired:
			return 'YES'
	return 'NO'
tt = int(input())
for _ in range(tt):
	(n, m) = map(int, input().split(' '))
	tiles = []
	for _ in range(n):
		(a, b) = map(int, input().split(' '))
		(c, d) = map(int, input().split(' '))
		tiles.append(((a, b), (c, d)))
	print(main(m, tiles))


import sys
from array import array
import typing as Tp

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def main():
	t = int(input())
	ans = ['NO'] * t
	for ti in range(t):
		(n, m) = map(int, input().split())
		for _ in range(n):
			(a, b) = map(int, input().split())
			(c, d) = map(int, input().split())
			if m & 1 == 0 and b == c:
				ans[ti] = 'YES'
	sys.stdout.buffer.write(('\n'.join(map(str, ans)) + '\n').encode('utf-8'))
main()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	matrix = []
	for i in range(2 * n):
		matrix.append(list(map(int, input().split())))
	result = False
	if m % 2 == 1:
		result = False
	else:
		for q in range(0, 2 * n, 2):
			if matrix[q][1] == matrix[q + 1][0]:
				result = True
				break
	if result:
		print('YES')
	else:
		print('NO')


from math import *
from collections import Counter, defaultdict
from sys import stdin, stdout
input = stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
for _ in range(I()):
	(n, m) = M()
	flag = 0
	for i in range(n):
		(a, b) = M()
		(c, d) = M()
		if b == c:
			flag = 1
	if m % 2:
		print('NO')
	elif flag:
		print('YES')
	else:
		print('NO')


from sys import stdin
input = stdin.readline
from collections import defaultdict

def solve():
	(n, m) = map(int, input().split())
	tile = [[] for _ in range(2 * n)]
	for i in range(2 * n):
		tile[i] = list(map(int, input().split()))
	if m & 1 == 1:
		print('NO')
		return
	for i in range(0, 2 * n, 2):
		if tile[i][1] == tile[i + 1][0]:
			print('YES')
			return
	print('NO')
	return
t = int(input())
for _ in range(t):
	solve()


T = int(input())
for t in range(T):
	(N, m) = [int(i) for i in input().split(' ')]
	found = False
	for n in range(N):
		row1 = input().split(' ')
		row2 = input().split(' ')
		if row1[1] == row2[0]:
			found = True
	if found and m % 2 == 0:
		print('YES')
	else:
		print('NO')


import itertools
import math
import sys
from collections import defaultdict

def stdinWrapper():
	data = '6\n3 4\n1 2\n5 6\n5 7\n7 4\n8 9\n9 8\n2 5\n1 1\n1 1\n2 2\n2 2\n1 100\n10 10\n10 10\n1 2\n4 5\n8 4\n2 2\n1 1\n1 1\n1 2\n3 4\n1 2\n1 1\n1 1\n\n\n'
	for line in data.split('\n'):
		yield line
if '--debug' not in sys.argv:

	def stdinWrapper():
		while True:
			yield sys.stdin.readline()
inputs = stdinWrapper()

def inputWrapper():
	return next(inputs)

def getType(_type):
	return _type(inputWrapper())

def getArray(_type):
	return [_type(x) for x in inputWrapper().split()]

def solve(m, symmetrical):
	return 'YES' if m % 2 == 0 and any(symmetrical) else 'NO'
t = getType(int)
for _ in range(t):
	(n, m) = getArray(int)
	symmetrical = [False] * n
	for i in range(n):
		(_, r) = getArray(int)
		(l, _) = getArray(int)
		symmetrical[i] = l == r
	res = solve(m, symmetrical)
	if res is not tuple and res is not list:
		res = (res,)
	print(*res)


T = int(input())
while T != 0:
	(n, m) = [int(i) for i in input().split()]
	flag = 0
	for i in range(n):
		a = [[int(i) for i in input().split()], [int(i) for i in input().split()]]
		if a[0][1] == a[1][0]:
			flag = 1
	if m % 2 != 0:
		flag = 0
	if flag == 0:
		print('NO')
	elif flag == 1:
		print('YES')
	T -= 1


import math
t = int(input())
for tc in range(t):
	line = input().split()
	(n, m) = (int(line[0]), int(line[1]))
	count = 0
	flag = 0
	for i in range(n):
		line1 = input().split()
		line2 = input().split()
		x = int(line1[1])
		y = int(line2[0])
		a = int(line1[0])
		b = int(line2[1])
		if x == y:
			count += 1
		if x == y == a == b:
			flag = 1
	if m % 2 != 0:
		print('NO')
		continue
	if flag == 1:
		print('YES')
		continue
	elif count >= 1:
		print('YES')
	else:
		print('NO')


def solve():
	(n, m) = map(int, input().split())
	a = []
	ok = False
	for i in range(n):
		(e, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		ok |= b == c
		a.append([[e, b], [c, d]])
	if m % 2 or not ok:
		print('NO')
		return
	if m == 2:
		print('YES')
		return

	def check(a1, a2):
		con1 = a1[0][0] == a2[0][0] and a1[0][1] == a2[1][0]
		con2 = a1[1][1] == a2[1][1] and a1[1][0] == a2[0][1]
		return con1 and con2
	for i in range(n):
		for j in range(n):
			if check(a[i], a[j]):
				print('YES')
				return
	print('NO')
	return

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()
main()


import os
from sys import stdin, stdout

class Input:

	def __init__(self):
		self.lines = stdin.readlines()
		self.idx = 0

	def line(self):
		try:
			return self.lines[self.idx].strip()
		finally:
			self.idx += 1

	def array(self, sep=' ', cast=int):
		return list(map(cast, self.line().split(sep=sep)))

	def is_next(self):
		return self.idx < len(self.lines)

def known_cases(func):
	inpt = Input()
	(num_of_cases,) = inpt.array()
	for case in range(num_of_cases):
		func(inpt)

def unknown_cases(func):
	inpt = Input()
	while inpt.is_next():
		func(inpt)

@known_cases
def solve(inpt):
	(n, m) = inpt.array()
	sym = False
	for i in range(n):
		(a, b) = inpt.array()
		(c, d) = inpt.array()
		if c == b:
			sym = True
	if m % 2:
		print('NO')
	elif sym:
		print('YES')
	else:
		print('NO')


t = int(input())
for j in range(t):
	z = list(map(int, input().split()))
	n = z[0]
	m = z[1]
	ans = False
	for i in range(n):
		z = list(map(int, input().split()))
		x = list(map(int, input().split()))
		if z[1] == x[0]:
			ans = True
	if m % 2 != 0:
		ans = False
	if ans:
		print('YES')
	else:
		print('NO')


import itertools

def solve():
	(num_tiles, width) = [int(i) for i in input().split()]
	tiles = []
	for _ in range(num_tiles):
		(tiles_0, tiles_1) = [int(i) for i in input().split()]
		(tiles_2, tiles_3) = [int(i) for i in input().split()]
		tiles.append((tiles_0, tiles_1, tiles_2, tiles_3))
	if width % 2 != 0:
		print('NO')
		return
	for t in tiles:
		if t[1] == t[2]:
			for (a, b) in itertools.product(range(len(tiles)), repeat=2):
				tile_a = tiles[a]
				tile_b = tiles[b]
				if tile_a[0] == tile_b[0] and tile_a[1] == tile_b[2] and (tile_a[2] == tile_b[1]) and (tile_a[3] == tile_b[3]):
					print('YES')
					return
			break
	print('NO')
num_tests = int(input())
for _ in range(num_tests):
	solve()


import math
import itertools
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))
ans = 0
t = inp()
for _ in range(t):
	(n, m) = inlt()
	types = []
	b = 'NO'
	for i in range(n):
		a = inlt() + inlt()
		if a[1] == a[2]:
			b = 'YES'
		types += [a]
	if m % 2:
		b = 'NO'
	print(b)


def result(n):
	j = False
	i = 0
	while i < n:
		if a[2 * i][1] == a[2 * i + 1][0]:
			j = True
			break
		i += 1
	return j
t = int(input())
for inh in range(0, t):
	(n, m) = map(int, input().split())
	a = []
	for inhj in range(0, 2 * n):
		k = tuple(map(int, input().split()))
		a.append(k)
	if m % 2 != 0:
		print('NO')
	else:
		check = result(n)
		if check:
			print('YES')
		else:
			print('NO')


import sys
input = sys.stdin.readline
(T,) = map(int, input().split())
for _ in range(T):
	(N, M) = map(int, input().split())
	R = False
	for _ in range(N):
		(a, b) = map(int, input().split())
		(c, d) = map(int, input().split())
		if b == c:
			R = True
	if M % 2:
		R = False
	print('YES' if R else 'NO')


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, M, tiles):
	if M % 2 != 0:
		return 'NO'
	hasSymmetric = False
	for i in range(0, 2 * N, 2):
		(a, b) = tiles[i]
		(c, d) = tiles[i + 1]
		if b == c:
			hasSymmetric = True
	if hasSymmetric:
		return 'YES'
	return 'NO'
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N, M) = [int(x) for x in input().split()]
	tiles = [[int(x) for x in input().split()] for i in range(2 * N)]
	ans = solve(N, M, tiles)
	print(ans)


def isSymmetric(matrix):
	res = [[0, 0], [0, 0]]
	for i in range(2):
		for j in range(2):
			res[j][i] = matrix[i][j]
	if res == matrix:
		return True
	return False
t = int(input())
for j in range(t):
	matrix = []
	count = 0
	(n, m) = map(int, input().strip().split())
	for l in range(n):
		for i in range(2):
			x = []
			l = [int(k) for k in input().split()]
			x.append(l[0])
			x.append(l[1])
			matrix.append(x)
		if isSymmetric(matrix):
			count += 1
			matrix = []
		else:
			matrix = []
	if count > 0 and m % 2 == 0:
		print('YES')
	else:
		print('NO')


from math import ceil
for i in range(int(input())):
	(n, k) = map(int, input().split())
	t = 0
	for j in range(n):
		(p, q) = map(int, input().split())
		(r, s) = map(int, input().split())
		if q == r:
			t = 1
	if t and k % 2 == 0:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	if m % 2 == 0:
		flag1 = True
	else:
		flag1 = False
	flag2 = False
	for i in range(n):
		(l1, l2) = map(int, input().split())
		(l3, l4) = map(int, input().split())
		if flag2 == False and l2 == l3:
			flag2 = True
	if flag1 == True and flag2 == True:
		print('YES')
	else:
		print('NO')


t = int(input())
b = []
flag = False
for i in range(t):
	(n, m) = map(int, input().split())
	if m % 2 != 0:
		for j in range(n):
			(vl, vp) = map(int, input().split())
			(nl, np) = map(int, input().split())
		b.append('NO')
	else:
		for j in range(n):
			(vl, vp) = map(int, input().split())
			(nl, np) = map(int, input().split())
			if vp == nl:
				flag = True
		if flag == True:
			b.append('YES')
		else:
			b.append('NO')
	flag = False
for i in range(t):
	print(b[i])


for tc in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	isAble = False
	for i in range(n):
		(x1, y1) = [int(x) for x in input().split()]
		(x2, y2) = [int(x) for x in input().split()]
		if y1 == x2:
			isAble = True
	if m & 1:
		print('NO')
		continue
	print('YES' if isAble else 'NO')


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	x = False
	for i in range(n):
		(_, b) = map(int, input().split())
		(c, _) = map(int, input().split())
		if c == b:
			x = True
	print('YES' if x and m % 2 == 0 else 'NO')


for _ in range(int(input())):
	count1 = 0
	(n, m) = map(int, input().split())
	for i in range(n):
		(t1, t2) = map(int, input().split())
		(t3, t4) = map(int, input().split())
		if m == 2:
			if t2 == t3:
				count1 += 2
		elif t2 == t3:
			count1 += 2
	if m % 2 != 0:
		ans = 'NO'
	elif m % 2 == 0:
		if count1 > 0:
			ans = 'YES'
		else:
			ans = 'NO'
	print(ans)


import math
from collections import deque
from collections import defaultdict
t = int(input())
while t > 0:
	t -= 1
	(n, m) = map(int, input().strip().split(' '))
	arr = []
	for i in range(n):
		(x, y) = map(int, input().strip().split(' '))
		(a, b) = map(int, input().strip().split(' '))
		arr.append([[x, y], [a, b]])
	if m % 2 != 0:
		print('NO')
	else:
		if m == 2:
			found = False
			for i in range(n):
				if arr[i][0][1] == arr[i][1][0]:
					found = True
					break
		else:
			found = False
			for i in range(n):
				if arr[i][0][1] == arr[i][1][0]:
					found = True
					break
		if found:
			print('YES')
		else:
			print('NO')


for x in range(int(input())):
	cnt = 0
	(n, m) = map(int, input().split())
	for j in range(n):
		(x, y) = map(int, input().split())
		(p, q) = map(int, input().split())
		if y == p:
			cnt = 1
	if cnt == 1 and m % 2 == 0:
		print('YES')
	else:
		print('NO')