#include <bits/stdc++.h>
using namespace std;
int t, n, y, m, ar[220][2];
int ans;
int main() {
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (int i = 0; i < 2 * n; i++)
      for (int j = 0; j < 2; j++) cin >> ar[i][j];
    y = 1;
    if (m % 2 == 1) {
      cout << "NO" << endl;
      continue;
    } else {
      for (int i = 0; i < 2 * n; i += 2)
        if (ar[i][1] == ar[i + 1][0]) {
          cout << "YES" << endl;
          y = 0;
          break;
        }
      if (y == 1) cout << "NO" << endl;
    }
  }
  return 0;
}
