#include <bits/stdc++.h>
using namespace std;
int a[200000];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    if (k & 1) {
      for (int i = 0; i < n; i++) {
        if (a[i] & 1)
          cout << "0";
        else
          cout << "1";
        if (i < n - 1) cout << " ";
      }
      cout << endl;
    } else {
      int flag = 0;
      for (int i = 0; i < n; i++) {
        if (a[i] < k / 2)
          cout << "1";
        else if (a[i] > k / 2)
          cout << '0';
        else {
          if (flag & 1)
            cout << '1';
          else
            cout << '0';
          flag++;
        }
        if (i < n - 1) cout << " ";
      }
      cout << endl;
    }
  }
}
