#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7, Base = 998244353;
const long long N = 6e5 + 7;
const long long INF = 1LL * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7LL;
const double pie = acos(-1.0);
long long x, y, n, test, m;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> test;
  while (test--) {
    cin >> n >> m;
    long long type[5], valid = 0;
    for (long long i = 1; i <= n; ++i) {
      for (long long j = 1; j <= 4; ++j) cin >> type[j];
      if (type[2] == type[3]) valid = 1;
    }
    if (valid) {
      if (m % 2)
        cout << "NO\n";
      else
        cout << "YES\n";
    } else
      cout << "NO\n";
  }
  return 0;
}
