#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m, c = 0;
    cin >> n >> m;
    int x, y;
    vector<pair<int, int> > V;
    for (int i = 0; i < 2 * n; i++) {
      cin >> x >> y;
      V.push_back(make_pair(x, y));
    }
    if (m & 1)
      cout << "NO" << endl;
    else {
      for (int j = 0; j < 2 * n; j += 2) {
        if (V[j].second == V[j + 1].first) c++;
      }
      if (c != 0)
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
    V.clear();
  }
}
