#include <bits/stdc++.h>
using namespace std;
const int N = 1e3;
long long n;
map<pair<pair<long long, long long>, pair<long long, long long>>, bool> q;
long long mx = 0;
int main() {
  cin >> n;
  long long x, y;
  long long a, b, c, d;
  for (int i = 0; i < n; ++i) {
    q.clear();
    cin >> x >> y;
    bool f1 = false;
    bool f2 = false;
    for (int j = 0; j < x; ++j) {
      cin >> a >> b >> c >> d;
      q[{{a, b}, {c, d}}] = true;
      if (b == c) f1 = true;
      if (q.find({{a, c}, {b, d}}) != q.end()) f2 = true;
    }
    if (y % 2 == 1) {
      cout << "NO\n";
      continue;
    }
    if (f1 && f2)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
