#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int t, n, u, x;
  cin >> t;
  while (t--) {
    cin >> n >> u;
    int y = 0;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
      cin >> x;
      if (x < u / 2)
        v[i] = 0;
      else if (x > u / 2)
        v[i] = 1;
      else {
        v[i] = 2;
        y++;
      }
    }
    int z = y;
    for (int i = 0; i < n; i++) {
      if (v[i] < 2)
        cout << v[i] << " ";
      else if (u % 2 == 0) {
        if (--y >= z / 2)
          cout << 0 << " ";
        else
          cout << 1 << " ";
      } else
        cout << 0 << " ";
    }
    cout << "\n";
  }
  return 0;
}
