#include <bits/stdc++.h>
using namespace std;
template <typename... T>
inline void inp(T &...args) {
  ((cin >> args), ...);
}
template <typename T>
inline istream &operator>>(istream &in, vector<T> &a) {
  for (auto &x : a) in >> x;
  return in;
}
template <typename T, typename U>
inline istream &operator>>(istream &in, pair<T, U> &a) {
  in >> a.first >> a.second;
  return in;
}
void solve(int &T) {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> a(n);
  cin >> a;
  map<long long int, long long int> m;
  for (long long int i = (0); ((1) > 0 ? i < (n) : i > (n)); i += (1)) {
    m[a[i]]++;
  }
  set<long long int> s;
  for (long long int i = (0); ((1) > 0 ? i < (n) : i > (n)); i += (1)) {
    if (a[i] <= k) {
      long long int x = a[i];
      long long int y = k - a[i];
      if (m.count(y) and !s.count(min(x, y))) {
        if (x == y and m[y] >= 2) {
          s.insert(min(x, y));
        } else
          s.insert(min(x, y));
      }
    }
  }
  11;
  int ok = 1;
  vector<long long int> ans(n, 0);
  for (long long int i = (0); ((1) > 0 ? i < (n) : i > (n)); i += (1)) {
    if (s.count(a[i])) {
      ans[i] = 1;
      if (k % 2 == 0 and a[i] == k / 2) {
        ans[i] = ok;
        ok ^= 1;
      }
    }
  }
  for (auto &X : ans) {
    cout << X << " ";
  }
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    if (0) cerr << "Case #" << i << "\n";
    solve(i);
  }
  return 0;
}
