#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, t;
    cin >> n >> t;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
      if (arr[i] == 0 || arr[i] == t) continue;
      arr[i] %= t;
    }
    set<int> s;
    set<int>::iterator it;
    bool selected = false;
    vector<int> color(n);
    for (int i = 0; i < n; i++) {
      if (t % 2 == 0 && arr[i] == t / 2) {
        color[i] = selected;
        selected = !selected;
      } else {
        int opp = t - arr[i];
        if (s.find(opp) == s.end()) {
          color[i] = 0;
          s.insert(arr[i]);
        } else {
          color[i] = 1;
        }
      }
    }
    for (int i = 0; i < n; i++) cout << color[i] << " ";
    cout << '\n';
  }
}
