Problem: Masha has n types of tiles of size 2 × 2. Each cell of the tile contains one integer. Masha has an infinite number of tiles of each type.

Masha decides to construct the square of size m × m consisting of the given tiles. This square also has to be a symmetric with respect to the main diagonal matrix, and each cell of this square has to be covered with exactly one tile cell, and also sides of tiles should be parallel to the sides of the square. All placed tiles cannot intersect with each other. Also, each tile should lie inside the square. See the picture in Notes section for better understanding.

Symmetric with respect to the main diagonal matrix is such a square s that for each pair (i, j) the condition s[i][j] = s[j][i] holds. I.e. it is true that the element written in the i-row and j-th column equals to the element written in the j-th row and i-th column.

Your task is to determine if Masha can construct a square of size m × m which is a symmetric matrix and consists of tiles she has. Masha can use any number of tiles of each type she has to construct the square. Note that she can not rotate tiles, she can only place them in the orientation they have in the input.

You have to answer t independent test cases.

Input

The first line of the input contains one integer t (1 ≤ t ≤ 100) — the number of test cases. Then t test cases follow.

The first line of the test case contains two integers n and m (1 ≤ n ≤ 100, 1 ≤ m ≤ 100) — the number of types of tiles and the size of the square Masha wants to construct.

The next 2n lines of the test case contain descriptions of tiles types. Types of tiles are written one after another, each type is written on two lines. 

The first line of the description contains two positive (greater than zero) integers not exceeding 100 — the number written in the top left corner of the tile and the number written in the top right corner of the tile of the current type. The second line of the description contains two positive (greater than zero) integers not exceeding 100 — the number written in the bottom left corner of the tile and the number written in the bottom right corner of the tile of the current type.

It is forbidden to rotate tiles, it is only allowed to place them in the orientation they have in the input.

Output

For each test case print the answer: "YES" (without quotes) if Masha can construct the square of size m × m which is a symmetric matrix. Otherwise, print "NO" (withtout quotes).

Example

Input


6
3 4
1 2
5 6
5 7
7 4
8 9
9 8
2 5
1 1
1 1
2 2
2 2
1 100
10 10
10 10
1 2
4 5
8 4
2 2
1 1
1 1
1 2
3 4
1 2
1 1
1 1


Output


YES
NO
YES
NO
YES
YES

Note

The first test case of the input has three types of tiles, they are shown on the picture below.

<image>

Masha can construct, for example, the following square of size 4 × 4 which is a symmetric matrix:

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using ii = pair<int, int>;
using tpl = tuple<int, int, int>;
inline bool read(char &);
inline bool read(char *);
template <class T>
inline bool read(T &);
template <class H, class... T>
inline bool read(H &, T &...);
inline void write(char);
inline void write(char *);
inline void write(const char *);
template <class H, class... T>
inline void write(H, T...);
template <class T>
inline void write(T);
template <class T>
inline T gcd(T, T);
template <class T>
inline T lcm(T, T);
template <class T>
inline T power(T, T);
template <class T>
inline T MulL(T, T, T);
template <class T>
inline T power(T, T, T);
template <class T>
inline T powerL(T, T, T);
template <class T>
inline void in(T *, size_t);
template <class T>
inline void in(vector<T> &, size_t);
template <class T>
inline void out(T *, size_t);
template <class T>
inline void out(vector<T> &, size_t);
const int dx[] = {1, -1, 0, 0, -1, 1, -1, 1},
          dy[] = {0, 0, -1, 1, 1, 1, -1, -1};
const int kx[] = {-2, -1, 1, 2, 2, 1, -1, -2},
          ky[] = {1, 2, 2, 1, -1, -2, -2, -1};
