#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, T, i, j, half, temp;
  scanf("%d", &t);
  vector<vector<int> > output(t);
  bool odd, flag;
  for (i = 0; i < t; i++) {
    scanf("%d %d", &n, &T);
    vector<int> nums(n);
    for (j = 0; j < n; j++) {
      scanf("%d", &nums[j]);
    }
    odd = T & 1;
    flag = false;
    half = T >> 1;
    for (j = 0; j < n; j++) {
      temp = nums[j] - half;
      if (temp < 0) {
        nums[j] = 0;
      } else if (temp > 0) {
        nums[j] = 1;
      } else {
        if (odd)
          nums[j] = 0;
        else {
          nums[j] = flag;
          flag = !flag;
        }
      }
    }
    output[i] = nums;
  }
  for (i = 0; i < t; i++) {
    for (auto it : output[i]) printf("%d ", it);
    printf("\n");
  }
  return 0;
}
