#include <bits/stdc++.h>
using namespace std;
long long int INF = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, i, j;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    long long int arr[n];
    unordered_map<long long int, long long int> hash;
    for (i = 0; i < n; i++) {
      cin >> arr[i];
      hash[arr[i]]++;
    }
    unordered_map<long long int, long long int> ans;
    unordered_map<long long int, long long int> vis;
    for (i = 0; i < n; i++) {
      long long int b = k - arr[i];
      if (b == arr[i]) {
        vis[arr[i]] = 1;
      } else if (ans[arr[i]] == 0 && b >= 0) {
        ans[arr[i]] = -1;
        ans[b] = 1;
      }
    }
    for (i = 0; i < n; i++) {
      if (vis[arr[i]] > 0) {
        if (vis[arr[i]] % 2 == 0)
          cout << 0 << " ";
        else
          cout << 1 << " ";
        vis[arr[i]]++;
      } else if (ans[arr[i]] == 1)
        cout << 0 << " ";
      else if (ans[arr[i]] == -1)
        cout << 1 << " ";
      else
        cout << 0 << " ";
    }
    cout << endl;
  }
  return 0;
}
