#include <bits/stdc++.h>
struct kuai {
  int x, y;
  int z, o;
};
int main() {
  int n;
  scanf("%d", &n);
  int i = 0;
  int m, k;
  for (i = 0; i < n; i++) {
    scanf("%d %d", &m, &k);
    int flag = 0;
    struct kuai stu[10000];
    int j = 0, h = 0;
    for (j = 0; j < m; j++) {
      scanf("%d %d %d %d", &stu[j].x, &stu[j].y, &stu[j].z, &stu[j].o);
    }
    for (j = 0; j < m; j++) {
      for (h = j; h < m; h++) {
        if (k % 2 == 0 && stu[h].y == stu[h].z && stu[j].x == stu[h].x &&
            stu[j].y == stu[h].z && stu[j].z == stu[h].y &&
            stu[j].o == stu[h].o) {
          flag = 1;
        }
      }
    }
    if (flag == 1)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
