#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k;
  cin >> n >> k;
  bool f = 0;
  while (n--) {
    long long arr[4];
    for (long long i = 0; i < (4); ++i) cin >> arr[i];
    if (arr[1] == arr[2]) f = 1;
  }
  if (!f || k % 2 != 0)
    cout << "NO";
  else
    cout << "YES";
  cout << "\n";
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) solve();
}
