#include <bits/stdc++.h>
using namespace std;
int vet[100111], k, cor[100111];
vector<int> tile[1001];
int main() {
  int t, n, a, b, c, d;
  scanf("%d", &t);
  for (int i = 0; i < t; ++i) {
    scanf("%d %d", &n, &k);
    for (int j = 0; j < n; ++j) {
      scanf("%d %d %d %d", &a, &b, &c, &d);
      tile[j].clear();
      tile[j].push_back(a);
      tile[j].push_back(b);
      tile[j].push_back(c);
      tile[j].push_back(d);
    }
    bool has1 = false;
    for (int j = 0; j < n; ++j) {
      if (tile[j][1] == tile[j][2]) {
        has1 = true;
        break;
      }
    }
    if (has1 and k % 2 == 0) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }
  return 0;
}
