#include <bits/stdc++.h>
using namespace std;
using llong = long long;
const int N = 2e6;
const int BIN_EPS = 10;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<vector<vector<int> > > arr(n,
                                      vector<vector<int> >(2, vector<int>(2)));
    int mark = 0;
    for (auto &x : arr) {
      cin >> x[0][0] >> x[0][1] >> x[1][0] >> x[1][1];
      if (x[0][1] != x[1][0]) {
        ++mark;
      }
    }
    if (mark == n || !(m >= 2 && m % 2 == 0)) {
      cout << "NO\n";
    } else {
      cout << "YES\n";
    }
  }
  return 0;
}
