#include <bits/stdc++.h>
using namespace std;
const int L = 2;
int main() {
  int N;
  cin >> N;
  int Matric[2][2];
  while (N) {
    bool flag = false;
    int n, m;
    cin >> n >> m;
    while (n) {
      for (int i = 0; i < L; i++) {
        for (int j = 0; j < L; j++) {
          cin >> Matric[i][j];
        }
      }
      if (Matric[0][1] == Matric[1][0]) {
        flag = true;
      }
      n--;
    }
    if (flag && m % 2 == 0) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
    N--;
  }
  return 0;
}
