#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n;
  cin >> n;
  int a, b;
  while (n--) {
    cin >> a >> b;
    int x, y;
    int d = 0;
    vector<vector<int>> p(a * 2, vector<int>(2));
    for (int i = 0; i < a * 2; i++) {
      for (int j = 0; j < 2; j++) {
        cin >> p[i][j];
        if (((i + 1) % 2 == 0) && (i > 0)) {
          x = p[i - 1][1];
          y = p[i][0];
          if (x == y) d++;
        }
      }
    }
    if (b % 2 != 0) {
      cout << "NO" << endl;
      continue;
    }
    if (d)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
