Problem: Masha has n types of tiles of size 2 × 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 × 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 × 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 ≤ t ≤ 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 ≤ n ≤ 100, 1 ≤ m ≤ 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 × 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 × 4 which is a symmetric matrix:

<image>

Solution (in PYTHON3):

Solution:
#codeforces div-2 round 668


'''for i in range(int(input())):
    n=int(input())
    arr=[int(i) for i in input().split()]
    print(*arr[::-1])'''


'''for i in range(int(input())):
    n=int(input())
    arr=[int(i) for i in input().split()]
    run=0
    for i in range(n-1,-1,-1):
        if arr[i]<0:
            run+=arr[i]
        else:
            if run<0:
                temp=arr[i]
                arr[i]=max(0,arr[i]+run)
                run=min(0,temp+run)
    res=0
    for i in range(n):
        res+=arr[i] if arr[i]>0 else 0
    print(res)'''

"""for i in range(int(input())):
    n,k=[int(i) for i in input().split()]
    s=intput()"""

#Codechef long challenge
'''from collections import defaultdict
for i in range(int(input())):
    n=int(input())
    arr=[int(i) for i in input().split()]
    cnt=defaultdict(int)
    for i in range(n):
        cnt[arr[i]]+=1
    print(len(cnt))'''

#Codeforces round 669 div-02

'''for i in range(int(input())):
    n=int(input())
    arr=[int(i) for i in input().split()]
    ones=0
    for i in range(n):
        if arr[i]==1:
            ones+=1
    if ones<=n//2:
        print(n-ones)
        print(*[0 for j in range(n-ones)])
    elif ones%2:
        print(ones-1)
        print(*[1 for j in range(ones-1)])
    else:
        print(ones)
        print(*[1 for j in range(ones)])'''
    

'''def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
for i in range(int(input())):
    n=int(input())
    arr=[int(i) for i in input().split()]

    k=max(arr)
    imp=[]
    run=k
    arr0=arr[:]
    for j in range(n):
        for i in range(len(arr0)):


    for i in range(n):
        imp.append((gcd(k,arr[i]),arr[i]))
    print(imp)
    imp.sort(key=lambda x:x[0],reverse=True)
    res=[]
    for i in imp:
        res.append(i[1])
    print(*res)'''

#Codeforces round 670 DIV-02
'''from collections import defaultdict
for i in range(int(input())):
    n=int(input())
    arr=[int(i) for i in input().split()]
    cnt=defaultdict(int)
    for i in arr:
        cnt[i]+=1
    first=0
    second=0
    tot=0
    for j in range(0,max(arr)+2):
        if cnt[j]==0:
            first=j
            break
    
    res=0
    for t in range(0,max(arr)+2):
        if cnt[t]==1 or cnt[t]==0:
            second=t
            break
    print(first+second)'''


'''for i in range(int(input())):
    n=int(input())
    arr=[int(i) for i in input().split()]
    arr.sort()
    pre=[arr[0] for i in range(len(arr))]
    suff=[arr[-1] for i in range(len(arr))]
    for i in range(1,n):
        pre[i]=pre[i-1]*arr[i]
    for j in range(n-2,-1,-1):
        suff[j]=suff[j+1]*arr[j]
    res=float("-inf")
    if n>=5:
        res=max(res,pre[1]*suff[-3],pre[3]*suff[-1],suff[-5])
    print(res)

    pos=[]
    zero=0
    neg=[]
    res=0
    for i in range(n):
        if arr[i]>0:
            pos.append(arr[i])
        elif arr[i]==0:
            zero+=1
        else:
            neg.append(arr[i])
    pos.sort(reverse=True)
    neg.sort()
    pos_pro=[pos[0] for i in range(len(pos))]
    neg_pro=[neg[0] for i in range(len(neg))]
    if len(pos)>1:
        for k in range(1,len(pos)):
            pos_pro[k]=pos_pro[k-1]*pos[k]
    if len(neg)>1:
        for k in range(1,len(neg)):
            neg_pro[k]=neg_pro[k-1]*neg[k]

    if len(pos)>=5:
        if len(neg)>=4:
            res=max(res,pos_pro[4],pos_pro[2]*neg_pro[1],pos_pro[0]*neg_pro[3])
        elif len(neg)>=2 and len(neg)<4:
            res=max(res,pos_pro[4],pos_pro[2]*neg_pro[1])
        else:
            res=pos_pro[4]
        print(res)
    
    else:
        if len(neg)>=2 and len(neg)<4:
            if len(pos)<3:
                res=0 
            else:
                res=max(res,neg_pro[1]*pos_pro[2])
        elif len(neg)>=4:
            if len(pos)>=1:
                res=max(res,neg_pro[3]*pos_pro[0])
            else:
                res=0 if zero else neg_pro[-1]

        print(res)'''
        



