#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, m;
    cin >> n >> m;
    long long int a[2][2];
    long long int f = 0;
    while (n--) {
      for (long long int i = 0; i < 2; i++) {
        for (long long int j = 0; j < 2; j++) {
          cin >> a[i][j];
        }
      }
      if (a[0][1] == a[1][0]) {
        f = 1;
      }
    }
    if (f == 1 && m % 2 == 0) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}
