#include <bits/stdc++.h>
using namespace std;
void solve(void) {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long> > v(n, vector<long long>(4));
  for (long long i = 0; i < n; ++i)
    cin >> v[i][0] >> v[i][1] >> v[i][2] >> v[i][3];
  if (m & 1) {
    cout << "NO" << endl;
    return;
  }
  for (auto it : v) {
    if (it[1] == it[2]) {
      cout << "YES\n";
      return;
    }
  }
  cout << "NO\n";
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) solve();
}
