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