#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m, l, r;
  cin >> n >> m;
  vector<vector<int>> v;
  vector<int> a;
  for (int i = 0; i < 2 * n; i++) {
    cin >> l >> r;
    a.push_back(l);
    a.push_back(r);
    v.push_back(a);
    a.clear();
  }
  if (m % 2 != 0)
    cout << "NO" << endl;
  else {
    bool flag = false;
    for (int i = 0; i < 2 * n; i = i + 2) {
      if (v[i][1] == v[i + 1][0]) {
        flag = true;
        break;
      }
    }
    cout << (flag == true ? "YES" : "NO") << endl;
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
