#include <bits/stdc++.h>
using namespace std;
const long long int INF = 2e18;
const long long int N = 2e5 + 5;
void null() {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> a;
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    a.push_back(x);
  }
  long long int b[n];
  memset(b, 0, sizeof(b));
  map<long long int, long long int> m, mm;
  set<pair<long long int, long long int>> s;
  for (long long int i = 0; i < n; i++) {
    if (m[k - a[i]] > 0) s.insert({min(k - a[i], a[i]), max(k - a[i], a[i])});
    m[a[i]]++;
  }
  for (auto i : s) {
    mm[i.first] = 0;
    mm[i.second] = 1;
  }
  long long int curr = 0;
  for (long long int i = 0; i < n; i++) {
    if (a[i] * 2 != k)
      cout << mm[a[i]] << " ";
    else {
      cout << curr << " ";
      curr ^= 1;
    }
  }
  cout << '\n';
  return;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  clock_t start, end;
  start = clock();
  cin >> t;
  while (t--) {
    null();
  }
  end = clock();
  double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
}
