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 JAVA):

Solution:
import java.io.*;
import java.math.*;
import java.util.*;

/**
 *
 * @author Saju
 *
 */




public class Main {

    private static int dx[] = { 1, 0, -1, 0 };
    private static int dy[] = { 0, -1, 0, 1 };
    
    private static int dx1[] = { 1, 1, 0, -1, -1, -1, 0, 1 };
    private static int dy1[] = { 0, -1, -1, -1, 0, 1, 1, 1 };

    private static final long INF = (long) Math.pow(10, 16);
    private static final int INT_INF = Integer.MAX_VALUE;
    private static final long NEG_INF = Long.MIN_VALUE;
    private static final int NEG_INT_INF = Integer.MIN_VALUE;
    private static final double EPSILON = 1e-10;

    private static final long MAX = (long) 1e12;
    
    private static final long MOD = 1000000007;

    private static final int MAXN = 200001;
    private static final int MAXA = 1000004;
    private static final int MAXLOG = 22;
    private static final double PI = Math.acos(-1);
    
    public static void main(String[] args) throws IOException {

        InputReader in = new InputReader(System.in);
//        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

//         InputReader in = new InputReader(new FileInputStream("src/test.in"));
//         PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("src/test.out")));

        
        
/*




*/        
        
        
        int test = in.nextInt();
		for (int t = 1; t <= test; t++) {
			int n = in.nextInt();
			int m = in.nextInt();
			
			int[][] tiles = new int[2 * n][2];
			
			for(int i = 0; i < n; i++) {
				tiles[2 * i][0] = in.nextInt();
				tiles[2 * i][1] = in.nextInt();
				tiles[2 * i + 1][0] = in.nextInt();
				tiles[2 * i + 1][1] = in.nextInt();
			}
			
			if(m % 2 != 0) {
				out.println("NO");
				continue;
			}
			if(hasSymmetric(n, tiles)) {
				out.println("YES");
			}
			else {
				out.println("NO");
			}
			
		}
        
        
        in.close();
        out.flush();
        out.close();
        System.exit(0);
    }
    

	





	private static boolean hasSymmetric(int n, int[][] tiles) {
		
		for(int i = 0; i < n; i++) {
			int a = tiles[2 * i][0];
			int b = tiles[2 * i][1];
			int c = tiles[2 * i + 1][0];
			int d = tiles[2 * i + 1][1];
			
			if(b == c) {
				return true;
			}
			
		}
		
		return false;
	}








	/*
     * return the number of elements in list that are less than or equal to the val
     */
    private static long upperBound(List<Long> list, long val) {
        int start = 0;
        int len = list.size();
        int end = len - 1;
        int mid = 0;

        while (true) {
            if (start > end) {
                break;
            }
            mid = (start + end) >> 1;
            long v = list.get(mid);
            if (v == val) {
                start = mid;
                while(start < end) {
                    mid = (start + end) >> 1;
                    if(list.get(mid) == val) {
                        if(mid + 1 < len && list.get(mid + 1) == val) {
                            start = mid + 1;
                        }
                        else {
                            return mid + 1;
                        }
                    }
                    else {
                        end = mid - 1;
                    }
                }
                return start + 1;
            }
            if (v > val) {
                end = mid - 1;
            } else {
                start = mid + 1;
            }
        }
        if (list.get(mid) < val) {
            return mid + 1;
        }
        return mid;
    }


    private static boolean isPalindrome(String str) {
        StringBuilder sb = new StringBuilder();
        sb.append(str);
        String str1 = sb.reverse().toString();
        return str.equals(str1);
    }

    private static String getBinaryStr(long n, int j) {
        String str = Long.toBinaryString(n);
        int k = str.length();
        for (int i = 1; i <= j - k; i++) {
            str = "0" + str;
        }

        return str;
    }
    
    private static long modInverse(long r) {
        return bigMod(r, MOD - 2, MOD);
    }
    
    private static long bigMod(long n, long k, long m) {

        long ans = 1;
        while (k > 0) {
            if ((k & 1) == 1) {
                ans = (ans * n) % m;
            }
            n = (n * n) % m;
            k >>= 1;
        }
        return ans;
    }
    
    private static long ceil(long n, long x) {
        long div = n / x;
        if(div * x != n) {
            div++;
        }
        return div;
    }
    
    private static int ceil(int n, int x) {
        int div = n / x;
        if(div * x != n) {
            div++;
        }
        return div;
    }

    
    private static int abs(int x) {
        if (x < 0) {
            return -x;
        }
        return x;
    }
    
    private static double abs(double x) {
        if (x < 0) {
            return -x;
        }
        return x;
    }

    private static long abs(long x) {
        if(x < 0) {
            return -x;
        }
        return x;
    }
    
    private static long lcm(long a, long b) {
        return (a * b) / gcd(a, b);
    }

    private static int lcm(int a, int b) {
        return (a * b) / gcd(a, b);
    }

    private static int gcd(int a, int b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }
    
    private static long gcd(long a, long b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    private static int log(long x, int base) {
        return (int) (Math.log(x) / Math.log(base));
    }

    private static int log(long x, long base) {
        return (int) (Math.log(x) / Math.log(base));
    }
    
    private static long min(long a, long b) {
        if (a < b) {
            return a;
        }
        return b;
    }

    private static int min(int a, int b) {
        if (a < b) {
            return a;
        }
        return b;
    }

    private static long max(long a, long b) {
        if (a < b) {
            return b;
        }
        return a;
    }

    private static int max(int a, int b) {
        if (a < b) {
            return b;
        }
        return a;
    }

    private static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public List<Integer> nextList(int n) {
            List<Integer> list = new ArrayList<>();
            for(int i = 0; i < n; i++) {
                list.add(nextInt());
            }
            return list;
        }
        
        public List<Long> nextLongList(int n) {
            List<Long> list = new ArrayList<>();
            for(int i = 0; i < n; i++) {
                list.add(nextLong());
            }
            return list;
        }

        public String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());

                }
            } catch (IOException e) {
                return null;
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            String line = null;
            try {
                tokenizer = null;
                line = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public boolean hasNext() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        
        public int[] nextIntArr(int n) {
            int arr[] = new int[n];
            for(int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }
        
        public long[] nextLongArr(int n) {
            long arr[] = new long[n];
            for(int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
        
        public int[] nextIntArr1(int n) {
            int arr[] = new int[n + 1];
            for(int i = 1; i <= n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }
        
        public long[] nextLongArr1(int n) {
            long arr[] = new long[n + 1];
            for(int i = 1; i <= n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
       
        public void close() {
            try {
                if(reader != null) {
                    reader.close();
                }
            }
            catch(Exception e) {
                
            }
            
            
        }
    }

}