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