#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    int flag = 0;
    while (n--) {
      int a, b, c, d;
      cin >> a >> b >> c >> d;
      if (c == b) flag = 1;
    }
    if (k % 2 == 0) {
      if (k == 2) {
        if (flag)
          cout << "YES\n";
        else
          cout << "NO\n";
      } else {
        if (flag)
          cout << "YES\n";
        else
          cout << "NO\n";
      }
    } else
      cout << "NO\n";
  }
  return 0;
}
