#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long hell = round(1e18);
long long check1(
    vector<pair<pair<long long, long long>, pair<long long, long long>>>& v,
    long long n) {
  for (long long i = 0; i < n; i++) {
    if (v[i].first.second == v[i].second.first) return 1;
  }
  return 0;
}
long long check2(
    vector<pair<pair<long long, long long>, pair<long long, long long>>>& v,
    long long n) {
  for (long long i = 0; i < n; i++) {
    for (long long j = i; j < n; j++) {
      if (v[i].first.second =
              v[j].second.first && v[i].second.first == v[j].first.second)
        return 1;
    }
  }
  return 0;
}
signed solve() {
  long long n, m;
  cin >> n >> m;
  vector<pair<pair<long long, long long>, pair<long long, long long>>> v(n);
  for (long long i = 0; i < n; i++)
    cin >> ((v[i].first).first) >> ((v[i].first).second) >>
        ((v[i].second).first) >> ((v[i].second).second);
  if (m % 2) {
    cout << ("NO");
    cout << ("\n");
    return 0;
  }
  long long a = check1(v, n);
  if (a == 1 && m == 2) {
    cout << ("YES");
    cout << ("\n");
    return 0;
  }
  long long b = check2(v, n);
  if (a & b) {
    cout << ("YES");
    cout << ("\n");
    return 0;
  }
  cout << ("NO");
  cout << ("\n");
  return 0;
}
signed main() {
  long long t = 1;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
