#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
char buf[1 << 22], *_p1 = buf, *_p2 = buf;
inline long long fr() {
  register char c =
      (_p1 == _p2 &&
               (_p2 = (_p1 = buf) + fread(buf, 1, 1 << 22, stdin), _p1 == _p2)
           ? EOF
           : *_p1++);
  register long long r = 0;
  register int b = 0;
  while (!isdigit(c))
    b = (c == '-'),
    c = (_p1 == _p2 &&
                 (_p2 = (_p1 = buf) + fread(buf, 1, 1 << 22, stdin), _p1 == _p2)
             ? EOF
             : *_p1++);
  while (isdigit(c))
    r = r * 10 + c - '0',
    c = (_p1 == _p2 &&
                 (_p2 = (_p1 = buf) + fread(buf, 1, 1 << 22, stdin), _p1 == _p2)
             ? EOF
             : *_p1++);
  return b ? -r : r;
}
inline void prc() {
  register int n = fr(), m = fr();
  int b = 0;
  if (m & 1) {
    for (register int i = 1; i <= n; ++i) {
      int t1 = fr(), t2 = fr(), t3 = fr(), t4 = fr();
    }
    cout << "NO\n";
    return;
  }
  for (register int i = 1; i <= n; ++i) {
    int t1 = fr(), t2 = fr(), t3 = fr(), t4 = fr();
    if (t2 == t3) b = 1;
  }
  if (b)
    cout << "YES\n";
  else
    cout << "NO\n";
}
signed main() {
  int T = fr();
  while (T--) prc();
  return 0;
}
