#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, m;
    cin >> n >> m;
    long long int d = 2 * n;
    long long int a[d + 1];
    long long int b[d + 1];
    long long int temp = 0;
    for (long long int i = 0; i < d; i++) {
      cin >> a[i] >> b[i];
      if ((i % 2) != 0) {
        if ((a[i] == b[i - 1])) temp++;
      }
    }
    if (temp == 0 || ((m % 2) == 1))
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
}
