#include <bits/stdc++.h>
using namespace std;
int main() {
  long long r, x, g, h, i, n, j, t, e, a, b, k, c, l, d, f, z = 0;
  cin >> t;
  while (t--) {
    z = 0;
    cin >> n >> k;
    long long m[n][2][2];
    for (i = 0; i < n; i++) {
      for (j = 0; j < 2; j++) {
        for (x = 0; x < 2; x++) {
          cin >> m[i][j][x];
        }
      }
    }
    a = 0;
    b = 0;
    l = 0;
    for (i = 0; i < n; i++) {
      if (m[i][0][1] == m[i][1][0]) z++;
      for (j = 0; j < n; j++) {
        if (m[i][0][0] == m[j][0][0] && (m[i][0][1] == m[j][1][0]) &&
            (m[i][1][0] == m[j][0][1]) && (m[i][1][1] == m[j][1][1]))
          l++;
      }
    }
    if (k & 1 || z == 0 || l == 0)
      cout << "NO\n";
    else {
      cout << "YES\n";
    }
  }
}
