#include <bits/stdc++.h>
using namespace std;
int x[] = {0, 1, 0, -1};
int y[] = {1, 0, -1, 0};
long long gcd(long long a, long long b) {
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
long long fastpow(long long a, long long b) {
  if (b == 0) return 1ll;
  if (b == 1) return a;
  long long sw;
  if (b % 2 == 1)
    sw = a;
  else
    sw = 1;
  long long h = fastpow(a, b / 2);
  return h * h * sw;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie();
  long long a, b, c, d, n, t, m, k;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    int pnt[n + 1];
    vector<long long> v;
    for (int i = 0; i < n; i++) {
      cin >> a;
      v.push_back(a);
    }
    multiset<long long> A;
    multiset<long long> B;
    map<long long, int> mpA;
    map<long long, int> mpB;
    for (int i = 0; i < n; i++) {
      long long pos = abs(v[i] - k);
      if (A.find(pos) == A.end()) {
        pnt[i] = 1;
        A.insert(v[i]);
        mpA[v[i]]++;
      }
      if (B.find(pos) == B.end()) {
        pnt[i] = 0;
        B.insert(v[i]);
        mpB[v[i]]++;
      }
      if (mpA[pos] < mpB[pos]) {
        A.insert(v[i]);
        pnt[i] = 1;
        mpA[v[i]]++;
      } else {
        B.insert(v[i]);
        pnt[i] = 0;
        mpB[v[i]]++;
      }
    }
    for (int i = 0; i < n; i++) cout << pnt[i] << " ";
    cout << endl;
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
