#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
const int N_MAX = 1 << 17;
unordered_map<int, vector<int>> ids;
unordered_map<int, int> pv;
int values[N_MAX];
int colors[N_MAX];
void dfs(int i, int color, int t) {
  if (colors[i] != -1) return;
  colors[i] = color;
  int next_id = t - values[i];
  while (pv[next_id] < ids[next_id].size() &&
         colors[ids[next_id][pv[next_id]]] != -1)
    pv[next_id]++;
  if (pv[next_id] < ids[next_id].size() &&
      colors[ids[next_id][pv[next_id]]] == -1)
    dfs(ids[next_id][pv[next_id]], !color, t);
}
void solve() {
  int n, T;
  cin >> n >> T;
  for (int i = 0; i < n; i++) {
    colors[i] = -1;
    scanf("%d", &values[i]);
    ids[values[i]].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    if (colors[i] != -1) continue;
    int v = values[i];
    int n_v = T - v;
    if (v == n_v) {
      int c = 0;
      for (auto id : ids[v]) colors[id] = c++ % 2;
      continue;
    }
    for (auto id : ids[v]) colors[id] = 0;
    for (auto id : ids[n_v]) colors[id] = 1;
  }
  for (int i = 0; i < n; i++) printf("%d ", colors[i]);
  ids.clear();
  pv.clear();
  printf("\n");
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) solve();
  return 0;
}
