#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m, i, c = 0;
    cin >> n >> m;
    int a[2 * n], b[2 * n];
    for (i = 1; i <= 2 * n; i++) {
      cin >> a[i];
      cin >> b[i];
    }
    if (m % 2 != 0) {
      cout << "NO\n";
    } else {
      for (i = 1; i <= 2 * n; i = i + 2) {
        if (b[i] == a[i + 1]) {
          c++;
        }
      }
      if (c > 0) {
        cout << "YES\n";
      } else {
        cout << "NO\n";
      }
    }
  }
  return 0;
}
