#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t1;
  cin >> t1;
  while (t1--) {
    int n;
    long long int t;
    cin >> n >> t;
    vector<pair<int, int> > arr(n);
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      arr[i] = {x, i};
    }
    sort(arr.begin(), arr.end());
    vector<int> ans(n, 0);
    map<long long int, int> mp;
    map<long long int, int> col;
    col[arr[0].first] = 1;
    mp[arr[0].first]++;
    for (int i = 1; i < n; i++) {
      int p1 = arr[i].second;
      int p2 = arr[i - 1].second;
      if (mp[t - arr[i].first] > 0) {
        if (arr[i].first == arr[i - 1].first &&
            (long long int)arr[i].first + arr[i - 1].first ==
                (long long int)t) {
          ans[p1] = ans[p2] ^ 1;
          col[arr[i].first] = ans[p1] + 1;
        } else {
          ans[p1] = (col[t - arr[i].first] - 1) ^ 1;
          col[arr[i].first] = ans[p1] + 1;
        }
      } else {
        ans[p1] = ans[p2];
        col[arr[i].first] = ans[p1] + 1;
      }
      mp[arr[i].first]++;
    }
    for (int i = 0; i < n; i++) cout << ans[i] << " ";
    cout << endl;
  }
}
