#include <bits/stdc++.h>
using namespace std;
bool prime[1000001];
void SieveOfEratosthenes() {
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= 1000000; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= 1000000; i += p) prime[i] = false;
    }
  }
}
long long biexp(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = res * x;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
long long bemo(long long x, long long y, long long m) {
  long long res = 1;
  x = x % m;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % m;
    y = y >> 1;
    x = (x * x) % m;
  }
  return res;
}
long long maxSubArraySum(long long a[], long long size) {
  long long max_so_far = INT_MIN, max_ending_here = 0;
  for (long long i = 0; i < size; i++) {
    max_ending_here = max_ending_here + a[i];
    if (max_so_far < max_ending_here) max_so_far = max_ending_here;
    if (max_ending_here < 0) max_ending_here = 0;
  }
  return max_so_far;
}
bool fun(long long i, long long j) { return abs(i) < abs(j); }
long long ceil_fun(long long x, long long y) { return ((x + y - 1) / y); }
void my_ans_is() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  int p[n];
  int ct = 0;
  for (long long i = 0; i < n; i++) {
    if (k % 2 == 0) {
      if (a[i] < k / 2) {
        p[i] = 0;
      } else if (a[i] > k / 2) {
        p[i] = 1;
      } else {
        if (ct)
          ct--;
        else
          ct++;
        p[i] = ct;
      }
    } else {
      if (a[i] >= k / 2 + 1)
        p[i] = 1;
      else
        p[i] = 0;
    }
  }
  for (long long i = 0; i < n; i++) cout << p[i] << " ";
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t;
  cin >> t;
  while (t--) {
    my_ans_is();
  }
  return 0;
}
