#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
void solve() {
  int n, m;
  cin >> n >> m;
  map<vector<int>, int> tiles;
  for (int i = 0; i < n; i++) {
    vector<int> temp;
    for (int j = 0; j < 4; j++) {
      int a;
      cin >> a;
      temp.push_back(a);
    }
    tiles[temp]++;
  }
  if (m & 1) {
    cout << "NO\n";
    return;
  }
  for (auto &i : tiles) {
    if (i.first[1] == i.first[2]) {
      cout << "YES\n";
      return;
    }
  }
  cout << "NO\n";
}
int main() {
  fast();
  int t;
  cin >> t;
  while (t--) solve();
}
