#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
const int N = 1e5 + 10;
int t, n, k, a[N], vis[N];
void solve() {
  memset(vis, 0, sizeof vis);
  scanf("%d%d", &n, &k);
  int num = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] < k / 2)
      vis[i] = 0;
    else if (a[i] > k / 2)
      vis[i] = 1;
    else {
      if (k % 2)
        vis[i] = 0;
      else {
        if (num % 2 == 0)
          vis[i] = 1, num++;
        else
          vis[i] = 0, num++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d ", vis[i]);
  }
  printf("\n");
}
int main() {
  scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}
