#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigMod(T p, T e, T M) {
  T ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T modInverse(T a, T M) {
  return bigMod(a, M - 2, M);
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  a = abs(a);
  b = abs(b);
  return (a / gcd(a, b)) * b;
}
template <class T>
inline T SQR(T a) {
  return a * a;
}
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
vector<pair<int, int> > v;
int BSlo(int lo, int hi, int key) {
  if (lo > hi) return 0x3f3f3f3f;
  int mid = (lo + hi) / 2;
  if (v[mid].first >= key) return min(mid, BSlo(lo, mid - 1, key));
  return BSlo(mid + 1, hi, key);
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, k;
    scanf("%d %d", &n, &k);
    v.clear();
    int e[n];
    memset(e, -1, sizeof e);
    for (int i = int(0); i < int(n); i++) {
      int x;
      scanf("%d", &x);
      v.push_back(make_pair(x, i));
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < n; i++) {
      if (e[v[i].second] != -1) continue;
      int x = v[i].first;
      if (x * 2 == k) {
        int y = 0, j = i;
        while (j < n && v[j].first == x) {
          j++;
          y++;
        }
        j = i;
        int z = 0;
        while (z < y / 2) {
          e[v[j].second] = 0;
          z++;
          j++;
        }
        while (z < y) {
          e[v[j].second] = 1;
          z++;
          j++;
        }
      } else {
        int j = BSlo(0, n - 1, k - x);
        if (j == 0x3f3f3f3f)
          e[v[i].second] = 0;
        else {
          while (j < n && v[j].first == k - x) {
            e[v[j].second] = 1;
            j++;
          }
          j = i;
          while (j < n && v[j].first == x) {
            e[v[j].second] = 0;
            j++;
          }
        }
      }
    }
    for (int i = 0; i < n; i++) {
      printf("%d", e[i]);
      printf(" ");
    }
    printf("\n");
  }
  return 0;
}
