#include <bits/stdc++.h>
using namespace std;
int fun(int n, int m, vector<vector<int> >& a) {
  if (m % 2) return 0;
  for (int i = 0; i < a.size(); i += 2) {
    if (a[i][1] == a[i + 1][0]) return 1;
  }
  return 0;
}
int main() {
  int t, n, m;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    vector<vector<int> > a(2 * n, vector<int>(2, 0));
    for (int i = 0; i < a.size(); i++) cin >> a[i][0] >> a[i][1];
    if (fun(n, m, a))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