const int MODF = 998244353;
const int MOD7 = 1000000007;
const int MOD9 = 1000000009;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x7f7f7f7f7f7f7f;
const long double EPS = 1e-9;
const long double ONE = ld(1);
const long double PI = acos(-ONE);
const int M = MOD7;
const int mx = 1e6 + 10;
char s[mx];
int n, m, a[mx];
int b[101][2][2];
bool can(int x, int y) {
  int c[4][4];
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 4; j++) {
      if (i < 2) {
        if (j < 2)
          c[i][j] = b[x][i][j];
        else
          c[i][j] = b[y][i][j - 2];
      } else {
        if (j < 2)
          c[i][j] = b[y][i - 2][j];
        else
          c[i][j] = b[x][i - 2][j - 2];
      }
    }
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 4; j++)
      if (c[i][j] != c[j][i]) return false;
  return true;
}
inline void MAIN(int cs) {
  read(n, m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) in(b[i][j], 2);
  }
  if (m & 1)
    puts("NO");
  else {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        if (can(i, j)) {
          puts("YES");
          return;
        }
    puts("NO");
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(20);
  srand(time(nullptr));
  int tc = 1;
  read(tc);
  for (register int cs = 1; cs < tc + 1; cs++) MAIN(cs);
  return 0;
}
char os[25];
template <class T>
inline void in(T *a, size_t n) {
  for (register int i = 0; i < n; i++) read(a[i]);
}
template <class T>
inline void in(vector<T> &a, size_t n) {
  for (register int i = 0; i < n; i++) read(a[i]);
}
template <class T>
inline void out(T *a, size_t n) {
  for (register int i = 0; i < n; i++) write(a[i], (i + 1 == n) ? '\n' : ' ');
}
template <class T>
inline void out(vector<T> &a, size_t n) {
  for (register int i = 0; i < n; i++) write(a[i], (i + 1 == n) ? '\n' : ' ');
}
inline void write(char c) { putchar(c); }
inline void write(char *s) { printf("%s", s); }
inline void write(const char *s) { printf("%s", s); }
template <class H, class... T>
inline void write(H h, T... t) {
  write(h);
  write(t...);
}
template <class T>
inline void write(T x) {
  if (x == 0) {
    putchar('0');
    return;
  }
  int i = 0;
  bool neg = (x < 0);
  if (neg) putchar('-'), x = -x;
  while (x > 0) {
    os[i++] = (x % 10) + '0';
    x /= 10;
  }
  i--;
  while (i >= 0) putchar(os[i--]);
}
inline bool read(char &c) {
  c = getchar();
  return c != EOF;
}
inline bool read(char *s) { return scanf("%s", s); }
template <class H, class... T>
inline bool read(H &h, T &...t) {
  return read(h) && read(t...);
}
template <class T>
inline bool read(T &val) {
  val = 0;
  bool neg = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      neg = 1;
    else if (ch == EOF)
      return 0;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    val = (val * 10) + (ch - '0');
    ch = getchar();
  }
  if (neg) val = -val;
  return 1;
}
template <class T>
inline T lcm(T a, T b) {
  return (a / gcd(a, b)) * b;
}
template <class T>
inline T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
inline T power(T v, T p) {
  T r = 1;
  while (p > 0) {
    if (p & 0x1) r = (r * v);
    v = (v * v);
    p >>= 1;
  }
  return r;
}
template <class T>
inline T power(T v, T p, T m) {
  v %= m;
  T r = 1;
  while (p > 0) {
    if (p & 0x1) r = (r * 1LL * v) % m;
    v = (v * 1LL * v) % m;
    p >>= 1;
  }
  return r;
}
template <class T>
inline T powerL(T v, T p, T m) {
  v %= m;
  T r = 1;
  while (p > 0) {
    if (p & 0x1) r = MulL(r, v, m);
    v = MulL(v, v, m);
    p >>= 1;
  }
  return r;
}
template <class T>
inline T MulL(T a, T b, T m) {
  T r = 0;
  a %= m;
  b %= m;
  while (b) {
    if (b & 0x1) r = (r + a) % m;
    b >>= 1;
    if (a < m - a)
      a <<= 1;
    else
      a -= (m - a);
  }
  return r;
}