#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    bool go = false;
    for (int i = 0; i < n; i++) {
      int array[2][2];
      for (int j = 0; j < 2; j++) {
        for (int k = 0; k < 2; k++) {
          cin >> array[j][k];
        }
      }
      if (array[0][1] == array[1][0]) {
        go = true;
      }
    }
    if (m % 2 != 0) {
      cout << "NO\n";
      continue;
    }
    if (go) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
}
