#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 0;
  char s = getchar();
  while (!isdigit(s)) f |= s == '-', s = getchar();
  while (isdigit(s)) x = x * 10 + s - 48, s = getchar();
  return f ? -x : x;
}
const int N = 1e5 + 10;
int n, m, a[N];
int main() {
  int tt = read();
  while (tt--) {
    n = read(), m = read();
    if (m % 2 == 0) {
      int s = 0;
      m = m / 2;
      for (int i = 1; i <= n; i++) {
        a[i] = read();
        if (a[i] == m) s++;
      }
      s /= 2;
      for (int i = 1; i <= n; i++) {
        if (a[i] < m)
          putchar('0'), putchar(' ');
        else if (a[i] > m)
          putchar('1'), putchar(' ');
        else {
          if (s > 0)
            putchar('0'), putchar(' ');
          else
            putchar('1'), putchar(' ');
          s--;
        }
      }
    } else {
      m = m / 2;
      for (int i = 1; i <= n; i++) {
        a[i] = read();
        if (a[i] <= m)
          putchar('0'), putchar(' ');
        else if (a[i] > m)
          putchar('1'), putchar(' ');
      }
    }
    puts("");
  }
  return 0;
}
