#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
const long long MOD = 1e9 + 7;
void solve() {
  int n;
  cin >> n;
  long long k;
  cin >> k;
  vector<long long> vect(n);
  for (int i = 0; i < n; i++) {
    cin >> vect[i];
  }
  vector<int> ans(n, -1);
  int curr = 0;
  if (k % 2 == 0) {
    for (int i = 0; i < n; i++) {
      if (vect[i] < k / 2) ans[i] = 0;
      if (vect[i] > k / 2) ans[i] = 1;
      if (vect[i] == k / 2) {
        ans[i] = curr;
        curr = 1 - curr;
      }
    }
  } else {
    for (int i = 0; i < n; i++) {
      if (vect[i] <= k / 2) ans[i] = 0;
      if (vect[i] > k / 2) ans[i] = 1;
    }
  }
  for (auto x : ans) cout << x << " ";
  cout << "\n";
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    solve();
  }
}
