#include <bits/stdc++.h>
const int N = 1e5 + 5;
const long double pi = 3.141592653;
const long long MOD = 1e9 + 7;
const long long mod = 998244353;
const long long INF = 9223372036854775807LL;
using namespace std;
int dx[9] = {1, -1, 0, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 0, 1, -1, 1, -1, 1, -1, 0};
int ma[105][2][2];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  cin >> T;
  while (T--) {
    int n, m, i, j;
    cin >> n >> m;
    bool yes = false;
    for (i = 1; i <= n; i++) {
      cin >> ma[i][0][0] >> ma[i][0][1] >> ma[i][1][0] >> ma[i][1][1];
      if (ma[i][1][0] == ma[i][0][1]) yes = true;
    }
    bool ok = true;
    if (m % 2 != 0)
      ok = false;
    else {
      if (!yes) ok = false;
    }
    if (ok)
      cout << "YES";
    else
      cout << "NO";
    cout << "\n";
  }
  return 0;
}
