#include <bits/stdc++.h>
int main(void) {
  int num;
  std::cin >> num;
  bool flag;
  int size;
  int tiles;
  int dim1;
  int dim2;
  int dim3;
  int dim4;
  for (int i = 0; i < num; i++) {
    flag = false;
    std::cin >> tiles >> size;
    for (int j = 0; j < tiles; j++) {
      std::cin >> dim1 >> dim2;
      std::cin >> dim3 >> dim4;
      if (dim2 == dim3) {
        flag = true;
      }
    }
    if ((flag == true) && (size % 2 == 0)) {
      std::cout << "YES\n";
    } else {
      std::cout << "NO\n";
    }
  }
}
