#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9;
bool operator==(vector<vector<int> > a, vector<vector<int> > b) {
  for (int i = 0; i < 20; ++i) {
    if (a[i].size() != b[i].size()) return false;
    for (int j = 0; j < a[i].size(); ++j)
      if (a[i][j] != b[i][j]) return false;
  }
  return true;
}
void XOR(vector<vector<int> > &a) {
  for (int i = 0; i < a.size(); ++i) {
    if (!a[i].size()) continue;
    int x = a[i][0];
    for (int j = 1; j < a[i].size(); ++j) x ^= a[i][j];
    a[i].clear();
    a[i].push_back(x);
  }
}
void refresh(vector<vector<int> > &a) {
  for (int i = 0; i < a.size(); ++i) {
    if (!a[i].size()) continue;
    int x = a[i][0];
    a[i].clear();
    a[__builtin_popcount(x)].push_back(x);
  }
}
void solve() {
  int n, m;
  cin >> n >> m;
  int a[2][2];
  bool f = false;
  while (n--) {
    for (int i = 0; i < 2; ++i)
      for (int j = 0; j < 2; ++j) cin >> a[i][j];
    if (a[0][1] == a[1][0]) {
      f = true;
    }
  }
  if (f && !(m & 1))
    cout << "YES\n";
  else
    cout << "NO\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