#Codeforces educational round


'''for i in range(int(input())):
    x,y,k=[int(i) for i in input().split()]
    sticks=k*(y+1)-1
    if sticks%(x-1):
        temp=sticks//(x-1)+1
    else:
        temp=sticks//(x-1)
    
    print(temp +k )'''


'''for i in range(int(input())):
    n=int(input())
    arr=[int(i) for i in input().split()]
    lock=[int(i) for i in input().split()]

    neg=[]
    for i in range(n):
        if lock[i]==0:
            neg.append(arr[i])
    neg.sort(reverse=True)
    j=0
    for i in range(len(arr)):
        if lock[i]==0:
            arr[i]=neg[j]
            j+=1
    print(*arr)'''

'''for _ in range(int(input())):
    n=int(input())
    arr=[int(i) for i in input().split()]
    if n==1:
        print(arr[0])
    else:

        dp=[[0,0] for i in range(n)]
        dp[-1]=[arr[-1],0]
        dp[-2]=[arr[-2],0]
        for k in range(n-3,-1,-1):
            dp[k][0]=arr[k]+dp[k+1][1]
            if arr[k]+arr[k+1]+dp[k+2][1]<dp[k][0]:
                dp[k][0]=arr[k]+arr[k+1]+dp[k+2][1]
            dp[k][1]=min(dp[k+1][0],dp[k+2][0])

        print(dp[0][0])
'''
#Codeforces round 673

'''for i in range(int(input())):
    n,k=[int(i) for i in input().split()]
    arr=[int(i) for i in input().split()]

    res=0
    flag=0

    temp=min(arr)
    app=0
    for i in range(n):
        if arr[i]==temp and not app:
            app=1
            continue
        elif arr[i]==temp and app:
            res+=(k-arr[i])//temp
        else:
            res+=(k-arr[i])//temp

    print(res)'''
'''from collections import defaultdict
for i in range(int(input())):
    n,t=[int(i) for i in input().split()]
    app=defaultdict(lambda:-1)
    arr=[int(i) for i in input().split()]
    ans=[0 for i in range(n)]

    for i in range(n):
        if arr[i]>t:
            continue
        elif app[t-arr[i]]!=-1:
            ans[i]=ans[app[t-arr[i]]]^1
            app[arr[i]]=i
        else:
            app[arr[i]]=i

    print(*ans)'''

'''for i in range(int(input())):
    n=int(input())
    arr=[int(i) for i in input().split()]

    where={}

    for i in range(n):
        if arr[i] in where:
            where[arr[i]].append(i)
        else:
            where[arr[i]]=[i]

    ans=[-1 for i in range(n)]
    last=0
    for k in range(1,n+1):
        if k not in where:
            continue
        else:
            res=0
            for t in range(1,len(where[k])):
                res=max(res,where[k][t]-where[k][t-1])
            res=max(res,where[k][0]+1,n-where[k][-1]) 

            if res>0 and ans[res-1]==-1:
                ans[res-1]=k

    mn=-1
    for i in range(n):
        if ans[i]!=-1 and mn<ans[i]:
            ans[i]=mn
        elif ans[i]==-1:
            ans[i]=mn
        else:
            mn=min(mn if mn!=-1 else float("inf"),ans[i])
        print(ans[i],end=" ")'''

#Codeforces round 674 DIV-3

'''for i in range(int(input())):
    n,x=[int(i) for i in input().split()]
    if n<3:
        print(1)
    else:
        temp=(n-2)//x
        temp+=1 if (n-2)%x!=0 else 0
        print(1+temp)'''

    
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")