#include <bits/stdc++.h>
using namespace std;
int main() {
  int num;
  cin >> num;
  int kind_num;
  int useless;
  bool flag;
  while (num--) {
    flag = false;
    cin >> kind_num >> useless;
    const int kind = kind_num;
    int array[kind][2][2];
    for (int i = 0; i < kind_num; i++) {
      cin >> array[i][0][0] >> array[i][0][1] >> array[i][1][0] >>
          array[i][1][1];
    }
    for (int i = 0; i < kind_num; i++) {
      if (array[i][0][1] == array[i][1][0]) {
        flag = true;
        break;
      }
    }
    if (flag && useless % 2 == 0) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
