RedDreamer has an array $a$ consisting of $n$ non-negative integers, and an unlucky integer $T$.

Let's denote the misfortune of array $b$ having length $m$ as $f(b)$ — the number of pairs of integers $(i, j)$ such that $1 \le i < j \le m$ and $b_i + b_j = T$. RedDreamer has to paint each element of $a$ into one of two colors, white and black (for each element, the color is chosen independently), and then create two arrays $c$ and $d$ so that all white elements belong to $c$, and all black elements belong to $d$ (it is possible that one of these two arrays becomes empty). RedDreamer wants to paint the elements in such a way that $f(c) + f(d)$ is minimum possible.

For example:

  if $n = 6$, $T = 7$ and $a = [1, 2, 3, 4, 5, 6]$, it is possible to paint the $1$-st, the $4$-th and the $5$-th elements white, and all other elements black. So $c = [1, 4, 5]$, $d = [2, 3, 6]$, and $f(c) + f(d) = 0 + 0 = 0$;  if $n = 3$, $T = 6$ and $a = [3, 3, 3]$, it is possible to paint the $1$-st element white, and all other elements black. So $c = [3]$, $d = [3, 3]$, and $f(c) + f(d) = 0 + 1 = 1$. 

Help RedDreamer to paint the array optimally!


-----Input-----

The first line contains one integer $t$ ($1 \le t \le 1000$) — the number of test cases. Then $t$ test cases follow.

The first line of each test case contains two integers $n$ and $T$ ($1 \le n \le 10^5$, $0 \le T \le 10^9$) — the number of elements in the array and the unlucky integer, respectively. 

The second line contains $n$ integers $a_1$, $a_2$, ..., $a_n$ ($0 \le a_i \le 10^9$) — the elements of the array. 

The sum of $n$ over all test cases does not exceed $10^5$.


-----Output-----

For each test case print $n$ integers: $p_1$, $p_2$, ..., $p_n$ (each $p_i$ is either $0$ or $1$) denoting the colors. If $p_i$ is $0$, then $a_i$ is white and belongs to the array $c$, otherwise it is black and belongs to the array $d$.

If there are multiple answers that minimize the value of $f(c) + f(d)$, print any of them.


-----Example-----
Input
2
6 7
1 2 3 4 5 6
3 6
3 3 3

Output
1 0 0 1 1 0 
1 0 0

Source: codeforces | Difficulty: EASY
Tags: Sorting

Mathematics

Greedy algorithms


Solutions:
t = int(input())
for _ in range(t):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = []
	b = False
	for i in range(n):
		if a[i] < T / 2:
			ans.append(0)
		elif a[i] > T / 2:
			ans.append(1)
		elif b:
			ans.append(1)
			b = not b
		else:
			ans.append(0)
			b = not b
	print(*ans)


for qq in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	dt0 = {}
	dt1 = {}
	ans = [0] * n
	for i in range(n):
		if not t - a[i] in dt0.keys():
			ans[i] = 0
			dt0[a[i]] = 1
		elif not t - a[i] in dt1.keys():
			ans[i] = 1
			dt1[a[i]] = 1
		elif dt0[t - a[i]] < dt1[t - a[i]]:
			ans[i] = 0
			dt0[a[i]] += 1
		else:
			ans[i] = 1
			dt1[a[i]] += 1
	print(*ans)


def answer(n, k, A):
	color = [0] * n
	color[0] = 0
	s0 = {}
	s1 = {}
	s0[A[0]] = 1
	for i in range(1, n):
		if k - A[i] not in s0:
			color[i] = 0
			if A[i] in s0:
				s0[A[i]] += 1
			else:
				s0[A[i]] = 1
		elif k - A[i] not in s1:
			color[i] = 1
			if A[i] in s1:
				s1[A[i]] += 1
			else:
				s1[A[i]] = 1
		elif s0[k - A[i]] > s1[k - A[i]]:
			color[i] = 1
			if A[i] in s1:
				s1[A[i]] += 1
			else:
				s1[A[i]] = 1
		else:
			color[i] = 0
			if A[i] in s0:
				s0[A[i]] += 1
			else:
				s0[A[i]] = 1
	return color
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	print(*answer(n, k, arr))


import sys
for _ in range(int(input())):
	(n, t) = map(int, sys.stdin.readline().split())
	arr = list(map(int, sys.stdin.readline().split()))
	ans_arr = [2 for i in range(n)]
	flag = 0
	if t % 2 != 0:
		mid = t // 2
		for i in range(n):
			if arr[i] <= mid:
				ans_arr[i] = 0
			elif arr[i] > mid:
				ans_arr[i] = 1
	elif t % 2 == 0:
		mid = t // 2
		for i in range(n):
			if arr[i] < mid:
				ans_arr[i] = 0
			elif arr[i] > mid:
				ans_arr[i] = 1
			elif arr[i] == mid:
				if flag == 0:
					ans_arr[i] = 0
					flag = 1
				elif flag == 1:
					ans_arr[i] = 1
					flag = 0
	print(' '.join(map(str, ans_arr)))


for _ in range(int(input())):
	(n, t) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	flip = 0
	for i in range(n):
		if 2 * arr[i] > t:
			arr[i] = 1
		elif 2 * arr[i] < t:
			arr[i] = 0
		else:
			arr[i] = flip
			flip = 1 - flip
	print(*arr)


from sys import stdin, stdout

def INPUT():
	return list((int(i) for i in stdin.readline().split()))

def inp():
	return stdin.readline()

def out(x):
	return stdout.write(x)
import math
import random
import sys
for _ in range(int(input())):
	(n, t) = INPUT()
	A = INPUT()
	D = {}
	X = []
	for i in range(n):
		if A[i] not in D:
			if t - A[i] not in D:
				D[A[i]] = 1
			else:
				D[A[i]] = (D[t - A[i]] + 1) % 2
			ans = D[A[i]]
		else:
			if 2 * A[i] == t:
				D[A[i]] += 1
				D[A[i]] %= 2
			ans = D[A[i]]
		X.append(ans)
	print(*X)


T = int(input())
res = list()
for i in range(T):
	(n, t) = tuple(map(int, input().split()))
	x = list(map(int, input().split()))
	l = list()
	ok = True
	for j in range(len(x)):
		if x[j] < int(t / 2):
			l.append(1)
		elif t % 2 == 0 and x[j] == int(t / 2) and ok:
			l.append(1)
			ok = False
		elif t % 2 == 0 and x[j] == int(t / 2) and (not ok):
			l.append(0)
			ok = True
		elif t % 2 != 0 and x[j] == int(t / 2):
			l.append(1)
		else:
			l.append(0)
	res.append(l)
for i in res:
	s = ''
	for j in i:
		s += str(j) + ' '
	print(s)


R = lambda : map(int, input().split())
(t,) = R()
r = []
for _ in [0] * t:
	(n, T) = R()
	f = 0
	for x in R():
		r += (+(2 * x + f > T),)
		f ^= 2 * x == T
print(*r)


for _ in range(int(input())):
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	need = 0
	b = [0] * n
	for i in range(n):
		a[i] *= 2
		if a[i] < x:
			b[i] = 0
			continue
		if a[i] > x:
			b[i] = 1
			continue
		need = 1 - need
		b[i] = need
	print(*b)


import sys
import itertools
import math
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n,) = I()
while n:
	n -= 1
	(m, k) = I()
	arr = I()
	l = k // 2
	ans = []
	dicta = {}
	for i in arr:
		if i not in dicta:
			dicta[i] = 1
		if i <= l:
			if i * 2 == k and dicta[i] % 2:
				ans.append(0)
			else:
				ans.append(1)
		else:
			ans.append(0)
		dicta[i] += 1
	print(*ans)


from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()
for _ in range(int(I1())):
	(n, T) = I()
	a = list(I())
	c = [0] * n
	f = 0
	if T % 2 != 0:
		for i in range(n):
			if a[i] > T // 2:
				c[i] = 1
	elif T % 2 == 0:
		for i in range(n):
			if a[i] > T // 2:
				c[i] = 1
			elif a[i] == T // 2:
				if f == 0:
					c[i] = 0
					f = 1
				else:
					c[i] = 1
					f = 0
	print(*c)


import math
import collections
t = int(input())
for w in range(t):
	(n, k) = (int(i) for i in input().split())
	l = [int(i) for i in input().split()]
	l1 = [0] * n
	c = 0
	for i in range(n):
		if l[i] > k / 2:
			l1[i] = 1
		elif l[i] < k / 2:
			l1[i] = 0
		elif c % 2 == 0:
			l1[i] = 0
			c += 1
		else:
			l1[i] = 1
			c += 1
	print(*l1)


test_case = int(input())
while test_case:
	(n, t) = map(int, input().split())
	N = list(map(int, input().split()))
	ans = ''
	chk = 0
	for ele in N:
		if t % 2 == 0 and ele == t / 2:
			ans += ' ' + str(chk % 2)
			chk += 1
		elif ele * 2 < t:
			ans += ' 1'
		else:
			ans += ' 0'
	print(ans.strip())
	test_case -= 1


test = int(input())
for q in range(test):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	c = 0
	x = ''
	for i in range(n):
		if k % 2 == 1:
			if a[i] <= k // 2:
				x += '0'
			else:
				x += '1'
		elif a[i] < k // 2:
			x += '0'
		elif a[i] > k // 2:
			x += '1'
		else:
			if c % 2 == 0:
				x += '0'
			else:
				x += '1'
			c += 1
	for i in range(n):
		if i != n - 1:
			print(x[i], end=' ')
		else:
			print(x[i])


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	w = []
	b = []
	sd = {}
	bd = {}
	sw = set()
	sb = set()
	lis = list(map(int, input().split()))
	ans = [0] * n
	c = 0
	for i in lis:
		if k - i not in sw:
			sw.add(i)
			sd[i] = 1
		elif k - i not in sb:
			sb.add(i)
			bd[i] = 1
			ans[c] = 1
		elif k - i in sw and k - i in sb:
			if bd[k - i] <= sd[k - i]:
				ans[c] = 1
				bd[i] += 1
				sb.add(i)
			else:
				sd[i] += 1
				sw.add(i)
		elif k - i in sb:
			sd[i] += 1
			sw.add(i)
		elif k - i in sw:
			ans[c] = 1
			bd[i] += 1
			sb.add(i)
		c += 1
	print(*ans)


from collections import Counter
for _ in range(int(input())):
	(n, T) = map(int, input().split())
	arr = list(map(int, input().split()))
	cnt = Counter(arr)
	ans = []
	e = 0
	if T % 2 == 0 and cnt[T // 2] > 0:
		e = 1
	for a in range(n):
		if e == 1:
			if arr[a] == T // 2:
				if cnt[T // 2] % 2 == 1:
					ans.append(0)
				else:
					ans.append(1)
				cnt[T // 2] -= 1
			elif arr[a] < T // 2:
				ans.append(0)
			else:
				ans.append(1)
		elif arr[a] <= T // 2:
			ans.append(0)
		else:
			ans.append(1)
	print(*ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().strip().split()))[:n]
	f = 0
	for num in arr:
		if num * 2 == k:
			print(f, end=' ')
			f = f ^ 1
		elif num <= k // 2:
			print(0, end=' ')
		else:
			print(1, end=' ')
	print()


T = int(input())
ans_ls = [0] * T
for t in range(T):
	(N, T) = map(int, input().split())
	a_ls = list(map(int, input().split()))
	res_ls = [0] * N
	halfT_count = 0
	for i in range(N):
		if a_ls[i] * 2 < T:
			res_ls[i] = 0
		elif a_ls[i] * 2 > T:
			res_ls[i] = 1
		else:
			res_ls[i] = halfT_count % 2
			halfT_count += 1
	ans_ls[t] = res_ls
for ans in ans_ls:
	print(*ans)


number = int(input())
for i in range(number):
	(n, t) = map(int, input().split())
	arr = list(map(int, input().split()))
	final = []
	flag = True
	for i in range(len(arr)):
		if arr[i] > t / 2:
			final.append(1)
		elif arr[i] < t / 2:
			final.append(0)
		else:
			if flag:
				final.append(1)
			if not flag:
				final.append(0)
			flag = not flag
	print(' '.join((str(i) for i in final)))


t = int(input())
for i in range(t):
	l = input()
	L = l.split()
	n = int(L[0])
	T = int(L[1])
	c = input()
	A = c.split()
	for i in range(n):
		A[i] = int(A[i])
	s0 = set()
	s1 = set()
	s1.add(T - A[0])
	ch = '1 '
	if T % 2 == 1:
		for i in range(1, n):
			if A[i] in s1:
				ch += '0 '
				s0.add(T - A[i])
			else:
				ch += '1 '
				s1.add(T - A[i])
	else:
		sex = 0
		for i in range(1, n):
			if A[i] == T // 2 and sex == 0:
				sex = 1
				ch += '0 '
			elif A[i] == T // 2 and sex == 1:
				sex = 0
				ch += '1 '
			elif A[i] in s1:
				ch += '0 '
				s0.add(T - A[i])
			else:
				ch += '1 '
				s1.add(T - A[i])
	print(ch)


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	c = {}
	d = {}
	(c1, d1) = ([], [])
	for i in range(n):
		if t - a[i] not in d:
			d[a[i]] = 1
			d1.append(i)
		elif t - a[i] not in c:
			c[a[i]] = 1
			c1.append(i)
		elif c[t - a[i]] < d[t - a[i]]:
			c[a[i]] += 1
			c1.append(i)
		elif c[t - a[i]] > d[t - a[i]]:
			d[a[i]] += 1
			d1.append(i)
		else:
			d[a[i]] += 1
			d1.append(i)
	ans = [0] * n
	for j in d1:
		ans[j] = 1
	print(*ans)


import sys
inp = sys.stdin.buffer.readline
inar = lambda : list(map(int, inp().split()))
inin = lambda : int(inp())
inst = lambda : inp().decode().strip()

def wrl(*args, end='\n'):
	for _arg in args:
		sys.stdout.write(str(_arg) + ' ')
	sys.stdout.write(end)
from collections import defaultdict as dd
_T_ = inin()
for _t_ in range(_T_):
	(n, t) = inar()
	a = inar()
	ind = dd(lambda : [])
	for i in range(n):
		ind[a[i]].append(i)
	wht = []
	blk = []
	if t % 2 == 0:
		if ind[t // 2]:
			l = len(ind[t // 2])
			for i in range(l // 2):
				blk.append(ind[t // 2][i])
			for i in range(l // 2, l):
				wht.append(ind[t // 2][i])
		for i in a:
			if i != t // 2:
				for j in ind[i]:
					wht.append(j)
				for j in ind[t - i]:
					blk.append(j)
				ind[i] = []
				ind[t - i] = []
	else:
		for i in a:
			for j in ind[i]:
				wht.append(j)
			for j in ind[t - i]:
				blk.append(j)
			ind[i] = []
			ind[t - i] = []
	indeces = [0 for i in range(n)]
	for i in wht:
		indeces[i] = 1
	print(*indeces)


def listToString(s):
	str1 = ' '
	s1 = [str(x) for x in s]
	return str1.join(s1)
for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = [0] * n
	flag = 0
	for i in range(n):
		if t % 2 != 0:
			if a[i] >= t / 2:
				ans[i] = 0
			else:
				ans[i] = 1
		elif a[i] > t / 2:
			ans[i] = 0
		elif a[i] == t / 2:
			if flag % 2 == 0:
				ans[i] = 0
			else:
				ans[i] = 1
			flag += 1
		else:
			ans[i] = 1
	print(listToString(ans))


def solve():
	(n, t) = map(int, input().split())
	l = [i for i in map(int, input().split())]
	d = {}
	dup = {}
	for i in l:
		d[i] = 0
		d[t - i] = 1
		if i == t - i:
			dup[i] = dup.get(i, 0) + 1
	res = []
	for i in l:
		res.append(d[i])
	for i in range(n):
		if l[i] == t - l[i] and dup[l[i]] > 1:
			res[i] = dup[l[i]] % 2
			dup[l[i]] -= 1
	print(*res)
t = int(input())
while t:
	solve()
	t -= 1


def solve(arr, T):
	hashSet1 = set()
	hashSet2 = set()
	resArray = []
	set1Score = 0
	set2Score = 0
	for el in arr:
		counter = T - el
		if counter not in hashSet1:
			resArray.append(0)
			hashSet1.add(el)
		elif counter not in hashSet2:
			resArray.append(1)
			hashSet2.add(el)
		elif set1Score < set2Score:
			resArray.append(0)
			hashSet1.add(el)
			set1Score += 1
		else:
			resArray.append(1)
			hashSet2.add(el)
			set2Score += 1
	return resArray
t = int(input())
for _ in range(t):
	(n, T) = map(int, input().split())
	arr = list(map(int, input().split()))
	res = solve(arr, T)
	print(*res)


for t in range(int(input())):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	i = 0
	for x in a:
		if x < T / 2:
			print(0, end=' ')
		elif x == T / 2:
			print(i, end=' ')
			i ^= 1
		else:
			print(1, end=' ')
	print()


import os
import sys
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	for _ in range(inp()):
		(n, t) = invr()
		a = inlt()
		ans = []
		threshflag = True
		thresh = t / 2
		for i in range(n):
			if a[i] > thresh:
				ans.append(1)
			elif a[i] < thresh:
				ans.append(0)
			elif a[i] == thresh and threshflag:
				ans.append(0)
				threshflag = not threshflag
			elif a[i] == thresh and (not threshflag):
				ans.append(1)
				threshflag = not threshflag
		print(*ans, sep=' ')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from sys import stdin
N = int(stdin.readline())
for case in range(N):
	(n, T) = map(int, stdin.readline().split())
	array = list(map(int, stdin.readline().split()))
	par = 0
	sets = set(array)
	seta = set()
	setb = set()
	ans = []
	for i in array:
		if T % 2 == 0 and i == T // 2:
			ans.append(par)
			par = [1, 0][par]
		elif i not in seta and i not in setb:
			seta.add(i)
			setb.add(T - i)
			ans.append(0)
		elif i in seta:
			ans.append(0)
		elif i in setb:
			ans.append(1)
	print(' '.join([str(i) for i in ans]))


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(n, t) = map(int, input().split())
	arr = list(map(int, input().split()))
	out = [0 for i in range(n)]
	dic = {}
	for i in arr:
		if i * 2 == t:
			if i in dic:
				dic[i] += 1
			else:
				dic[i] = 1
		elif t - i in dic:
			if dic[t - i]:
				dic[i] = 0
			else:
				dic[i] = 1
		else:
			dic[i] = 0
	if t // 2 in dic:
		c = dic[t // 2] // 2
		x = dic[t // 2]
	for i in range(n):
		if arr[i] * 2 == t:
			if x > c:
				out[i] = 0
				x -= 1
			else:
				out[i] = 1
				x -= 1
		elif dic[arr[i]] == 0:
			out[i] = 0
		else:
			out[i] = 1
	print(*out)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdarr = lambda : map(int, stdstr().split())
mod = 1000000007
for _ in range(stdint()):
	(n, t) = stdarr()
	arr = list(stdarr())
	res = [-1] * n
	if t & 1 == 1:
		for i in range(n):
			if arr[i] > t // 2:
				res[i] = 1
			else:
				res[i] = 0
	else:
		x = 0
		for i in range(n):
			if arr[i] == t // 2:
				if x % 2 == 0:
					res[i] = 0
				else:
					res[i] = 1
				x += 1
			elif arr[i] < t // 2:
				res[i] = 0
			else:
				res[i] = 1
	print(*res)


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	count = 0
	for x in range(n):
		if a[x] < k / 2:
			print('0', end=' ')
		elif a[x] > k / 2:
			print('1', end=' ')
		elif count % 2:
			count += 1
			print('1', end=' ')
		else:
			count += 1
			print('0', end=' ')
	print()
	t -= 1


from __future__ import division, print_function
import os
import sys
from collections import defaultdict
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	t = int(input())
	for _ in range(t):
		(n, T) = map(int, input().split())
		a = [int(ai) for ai in input().split()]
		color = {}
		s = set(a)
		while s:
			i = s.pop()
			color[i] = 0
			if T - i in s:
				s.remove(T - i)
				color[T - i] = 1
		same = 0
		sol = [0] * n
		for (i, j) in enumerate(a):
			if j == T - j:
				sol[i] = same
				same ^= 1
				continue
			sol[i] = color[j]
		print(*sol)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from collections import defaultdict
t = int(input())
while t != 0:
	(n, k) = map(int, input().split())
	list1 = list(map(int, input().split()))
	d = defaultdict(list)
	for i in range(len(list1)):
		d[list1[i]].append(i)
	ans1 = []
	ans2 = []
	d2 = {}
	for i in d.keys():
		d2[i] = 0
	for i in d.keys():
		if d2[i] == 1:
			continue
		if i == k - i:
			temp1 = d[i][:len(d[i]) // 2]
			temp2 = d[i][len(d[i]) // 2:]
			ans1.extend(temp1)
			ans2.extend(temp2)
		else:
			ans1.extend(d[i])
			if k - i in d.keys():
				ans2.extend(d[k - i])
				d2[k - i] = 1
	ans = [-1] * n
	for i in range(len(ans1)):
		ans[ans1[i]] = 0
	for i in range(len(ans2)):
		ans[ans2[i]] = 1
	print(*ans)
	t -= 1


import time, math as mt, bisect as bs, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * (2 * 10 ** 5 + 5)
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(2 * 10 ** 5 + 5):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return

def readTree(n, e):
	adj = [set() for i in range(n + 1)]
	for i in range(e):
		(u1, u2) = IP()
		adj[u1].add(u2)
	return adj
mod = 10 ** 9 + 7

def solve():
	(n, t) = IP()
	a = L()
	d = {}
	for ele in a:
		d[ele] = d.get(ele, 0) + 1
	color = {}
	for i in range(n):
		x = a[i]
		if color.get(x, -1) == -1:
			color[x] = 0
			if d.get(t - x, 0):
				color[t - x] = 1
	cur = 0
	for ele in a:
		if ele == t // 2 and d[ele] > 1 and (t % 2 == 0):
			print(1 - cur, end=' ')
			cur = 1 - cur
		else:
			print(color[ele], end=' ')
	print()
	return
t = II()
for i in range(t):
	solve()


T = int(input())
for t in range(T):
	(n, k) = [int(i) for i in input().split()]
	A = [int(i) for i in input().split()]
	ans = []
	half = k // 2
	if k % 2:
		for i in A:
			if i <= half:
				ans.append(1)
			else:
				ans.append(0)
	else:
		cur = 0
		for i in A:
			if i < half:
				ans.append(1)
			elif i > half:
				ans.append(0)
			else:
				ans.append(cur)
				cur ^= 1
	print(*ans)


t = int(input())
for i in range(t):
	(n, k) = [int(i) for i in input().split()]
	a = [[int(i), 0] for i in input().split()]
	for i in range(len(a)):
		a[i][1] = i
	res = [0 for i in range(n)]
	er = 0
	for j in a:
		if j[0] == k // 2:
			er += 1
	er1 = er // 2
	q = False
	for j in a:
		if k - j[0] < k / 2:
			res[j[1]] = 1
		elif k - j[0] > k / 2:
			res[j[1]] = 0
		else:
			if er <= er1:
				res[j[1]] = 1
			er -= 1
	print(*res)


ncases = int(input())

def to_int(s):
	return int(s)
for case in range(ncases):
	nt = input().split(' ')
	n = int(nt[0])
	t = int(nt[1])
	nums = list(map(to_int, input().split(' ')))
	counts = set()
	for n in nums:
		counts.add(n)
	colorAssignments = {}
	for key in counts:
		if not key in colorAssignments:
			colorAssignments[key] = 0
		if t - key in counts and (not t - key in colorAssignments):
			colorAssignments[t - key] = 1
	colors = []
	alt = 0
	for n in nums:
		if t % 2 == 0 and t // 2 == n:
			colors.append(alt)
			alt = 1 - alt
		else:
			colors.append(colorAssignments.get(n))
	for c in colors:
		print(c, end=' ')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	x = 0
	b = [0] * n
	for i in range(n):
		if k % 2 == 0:
			if a[i] < k // 2:
				b[i] += 1
			elif a[i] == k // 2:
				if x % 2 == 0:
					b[i] += 1
				x += 1
		elif a[i] <= k // 2:
			b[i] += 1
	print(*b)


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def sumDigits(no):
	return 0 if no == 0 else int(no % 10) + sumDigits(int(no / 10))
MOD = 1000000007
PMOD = 998244353
N = 10 ** 9 + 7
LOGN = 30
T = 1
T = int(stdin.readline())
for _ in range(T):
	(n, t) = list(map(int, stdin.readline().rstrip().split()))
	a = list(map(int, stdin.readline().rstrip().split()))
	ans = [0] * n
	if t % 2 == 1:
		for i in range(n):
			if a[i] % 2 == 1:
				ans[i] = 1
	else:
		t = t // 2
		cnt = 0
		for i in range(n):
			if a[i] == t:
				cnt += 1
				ans[i] = 1
			if a[i] < t:
				ans[i] = 1
		cnt = cnt // 2
		for i in range(n):
			if a[i] == t:
				if cnt > 0:
					ans[i] = 0
					cnt -= 1
				else:
					break
	print(*ans)


from collections import defaultdict, Counter
from math import log, ceil, floor

def solve():
	(n, t) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	c = []
	d = []
	s = set()
	count = Counter(a)
	for i in range(n):
		if t - a[i] in s:
			d.append(i)
		else:
			s.add(a[i])
			c.append(i)
	res = [0 for i in range(n)]
	for i in d:
		res[i] = 1
	if t & 1 ^ 1:
		fun = []
		for i in range(n):
			if a[i] == t // 2:
				fun.append(i)
		if len(fun) > 0:
			for i in range(len(fun)):
				if i < len(fun) // 2:
					res[fun[i]] = 0
				else:
					res[fun[i]] = 1
	print(*res)
t = 1
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for _ in range(t):
	(n, t) = list(map(int, input().split()))
	nums = list(map(int, input().split()))
	ans = []
	half_counter = 0
	for num in nums:
		if num < t / 2:
			ans.append(0)
		elif num > t / 2:
			ans.append(1)
		else:
			if half_counter % 2 == 0:
				ans.append(0)
			else:
				ans.append(1)
			half_counter += 1
	print(*ans)


import sys
from collections import defaultdict as dd
from collections import Counter as cc
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = lambda : sys.stdin.buffer.readline().rstrip()
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	q = set()
	w = [0] * n
	r = []
	for i in range(n):
		if a[i] == k / 2:
			r.append(i)
		elif a[i] < k / 2:
			w[i] = 1
	t = 1
	for i in r:
		w[i] = t
		t = abs(t - 1)
	print(*w)


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=2 ** 30, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] > k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

class TrieNode:

	def __init__(self):
		self.children = [None] * 26
		self.isEndOfWord = False

class Trie:

	def __init__(self):
		self.root = self.getNode()

	def getNode(self):
		return TrieNode()

	def _charToIndex(self, ch):
		return ord(ch) - ord('a')

	def insert(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				pCrawl.children[index] = self.getNode()
			pCrawl = pCrawl.children[index]
		pCrawl.isEndOfWord = True

	def search(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				return False
			pCrawl = pCrawl.children[index]
		return pCrawl != None and pCrawl.isEndOfWord

class Node:

	def __init__(self, data):
		self.data = data
		self.count = 0
		self.left = None
		self.right = None

class BinaryTrie:

	def __init__(self):
		self.root = Node(0)

	def insert(self, pre_xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = pre_xor & 1 << i
			if val:
				if not self.temp.right:
					self.temp.right = Node(0)
				self.temp = self.temp.right
				self.temp.count += 1
			if not val:
				if not self.temp.left:
					self.temp.left = Node(0)
				self.temp = self.temp.left
				self.temp.count += 1
		self.temp.data = pre_xor

	def query(self, xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = xor & 1 << i
			if not val:
				if self.temp.left and self.temp.left.count > 0:
					self.temp = self.temp.left
				elif self.temp.right:
					self.temp = self.temp.right
			elif self.temp.right and self.temp.right.count > 0:
				self.temp = self.temp.right
			elif self.temp.left:
				self.temp = self.temp.left
			self.temp.count -= 1
		return xor ^ self.temp.data
for ik in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	s = set()
	s1 = set()
	arr = [-1] * n
	t = 0
	for i in range(n):
		if l[i] == k // 2 and k % 2 == 0:
			if t == 0:
				s.add(l[i])
				arr[i] = 0
			else:
				s1.add(l[i])
				arr[i] = 1
			t = 1 - t
			continue
		if k - l[i] not in s:
			s.add(l[i])
			arr[i] = 0
		else:
			s1.add(l[i])
			arr[i] = 1
	print(*arr)


def pairs(v):
	return v * (v - 1) // 2

def solve():
	(n, t) = [int(v) for v in input().split()]
	arr = [int(v) for v in input().split()]
	hlfT = -1
	if t % 2 != 0:
		hlfT = -1
	else:
		hlfT = t // 2
	mptocolor = {}
	ans = [-1] * n
	for i in range(n):
		if hlfT != arr[i]:
			if arr[i] not in mptocolor:
				mptocolor[arr[i]] = 0
				mptocolor[t - arr[i]] = 1
				ans[i] = 0
			else:
				ans[i] = mptocolor[arr[i]]
	cntr = {}
	for v in arr:
		cntr.setdefault(v, 0)
		cntr[v] += 1
	cnt = cntr.get(hlfT, 0)
	hlf = cnt // 2
	ohf = cnt - hlf
	i = 0
	while hlf > 0 and i < n:
		if arr[i] == hlfT:
			hlf -= 1
			ans[i] = 0
		i += 1
	i = 0
	while i < n:
		if arr[i] == hlfT and ans[i] == -1:
			ans[i] = 1
		i += 1
	print(*ans)
t = int(input())
for _ in range(t):
	solve()


for j in range(int(input())):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	m = k // 2
	if k % 2 == 1:
		for i in range(n):
			if a[i] % 2:
				a[i] = 1
			else:
				a[i] = 0
	else:
		f = 0
		for i in range(n):
			if a[i] < m:
				a[i] = 1
			elif a[i] > m:
				a[i] = 0
			else:
				a[i] = f
				f ^= 1
	for i in a:
		print(i, end=' ')
	print()


import sys
input = sys.stdin.readline

def main():
	(n, t) = map(int, input().split())
	alst = list(map(int, input().split()))
	lst = [[i, a] for (i, a) in enumerate(alst)]
	lst.sort()
	if t % 2 == 0:
		mid = t // 2
	else:
		mid = t / 2
	ans = [-1 for _ in range(n)]
	flg = False
	for (i, a) in lst:
		if a < mid:
			ans[i] = 0
		elif a > mid:
			ans[i] = 1
		elif flg:
			flg = False
			ans[i] = 0
		else:
			flg = True
			ans[i] = 1
	print(*ans)
for _ in range(int(input())):
	main()


for _ in range(int(input())):
	(n, t) = tuple(map(int, input().split()))
	arr = list(map(int, input().split()))
	ans = [-1] * n
	if t % 2 == 0:
		x = t // 2
		c = arr.count(x)
		c2 = 0
		for i in range(n):
			if arr[i] != x:
				continue
			if c2 < c // 2:
				ans[i] = 0
			else:
				ans[i] = 1
			c2 += 1
	for i in range(n):
		if ans[i] != -1:
			continue
		if arr[i] <= t // 2:
			ans[i] = 0
		else:
			ans[i] = 1
	print(*ans)


for i in range(int(input())):
	(n, t) = map(int, input().split())
	currMid = 0
	a = list(map(int, input().split()))
	for j in range(n):
		x = a[j]
		r = 0
		if t % 2 == 0 and x == t // 2:
			currMid += 1
			r = currMid % 2
		elif 2 * x < t:
			r = 0
		else:
			r = 1
		print(r, end=' ')
	print()


tests = int(input())
for t in range(tests):
	(n, s) = [int(i) for i in input().split(' ')]
	values = [int(i) for i in input().split(' ')]
	black = {}
	white = {}
	for v in values:
		comp = s - v
		if comp in black.keys():
			if comp in white.keys():
				if black[comp] > white[comp]:
					print(1, end=' ')
					if v in white:
						white[v] += 1
					else:
						white[v] = 1
				else:
					print(0, end=' ')
					if v in black:
						black[v] += 1
					else:
						black[v] = 1
			else:
				print(1, end=' ')
				if v in white:
					white[v] += 1
				else:
					white[v] = 1
		else:
			print(0, end=' ')
			if v in black:
				black[v] += 1
			else:
				black[v] = 1
	print(end='\n')


for _ in 'A' * int(input()):
	(n, T) = map(int, input().split())
	a = [*map(int, input().split())]
	d = {}
	ans = []
	k = a.count(T // 2)
	z = 0
	for num in a:
		if T % 2 == 0 and num == T / 2:
			if z < k // 2:
				ans += [0]
			else:
				ans += [1]
			z += 1
		elif num in d:
			ans += [d[num]]
		elif T - num in d:
			ans += [d[T - num] ^ 1]
			d[num] = d[T - num] ^ 1
		else:
			ans += [0]
			d[num] = 0
	print(*ans)


from math import sqrt, ceil
from collections import defaultdict

def solve():
	(n, t) = map(int, input().split())
	l = list(map(int, input().split()))
	col = defaultdict(int)
	hash = defaultdict(int)
	ans = []
	for i in range(n):
		z = t - l[i]
		if hash[z] > 0:
			ka = col[z]
			c = ka ^ 1
			if c == 0:
				ans.append(0)
				col[l[i]] = 0
			else:
				ans.append(1)
				col[l[i]] = 1
			hash[l[i]] += 1
		else:
			hash[l[i]] += 1
			ans.append(0)
			col[l[i]] = 0
	print(*ans)
t = int(input())
for _ in range(t):
	solve()


def Sort(sub_li, y):
	sub_li.sort(key=lambda x: x[y])
	return sub_li
a = int(input())
for i in range(a):
	(n, T) = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = []
	for j in range(n):
		e = []
		e.append(b[j])
		e.append(j)
		b[j] = e
	X = []
	Y = []
	Z = []
	count1 = 0
	for j in range(n):
		if T % 2 == 0 and T // 2 == b[j][0]:
			Y.append(b[j])
			count1 = count1 + 1
		if T / 2 > b[j][0]:
			X.append(b[j])
		if T / 2 < b[j][0]:
			Z.append(b[j])
	if count1 != 0:
		n1 = count1 // 2
		for j in range(n):
			if T / 2 == b[j][0]:
				n1 = n1 - 1
				if n1 >= 0:
					X.append(b[j])
				else:
					Z.append(b[j])
	for j in range(len(Z)):
		Z[j][0] = 1
	for j in range(len(X)):
		X[j][0] = 0
	l1 = X + Z
	Sort(l1, 1)
	for j in range(n):
		print(l1[j][0], end=' ')
	print()


for _ in range(int(input())):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	flag = True
	res = []
	for i in a:
		if i == T // 2 and T % 2 == 0:
			if flag:
				res.append(0)
				flag = False
			else:
				res.append(1)
				flag = True
		elif i > T // 2:
			res.append(1)
		else:
			res.append(0)
	print(*res)


def main():
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	flip = True
	ans = [0 for _ in range(n)]
	for i in range(n):
		if t - a[i] > a[i]:
			ans[i] = 1
		elif a[i] == t // 2 and t % 2 == 0:
			if flip:
				ans[i] = 1
			flip = not flip
	for c in ans:
		print(c, end=' ')
	print('')
for _ in range(int(input())):
	main()


from collections import defaultdict

class Solution:

	def __init__(self):
		pass

	def run(self):
		(n, T) = [int(i) for i in input().split()]
		arr = [int(i) for i in input().split()]
		d = defaultdict(list)
		white = set()
		black = set()
		result = [0] * len(arr)
		for i in range(len(arr)):
			d[arr[i]].append(i)
		if len(arr) == len(d[arr[0]]) and arr[0] * 2 == T:
			white = True
			for i in range(len(result)):
				if white:
					result[i] = '0'
				else:
					result[i] = '1'
				white = not white
			return ' '.join(result)
		for i in range(len(arr)):
			a = arr[i]
			if len(d[a]) == 0 or d[a][0] != i:
				continue
			result[i] = '0'
			d[a].remove(i)
			if len(d[T - a]) > 0:
				if len(d[T - a]) > 2 and a * 2 == T:
					d[T - a].append(i)
					white = True
					for i in d[T - a]:
						if white:
							result[i] = '0'
						else:
							result[i] = '1'
						white = not white
					d[T - a] = []
				for k in range(len(d[T - a])):
					j = d[T - a].pop(0)
					result[j] = '1'
		return ' '.join(result)
t = int(input())
s = Solution()
for i in range(t):
	print(s.run())


def process():
	(n, T) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	if T % 2:
		T = T // 2
		for i in l:
			if i <= T:
				print(0, end=' ')
			else:
				print(1, end=' ')
	else:
		h = T // 2
		flag = 0
		for i in l:
			if h < i:
				print(0, end=' ')
			elif h > i:
				print(1, end=' ')
			else:
				print(flag, end=' ')
				if flag == 0:
					flag = 1
				else:
					flag = 0
	print()

def main():
	for i in range(int(input())):
		process()
main()


T = int(input())
for test in range(T):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	res = []
	j = 0
	for i in a:
		if i * 2 < t:
			res += ['0']
		elif i * 2 > t:
			res += ['1']
		else:
			res.append(['0', '1'][j])
			j = 1 - j
	print(' '.join(res))


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	(n, k) = R()
	a = sorted(enumerate(R()), key=lambda x: x[1])
	v = [0] * n
	j = 0
	if k % 2 == 0:
		p = k // 2
		for i in a:
			if i[1] == p:
				j += 1
		j //= 2
	for i in range(n - 1, 0, -1):
		v[a[i][0]] = 1
		if a[i][1] + a[i - 1][1] < k:
			break
		elif a[i][1] == a[i - 1][1] and a[i][1] + a[i - 1][1] == k:
			if j > 1:
				j -= 1
			else:
				break
		elif a[i][1] + a[i - 1][1] == k:
			break
	print(*v)


def color(arr, T):
	bigger = []
	lower = []
	equal = []
	base = T / 2
	blanck = [0] * len(arr)
	for i in range(len(arr)):
		if arr[i] > base:
			bigger.append(i)
		elif arr[i] < base:
			lower.append(i)
		elif arr[i] == base:
			equal.append(i)
	mid = len(equal) // 2
	bigger += equal[mid:]
	lower += equal[:mid]
	for i in bigger:
		blanck[i] = 1
	print(*blanck)
	return ''
t = int(input())
for i in range(t):
	(a, b) = map(int, input().strip().split())
	print(color(list(map(int, input().strip().split())), b))


t = int(input())
for _ in range(t):
	(n, T) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	h = T / 2
	p = [0] * n
	cnt = 0
	for i in range(n):
		if a[i] < h:
			p[i] = 1
		elif a[i] == h and cnt % 2 == 0:
			p[i] = 1
			cnt += 1
		elif a[i] == h and cnt % 2 == 1:
			cnt += 1
	for i in p:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	count = 0
	for i in range(n):
		if a[i] < T / 2:
			a[i] = 1
		elif a[i] == T / 2:
			a[i] = count
			count = (count + 1) % 2
		else:
			a[i] = 0
	print(*a)


import sys
import itertools as it
import math as mt
import collections as cc
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n, s) = I()
	l = I()
	ans = [0] * n
	cnt = 0
	for i in range(n):
		if l[i] < s // 2:
			ans[i] = 1
		elif l[i] > s // 2:
			ans[i] = 0
		elif l[i] == s // 2:
			if s % 2 == 0:
				if cnt % 2 == 0:
					ans[i] = 1
				else:
					ans[i] = 0
				cnt += 1
			else:
				ans[i] = 1
	print(*ans)


import os, sys
from collections import defaultdict, Counter
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		(n, t) = map(int, input().split())
		a = [int(x) for x in input().split()]
		z = defaultdict(lambda : -1)
		x = []
		y = []
		if t % 2 == 1:
			for i in a:
				if z[i] == -1:
					z[i] = 1
					z[t - i] = 0
					y.append(z[i])
				else:
					y.append(z[i])
		else:
			x = a.count(t // 2)
			if x % 2 == 0:
				x = x // 2
				w = 1
			else:
				x = x // 2
				w = 2
			for i in a:
				if i == t // 2:
					if x != 0:
						y.append(1)
						x -= 1
					else:
						y.append(0)
				elif z[i] == -1:
					z[i] = 1
					z[t - i] = 0
					y.append(z[i])
				else:
					y.append(z[i])
		print(*y)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import os
import sys
import io
GANS = []
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	li = [int(i) for i in input().split()]
	d1 = {}
	d2 = {}
	col = []
	for i in li:
		if d1.get(k - i, 0) > d2.get(k - i, 0):
			d2[i] = d2.get(i, 0) + 1
			col.append(1)
		else:
			d1[i] = d1.get(i, 0) + 1
			col.append(0)
	print(*col)


def calc(n, T, a):
	newa = [[0, 0] for i in range(n)]
	for (i, item) in enumerate(a):
		newa[i][0] = item
		newa[i][1] = i
	newa.sort()
	sol = [0 for i in range(n)]
	breakpt = -1
	i = 1
	while i < n:
		if newa[i][0] + newa[i - 1][0] > T:
			breakpt = i
			break
		if newa[i][0] == newa[i - 1][0] and 2 * newa[i][0] == T:
			count = 1
			val = newa[i][0]
			j = i
			while j < n and newa[j][0] == val:
				j += 1
				count += 1
			breakpt = i - 1 + count // 2
			break
		if newa[i][0] + newa[i - 1][0] == T:
			breakpt = i
			break
		i += 1
	index = 0
	while index < breakpt:
		sol[newa[index][1]] = 0
		index += 1
	while index < n:
		sol[newa[index][1]] = 1
		index += 1
	print(*sol)
t = int(input())
for i in range(t):
	(n, T) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	calc(n, T, a)


import sys, math
input = lambda : sys.stdin.readline().rstrip()

def gcd(n, f):
	if n == 0 or f == 0:
		return max(n, f)
	if n > f:
		return gcd(n % f, f)
	else:
		return gcd(f % n, n)

def division_with_remainder_up(pp, ppp):
	return (pp + ppp - 1) // ppp
for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = [0] * n
	if t % 2 == 1:
		for i in range(n):
			if division_with_remainder_up(t, 2) <= a[i]:
				ans[i] = 1
		print(*ans)
	else:
		f = 1
		for i in range(n):
			if t // 2 == a[i]:
				if f % 2 == 1:
					ans[i] = 1
				f += 1
			elif t // 2 < a[i]:
				ans[i] = 1
		print(*ans)


def solve(lst, k):
	dicts = {}
	ans = []
	flag = 0
	for i in lst:
		if i * 2 == k:
			ans.append(flag)
			flag = 1 - flag
		elif i * 2 < k:
			ans.append('1')
		else:
			ans.append('0')
	return ' '.join([str(i) for i in ans])
m = int(input())
for i in range(m):
	(k, m) = map(int, input().split(' '))
	lst = list(map(int, input().split(' ')))
	print(solve(lst, m))


def solve():
	(n, t) = map(int, input().split())
	l = [i for i in map(int, input().split())]
	d = {}
	dup = {}
	for i in l:
		if i == t - i:
			dup[i] = dup.get(i, 0) + 1
		else:
			d[i] = 0
			d[t - i] = 1
	for i in range(n):
		if l[i] == t - l[i]:
			print(dup[l[i]] % 2, end=' ')
			dup[l[i]] -= 1
		else:
			print(d[l[i]], end=' ')
	print()
t = int(input())
while t:
	solve()
	t -= 1


from collections import defaultdict, Counter
import copy
from copy import deepcopy
for _ in range(int(input())):
	(n, t) = map(int, input().split())
	l = list(map(int, input().split()))
	ll = [2 for i in range(n)]
	s = 0
	for i in range(n):
		if l[i] < t / 2:
			ll[i] = 1
			s += 1
		elif l[i] > t / 2:
			ll[i] = 0
			s += 1
	c = n - s
	cc = copy.deepcopy(c)
	for i in ll:
		if i != 2:
			print(i, end=' ')
		elif c > cc // 2:
			print(0, end=' ')
			c -= 1
		else:
			print(1, end=' ')
	print()


from sys import stdin
input = lambda : stdin.readline().strip()
for _ in range(int(input())):
	(n, t) = [int(i) for i in input().split()]
	lst = [int(i) for i in input().split()]
	lst2 = []
	k = 0
	for i in lst:
		if i + i == t:
			lst2.append(-1)
		elif i + i < t:
			lst2.append(0)
		else:
			lst2.append(1)
	nm = lst2.count(-1)
	if nm > 0:
		nd = 0
		for i in range(0, n):
			if lst2[i] == -1:
				if nd < nm // 2:
					lst2[i] = 0
					nd += 1
				else:
					lst2[i] = 1
					nd += 1
	print(*lst2)


t = int(input())
for i in range(t):
	(n, T) = map(int, input().split(' '))
	l = list(map(int, input().split(' ')))
	d = dict()
	for (i, x) in enumerate(l):
		try:
			d[x].append(i)
		except KeyError:
			d[x] = [i]
	positions = ['-1'] * n
	for (i, x) in enumerate(l):
		if positions[i] == '-1':
			half = T - x
			if x != half:
				for j in d[x]:
					positions[j] = '1'
				if half in d.keys():
					for j in d[half]:
						positions[j] = '0'
			else:
				indices = d[x]
				(j, k) = (0, len(indices) - 1)
				while j < k:
					positions[indices[j]] = '1'
					positions[indices[k]] = '0'
					j += 1
					k -= 1
				if positions[indices[j]] == '-1':
					positions[indices[j]] = '1'
	print(' '.join(positions))


for tc in range(int(input())):
	(n, t) = map(int, input().split())
	arr = list(map(int, input().split()))
	zero = {}
	one = {}
	for i in arr:
		if zero.get(abs(i - t)):
			if one.get(abs(i - t)) and one[abs(i - t)] <= zero[abs(i - t)]:
				if one.get(i):
					one[i] += 1
				else:
					one[i] = 1
			elif one.get(abs(i - t)) and one[abs(i - t)] > zero[abs(i - t)]:
				if zero.get(i):
					zero[i] += 1
				else:
					zero[i] = 1
			elif one.get(i):
				one[i] += 1
			else:
				one[i] = 1
		elif zero.get(i):
			zero[i] += 1
		else:
			zero[i] = 1
	for num in arr:
		if zero.get(num) and zero[num] > 0:
			print(0, end=' ')
			zero[num] -= 1
		else:
			print(1, end=' ')
			one[num] -= 1
	print()


t = int(input())
for i in range(t):
	(n, T) = map(int, input().split())
	lst = list(map(int, input().split()))
	ans = list()
	for i in range(n):
		ans.append(0)
	c = 0
	if T % 2:
		for i in range(n):
			if lst[i] > T // 2:
				ans[i] = 1
	else:
		for i in range(n):
			if lst[i] > T // 2:
				ans[i] = 1
		for i in range(n):
			if lst[i] == T // 2:
				if c % 2:
					ans[i] = 1
				else:
					ans[i] = 0
				c += 1
	for i in range(n):
		print(ans[i], end=' ')
	print()


e = int(input())
for j in range(e):
	(n, t) = map(int, input().split())
	l = list(map(int, input().split()))
	ans = []
	if t % 2 == 0:
		t2 = 0
		for i in l:
			if i < t // 2:
				ans += [0]
			elif i > t // 2:
				ans += [1]
			elif t2:
				ans += [1]
				t2 = int(not t2)
			else:
				ans += [0]
				t2 = int(not t2)
		print(*ans)
	else:
		for i in l:
			if i <= t // 2:
				ans += [0]
			else:
				ans += [1]
		print(*ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	s = set()
	c = 0
	b = [0] * n
	for i in range(n):
		if 2 * a[i] == k:
			b[i] = c
			c = 1 - c
		elif a[i] in s:
			b[i] = 1
		else:
			s.add(k - a[i])
	print(*b)


import math

def main():
	t = int(input())
	vals = []
	for t_ in range(t):
		(n, T) = list(map(int, input().split(' ')))
		arr = list(map(int, input().split(' ')))
		c = [0] * len(arr)
		cher = 0
		t_2 = T // 2
		mapdict = dict()
		if T % 2 == 0:
			for (i, val) in enumerate(arr):
				if val == t_2:
					c[i] = cher
					cher ^= 1
				elif val in mapdict:
					c[i] = mapdict[val]
				elif T - val in mapdict:
					mapdict[val] = mapdict[T - val] ^ 1
					c[i] = mapdict[val]
				else:
					mapdict[val] = 0
		else:
			for (i, val) in enumerate(arr):
				c[i] = val % 2
		print(' '.join(list(map(str, c))))
	for val in vals:
		print(val)
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	ans = []
	c = 0
	for i in l:
		if i < k // 2:
			ans.append(0)
		elif i == k // 2:
			if k % 2:
				ans.append(0)
			elif c == 0:
				ans.append(0)
				c = 1
			else:
				ans.append(1)
				c = 0
		else:
			ans.append(1)
	print(*ans)


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	array = list(map(int, input().split()))
	count = {}
	for i in range(n):
		if array[i] in count:
			count[array[i]] += 1
		else:
			count[array[i]] = 1
	result = [0] * n
	for i in range(n):
		if t - array[i] in count.keys():
			if t - array[i] == array[i]:
				if count[array[i]] == 1:
					del count[array[i]]
				elif count[array[i]] % 2 == 0:
					result[i] = 1
					count[array[i]] -= 1
				else:
					count[array[i]] -= 1
			elif array[i] > t - array[i]:
				result[i] = 1
	print(' '.join(map(str, result)))


for T in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	(arr, d) = ([], {})
	for i in range(len(a)):
		arr.append([a[i], i])
		d[a[i], i] = 0
	arr.sort(key=lambda x: x[0])
	(i, j) = (0, n - 1)
	while i < j:
		if arr[i][0] + arr[j][0] <= t:
			if arr[i][0] + arr[j][0] == t:
				d[arr[i][0], arr[i][1]] = 1
				if arr[i][0] == arr[j][0]:
					j -= 1
			i += 1
		else:
			j -= 1
	for i in range(len(a)):
		print(d[a[i], i], end=' ')
	print()


t = int(input())
while t:
	(n, m) = map(int, input().split())
	li = list(map(int, input().split()))
	ans = []
	flag = 1
	for i in li:
		if i < m / 2:
			ans.append(1)
		elif i > m / 2:
			ans.append(0)
		elif i == m / 2 and flag == 1:
			ans.append(1)
			flag = 0
		else:
			ans.append(0)
			flag = 1
	for i in ans:
		print(i, end=' ')
	print()
	t -= 1


for _ in range(int(input())):
	(n, t) = [int(c) for c in input().split()]
	arr = [int(c) for c in input().split()]
	val = 0
	ans = [0 for i in range(n)]
	for i in range(n):
		if arr[i] <= t // 2:
			ans[i] = 1
		elif arr[i] > t / 2:
			ans[i] = 0
	if t % 2 == 0:
		for i in range(n):
			if arr[i] == t // 2:
				ans[i] = val
				val = 1 - val
	print(*ans)


t = int(input())
for i in range(t):
	(n, T) = map(int, input().split())
	l = list(map(int, input().split()))
	flag = [-1] * n
	prev = 0
	if T % 2 == 1:
		for j in range(n):
			if l[j] % 2 == 0:
				flag[j] = 0
			else:
				flag[j] = 1
	else:
		for j in range(n):
			if l[j] == T / 2:
				if prev == 0:
					flag[j] = 1
					prev = 1
				else:
					flag[j] = 0
					prev = 0
			elif l[j] < T / 2:
				flag[j] = 0
			else:
				flag[j] = 1
	print(' '.join(map(str, flag)))


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
decimal.getcontext().prec = 46

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def modefiedSieve():
	mx = 10 ** 7 + 1
	sieve = [-1] * mx
	for i in range(2, mx):
		if sieve[i] == -1:
			sieve[i] = i
			for j in range(i * i, mx, i):
				if sieve[j] == -1:
					sieve[j] = i
	return sieve

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def DFS(n, s, adj):
	visited = [False for i in range(n + 1)]
	stack = []
	stack.append(s)
	while len(stack):
		s = stack[-1]
		stack.pop()
		if not visited[s]:
			visited[s] = True
		for node in adj[s]:
			if not visited[node]:
				stack.append(node)

def maxSubArraySum(a, size):
	maxint = 10 ** 10
	max_so_far = -maxint - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far

def solve():
	(n, k) = num_input()
	arr = list_input()
	num = {}
	for i in range(n):
		try:
			num[arr[i]].append(i)
		except KeyError:
			num[arr[i]] = [i]
	ans = [0] * n
	for i in num.keys():
		x = k - i
		while num[i] != []:
			pos = num[i].pop(0)
			ans[pos] = 0
			if i <= k:
				try:
					if num[x] != []:
						temp = num[x].pop(0)
						ans[temp] = 1
				except KeyError:
					ans[pos] = 0
		if i <= k:
			try:
				while num[x] != []:
					temp = num[x].pop(0)
					ans[temp] = 1
			except KeyError:
				pass
	print(*ans)
t = 1
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	ls = list(map(int, input().split()))
	d1 = dict()
	d2 = dict()
	d3 = dict()
	ans = [-1] * n
	for i in range(n):
		if d1.get(ls[i]) is None:
			d1[ls[i]] = 1
		else:
			d1[ls[i]] += 1
	for i in range(n):
		if d1.get(t - ls[i]) is not None:
			if d2.get(t - ls[i]) is not None and d3.get(t - ls[i]) is not None:
				if d2[t - ls[i]] < d3[t - ls[i]]:
					ans[i] = 0
					if d2.get(ls[i]) is None:
						d2[ls[i]] = 1
					else:
						d2[ls[i]] += 1
				else:
					ans[i] = 1
					if d3.get(ls[i]) is None:
						d3[ls[i]] = 1
					else:
						d3[ls[i]] += 1
			elif d2.get(t - ls[i]) is not None:
				ans[i] = 1
				if d3.get(ls[i]) is None:
					d3[ls[i]] = 1
				else:
					d3[ls[i]] += 1
			elif d3.get(t - ls[i]) is not None:
				ans[i] = 0
				if d2.get(ls[i]) is None:
					d2[ls[i]] = 1
				else:
					d2[ls[i]] += 1
			else:
				ans[i] = 1
				if d3.get(ls[i]) is None:
					d3[ls[i]] = 1
				else:
					d3[ls[i]] += 1
		else:
			ans[i] = 0
			if d3.get(ls[i]) is None:
				d3[ls[i]] = 1
			else:
				d3[ls[i]] += 1
	print(*ans)


from collections import Counter
t = int(input())
for _ in range(t):
	(n, T) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	ans = [0] * n
	(c_Counter, d_Counter) = (Counter(), Counter())
	for i in range(n):
		no = a[i]
		if c_Counter[T - no] > d_Counter[T - no]:
			ans[i] = 1
			d_Counter[no] += 1
		else:
			c_Counter[no] += 1
	print(' '.join(map(str, ans)).strip())


import math
teststring = '2\n6 7\n1 2 3 4 5 6\n3 6\n3 3 3\n'
online = __file__ != '/home/jhli/py/673/Problem_B.py'
(true, false) = (True, False)
if True:

	def spitout():
		for c in teststring.splitlines():
			yield c
	_ito = spitout()
	if not online:

		def input():
			return next(_ito)

	def build_enum(*a):
		built = dict()
		for (i, c) in enumerate(a):
			built[c] = i
		return lambda x: built[x]
T = int(input())
for ti in range(1, T + 1):
	[n, k] = map(int, input().split(' '))
	a = []
	a.extend([int(e) for e in input().split(' ')])
	l = len(a)
	s_keys = sorted(range(l), key=lambda k: a[k])
	colors = [0] * l
	parity = True
	for i in range(l):
		key = s_keys[i]
		if a[key] < k / 2:
			colors[key] = 0
		elif a[key] > k / 2:
			colors[key] = 1
		else:
			colors[key] = int(parity)
			parity = not parity
	print(' '.join(map(str, colors)))


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = [int(x) for x in input().split()]
	ans = [0] * n
	d = {}
	for i in range(0, n):
		x = t - a[i]
		if x in d:
			ans[i] = 1 - d[x]
			d[a[i]] = 1 - d[x]
		else:
			d[a[i]] = 0
	print(*ans)


from sys import stdin

def colour(numbers, unlucky):
	indexed = list(enumerate(numbers))
	indexed.sort(key=lambda x: x[1])
	(index, a) = zip(*indexed)
	colours = [0] * len(a)
	back_idx = len(a) - 1
	front_idx = 0
	while a[back_idx] > unlucky and back_idx > 0:
		back_idx -= 1
	while a[front_idx] != a[back_idx] and front_idx < back_idx:
		back_val = a[back_idx]
		diff = unlucky - back_val
		while a[front_idx] < diff and a[front_idx] < back_val:
			front_idx += 1
		if a[front_idx] == a[back_idx]:
			break
		while a[front_idx] == diff:
			colours[front_idx] = 1
			front_idx += 1
		while a[back_idx] == back_val:
			back_idx -= 1
	if front_idx < back_idx:
		to_split = back_idx - front_idx + 1
		colours[front_idx:front_idx + to_split // 2] = [1] * (to_split // 2)
	result = [0] * len(a)
	for (idx, colour) in enumerate(colours):
		result[index[idx]] = colour
	return result
tests = int(stdin.readline().rstrip())
for _ in range(tests):
	(_, unlucky) = map(int, stdin.readline().rstrip().split())
	a = list(map(int, stdin.readline().rstrip().split()))
	print(' '.join(map(str, colour(a, unlucky))))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
for _ in range(N()):
	(n, k) = RL()
	a = RLL()
	res = []
	dic = {}
	flag = 0
	for i in a:
		if k & 1 == 0 and i == k >> 1:
			res.append(flag)
			flag ^= 1
		elif k - i not in dic:
			res.append(0)
			dic[i] = 1
		else:
			res.append(1)
	print_list(res)


import sys
input = sys.stdin.buffer.readline
from collections import defaultdict
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	d = defaultdict(int)
	if k % 2 == 0:
		el = k // 2
	else:
		el = None
	c = 0
	for i in range(n):
		if a[i] == el:
			c += 1
		elif a[i] in d:
			pass
		elif k - a[i] in d:
			if d[k - a[i]] == 0:
				d[a[i]] = 1
			else:
				d[a[i]] = 0
		else:
			d[a[i]] = 0
	c //= 2
	ans = [0] * n
	for i in range(n):
		if a[i] == el:
			if c > 0:
				ans[i] = 1
				c -= 1
		else:
			ans[i] = d[a[i]]
	print(*ans)


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c for j in range(b)] for i in range(a)]

def list3d(a, b, c, d):
	return [[[d for k in range(c)] for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** (-10)
for _ in range(INT()):
	(N, T) = MAP()
	A = LIST()
	C = Counter(A)
	D = {}
	ans = [-1] * N
	for (k1, v) in C.items():
		if k1 in D:
			continue
		k2 = T - k1
		if k1 == k2:
			cnt = v // 2
			for i in range(N):
				if A[i] == k1:
					if cnt:
						ans[i] = 0
						cnt -= 1
					else:
						ans[i] = 1
		else:
			D[k1] = 0
			D[k2] = 1
	for i in range(N):
		if ans[i] == -1:
			ans[i] = D[A[i]]
	print(*ans)


t = int(input())
for _ in range(t):
	(n, T) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	dict1 = {}
	dict2 = {}
	for i in range(n):
		if arr[i] not in dict1.keys():
			dict1[arr[i]] = 1
			dict2[arr[i]] = [i]
		else:
			dict1[arr[i]] += 1
			dict2[arr[i]].append(i)
	ans = [0] * n
	lis = [0] * n
	for i in range(n):
		if lis[i] == 0:
			a = T - arr[i]
			b = dict1[arr[i]]
			if a in dict1.keys():
				c = dict1[a]
				if a == arr[i]:
					for j in range(c // 2):
						ans[dict2[arr[i]][j]] = 1
						lis[dict2[arr[i]][j]] = 1
					for j in range(c):
						lis[dict2[arr[i]][j]] = 1
				else:
					for j in range(b):
						ans[dict2[arr[i]][j]] = 1
						lis[dict2[arr[i]][j]] = 1
					for j in range(c):
						lis[dict2[a][j]] = 1
	print(' '.join((str(x) for x in ans)))


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = list()
	k = True
	for i in a:
		if i < t / 2:
			ans.append(0)
		elif i == t / 2:
			if k:
				ans.append(0)
				k = False
			else:
				ans.append(1)
				k = True
		else:
			ans.append(1)
	print(*ans)


for ad in range(int(input())):
	(n, t) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	a = [0] * n
	if t % 2 == 0:
		if t // 2 in l:
			c = l.count(t // 2)
			c1 = c // 2
			for i in range(n):
				if l[i] > t // 2:
					a[i] = 1
				elif l[i] == t // 2 and c > c1:
					c -= 1
					a[i] = 1
				else:
					a[i] = 0
		else:
			for i in range(n):
				if l[i] > t // 2:
					a[i] = 1
				else:
					a[i] = 0
	else:
		for i in range(n):
			if l[i] > t // 2:
				a[i] = 1
			else:
				a[i] = 0
	for i in range(n):
		print(a[i], end=' ')
	print()


import math
import sys

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	(n, T) = Read.list_int()
	a = Read.list_int()
	tmp = {}
	res = []
	for i in a:
		v = T - i
		r = '1'
		if v in tmp:
			if tmp[v] == '1':
				r = '0'
		tmp[i] = r
		res.append(r)
	print(' '.join(res))
query_count = Read.int()
while query_count:
	query_count -= 1
	solve()


from collections import defaultdict
for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	dic = defaultdict(lambda : 0)
	for i in a:
		dic[i] = 1
	ans = [0] * n
	for i in range(n):
		if k - a[i] == a[i]:
			if dic[a[i]] == 1:
				ans[i] = 1
				dic[a[i]] = 0
			else:
				ans[i] = 0
				dic[a[i]] = 1
		elif dic[k - a[i]] == 1:
			dic[a[i]] = 0
			ans[i] = 1
	print(*ans)


from bisect import *
from collections import *
from math import *
from heapq import *
from typing import List
from itertools import *
from operator import *
from functools import *
import sys
from time import time
start = time()
t = 1000
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	s = set()
	ans = []
	if k & 1:
		for a in arr:
			if k - a not in s:
				s.add(a)
				ans.append(1)
			else:
				ans.append(0)
	else:
		cur = 0
		for a in arr:
			if a != k // 2:
				if k - a not in s:
					s.add(a)
					ans.append(1)
				else:
					ans.append(0)
			else:
				ans.append(cur)
				cur ^= 1
	ans = map(str, ans)
	print(' '.join(ans))


t = int(input())
ns = []
for i in range(t):
	(n, te) = map(int, input().split())
	arr = list(map(int, input().split()))
	color = []
	c = set()
	if te % 2 != 0:
		for el in arr:
			if te - el not in c:
				color.append(0)
				c.add(el)
			else:
				color.append(1)
	else:
		num = arr.count(te // 2)
		ctr = 0
		for el in arr:
			if el == te // 2:
				if ctr >= num // 2:
					color.append(1)
				else:
					color.append(0)
				ctr += 1
			elif te - el not in c:
				color.append(0)
				c.add(el)
			else:
				color.append(1)
	ns.append(color)
for el in ns:
	print(' '.join(list(map(str, el))))


import math
T = int(input())
for t in range(T):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	d = False
	T2 = T // 2
	con = a.count(T // 2)
	if T % 2 == 1:
		con = 0
		T2 += 0.5
	con //= 2
	ans = [0] * n
	for i in range(n):
		if a[i] < T2:
			ans[i] = '0'
		elif a[i] > T2:
			ans[i] = '1'
		elif con:
			ans[i] = '0'
			con -= 1
		else:
			ans[i] = '1'
	print(' '.join(ans))


for _ in range(int(input())):
	(n, t) = [int(i) for i in input().split()]
	nums = [int(i) for i in input().split()]
	ans = []
	i = 0
	check = t // 2
	if t % 2 == 0:
		for num in nums:
			if num < check:
				ans.append(0)
			elif num > check:
				ans.append(1)
			else:
				ans.append(i % 2)
				i += 1
	else:
		for num in nums:
			if num < check:
				ans.append(0)
			elif num > check:
				ans.append(1)
			else:
				ans.append(0)
	print(' '.join([str(i) for i in ans]))


import sys
import math

def ints():
	return list(map(int, sys.stdin.readline().strip().split()))
T = int(input())
while T:
	T -= 1
	(n, k) = map(int, input().split())
	ls = ints()
	ans = 0
	if k % 2 != 0:
		for i in ls:
			if i <= k // 2:
				print(0, end=' ')
			else:
				print(1, end=' ')
	else:
		for i in ls:
			if i < k // 2:
				print(0, end=' ')
			elif i > k // 2:
				print(1, end=' ')
			else:
				print(ans, end=' ')
				ans = 1 - ans
	print()


t = int(input())
for _ in range(t):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	a = [[a[i], i] for i in range(n)]
	a.sort()
	d = ['0'] * n
	(i, j) = (0, n - 1)
	while i < j and j < n:
		if a[i][0] + a[j][0] == T:
			d[a[j][1]] = '1'
			while a[i + 1][0] != a[i][0] and a[j - 1][0] == a[j][0]:
				d[a[j - 1][1]] = '1'
				j -= 1
			while a[j - 1][0] != a[j][0] and a[i + 1][0] == a[i][0]:
				i += 1
			i += 1
			j -= 1
		elif a[i][0] + a[j][0] < T:
			i += 1
		else:
			j -= 1
	print(' '.join(d))


import sys
sys.setrecursionlimit(2000)
from collections import Counter
from functools import reduce
t = [int(val) for val in sys.stdin.readline().split()][0]
for test in range(t):
	(n, T) = [int(val) for val in sys.stdin.readline().split()]
	a = [int(val) for val in sys.stdin.readline().split()]
	a = [(val, ind) for (ind, val) in enumerate(a)]
	a.sort(key=lambda x: x[0])
	inds_map = [val[1] for val in a]
	a = [val[0] for val in a]
	ans = [0] * n
	ind1 = 0
	ind2 = n - 1
	bads = {}
	while ind1 < ind2:
		fval = a[ind1]
		bval = a[ind2]
		summ = fval + bval
		diff = T - summ
		if diff == 0:
			inds = []
			while ind2 >= 0 and a[ind2] == bval:
				inds.append(inds_map[ind2])
				ind2 -= 1
			bads[fval, bval] = inds
			ind1 += 1
		elif diff < 0:
			ind2 -= 1
		else:
			ind1 += 1
	for (key, inds) in bads.items():
		(val1, val2) = key
		if val1 == val2:
			for (ind, val) in enumerate(inds):
				if ind % 2 != 0:
					ans[val] = 1
		else:
			for ind in inds:
				ans[ind] = 1
	for val in ans:
		print(val, end=' ')
	print('')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	arr = list(map(int, input().split()))
	b = b / 2
	y = 0
	for i in arr:
		if i > b:
			print('1', end=' ')
		elif i < b:
			print('0', end=' ')
		else:
			print(y, end=' ')
			y = (y + 1) % 2
	print()


import sys
import math
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = [int(x) for x in input().split()]
	ans = [0 for i in range(n)]
	if k % 2 == 1:
		for i in range(n):
			if l[i] % 2 == 0:
				ans[i] = 1
	else:
		for i in range(n):
			if l[i] < k / 2:
				ans[i] = 1
		a = l.count(k // 2)
		if a > 1:
			b = a // 2
			for i in range(n):
				if l[i] == k // 2:
					ans[i] = 1
					b -= 1
				if b == 0:
					break
	print(*ans)


for i in range(int(input())):
	(n, t) = map(int, input().split())
	list = [x for x in map(int, input().split())]
	flag = 0
	for j in list:
		if j < t / 2:
			print(1, end=' ')
		elif j > t / 2:
			print(0, end=' ')
		elif flag == 0:
			print(0, end=' ')
			flag = 1
		else:
			print(1, end=' ')
			flag = 0
	print('')


for _ in range(int(input())):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	s0 = set([])
	s1 = set([])
	alst = []
	for i in a:
		if i in s0:
			alst.append(0)
			if i <= T:
				if T - i == i:
					s0.remove(i)
					s1.add(T - i)
				else:
					s1.add(T - i)
		elif i in s1:
			alst.append(1)
			if i <= T:
				if T - i == i:
					s1.remove(i)
					s0.add(T - i)
				else:
					s0.add(T - i)
		else:
			alst.append(0)
			if i <= T:
				if T - i == i:
					s1.add(T - i)
				else:
					s0.add(i)
					s1.add(T - i)
	print(*alst)


for _ in ' ' * int(input()):
	(n, t) = map(int, input().split())
	(a, cnt) = (list(map(int, input().split())), 0)
	for i in range(n):
		if a[i] < t / 2:
			a[i] = 1
		elif a[i] > t / 2:
			a[i] = 0
		else:
			if cnt % 2:
				a[i] = 1
			else:
				a[i] = 0
			cnt += 1
	print(*a)


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	d = {}
	for i in a:
		d[i] = d.get(i, 0) + 1
	aa = []
	bb = []
	pairs = []
	f = {}
	cnt = {}
	for i in a:
		if d[i] > 0:
			rem = t - i
			try:
				if d[rem] > 0:
					if rem == i:
						total = d[rem]
						aa += [i] * (total // 2)
						bb += [i] * (total - total // 2)
						f[i] = d[i]
						d[i] = -2
					else:
						aa += [i] * d[i]
						d[i] = -1
						bb += [rem] * d[rem]
						d[rem] = 0
			except:
				pass
	for i in d:
		if d[i] > 0:
			aa += [i] * d[i]
			d[i] = -1
	ans = []
	for i in a:
		if d[i] == -1:
			ans.append(0)
		elif d[i] == -2:
			cnt[i] = cnt.get(i, 0) + 1
			if cnt[i] <= f[i] // 2:
				ans.append(0)
			else:
				ans.append(1)
		else:
			ans.append(1)
	print(*ans)


import sys, collections as cc
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(t,) = I()
for _ in range(t):
	(n, k) = I()
	l = I()
	an = [0] * n
	md = k // 2
	for i in range(n):
		if l[i] > md:
			an[i] = 1
	if k % 2:
		print(*an)
	else:
		rr = l.count(md)
		rr //= 2
		for i in range(n):
			if rr and l[i] == md:
				an[i] = 1
				rr -= 1
		print(*an)


t = int(input())
for i in range(t):
	col = 0
	(n, T) = [int(i) for i in input().split()]
	ans = []
	a = [int(i) for i in input().split()]
	for i in range(n):
		res = 0
		if T % 2 == 0 and a[i] == T // 2:
			res = col % 2
			col += 1
		elif 2 * a[i] < T:
			res = 0
		else:
			res = 1
		ans.append(res)
	print(*ans)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for _ in range(t):
	(n, T) = map(int, input().split())
	a = [int(x) for x in input().split()]
	if T % 2 != 0:
		for i in range(n):
			if a[i] <= T // 2:
				a[i] = 0
			else:
				a[i] = 1
		print(*a)
	else:
		flag = 0
		for i in range(n):
			if a[i] < T // 2:
				a[i] = 0
			elif a[i] == T // 2:
				a[i] = flag
				flag = flag ^ 1
			else:
				a[i] = 1
		print(*a)


for _ in range(int(input())):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	res = []
	i = 0
	for x in a:
		if x < T / 2:
			res.append(0)
		elif x == T / 2:
			res.append(i)
			i ^= 1
		else:
			res.append(1)
	print(*res)


import math

def inp():
	return int(input())

def insr():
	s = input()
	return s

def inlt():
	return list(map(int, input().split()))

def inlts():
	return input().split()

def dig_sum(s):
	return sum([int(i) for i in s])

def solve(l, k):
	ans = []
	last = 0
	for i in range(len(l)):
		if l[i] < k / 2:
			ans.append(0)
		elif l[i] > k / 2:
			ans.append(1)
		else:
			ans.append(last)
			last = 1 - last
	return ans
r = inp()
for i in range(r):
	l2 = inlt()
	l = inlt()
	print(' '.join([str(i) for i in solve(l, l2[1])]))


t = int(input())
for test in range(t):
	(n, k) = [int(i) for i in input().split(' ')]
	l = [int(i) for i in input().split(' ')]
	mid = 0
	c = [0 for i in range(n)]
	for j in range(n):
		if l[j] > k / 2:
			c[j] = 1
		elif l[j] == k / 2:
			c[j] = mid
			mid = (mid + 1) % 2
	res = ''
	for i in range(n):
		res = res + str(c[i]) + ' '
	print(res)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	g = []
	c = 0
	for j in range(n):
		if k % 2 != 0:
			if a[j] <= k // 2:
				g.append(0)
			else:
				g.append(1)
		elif a[j] < k // 2:
			g.append(0)
		elif a[j] == k // 2:
			if c % 2 == 0:
				g.append(0)
				c = c + 1
			else:
				g.append(1)
				c = c + 1
		else:
			g.append(1)
	print(' '.join(map(str, g)))


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop, heapify
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
from itertools import accumulate
from functools import lru_cache
M = mod = 998244353

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	(n, t) = li()
	l = li()
	if n == 1:
		print(0)
		continue
	seta = Counter()
	setb = Counter()
	for i in l:
		if seta[t - i] < setb[t - i]:
			seta[i] += 1
		else:
			setb[i] += 1
	index = defaultdict(list)
	for i in range(n):
		index[l[i]].append(i)
	ans = set()
	for i in seta:
		for j in range(seta[i]):
			ans.add(index[i].pop())
	l = [1] * n
	for i in range(n):
		if i in ans:
			l[i] = 0
	print(*l)


def solve(n, T, res):
	f = 1
	ans = []
	for i in range(n):
		r = 0
		if T % 2 == 0 and res[i] == T // 2:
			r = f
			if f == 0:
				f = 1
			else:
				f = 0
		elif 2 * res[i] < T:
			r = 0
		else:
			r = 1
		ans.append(r)
	return ans
t = int(input())
while t:
	res = []
	(n, T) = map(int, input().split(' '))
	in_ = map(int, input().split(' '))
	for x in in_:
		res.append(int(x))
	print(*solve(n, T, res))
	t -= 1


from functools import lru_cache
from sys import stdin, stdout
import sys
from math import *
input = stdin.readline
for __ in range(int(input())):
	(n, k) = map(int, input().split())
	ar = list(map(int, input().split()))
	a = []
	for i in range(n):
		a.append([ar[i], i])
	d = {}
	ans = [0] * n
	a.sort()
	for i in range(n - 1, -1, -1):
		if k - a[i][0] < a[i][0]:
			ans[a[i][1]] = 1
	if k % 2 == 0 and k // 2 in ar:
		s = ar.count(k // 2) // 2
		for i in range(n):
			if ar[i] == k // 2 and s > 0:
				s -= 1
				ans[i] = 1
	print(*ans)


for w in range(int(input())):
	(n, t) = tuple(map(int, input().split()))
	a1 = list(map(int, input().split()))
	a = sorted(a1)
	c = 0
	b = {}
	i = 0
	j = n - 1
	if t % 2 != 0:
		while i < j:
			if a[i] + a[j] == t:
				if a[j] not in b:
					b[a[j]] = 1
				else:
					b[a[j]] += 1
				if a[j] == a[j - 1]:
					j -= 1
				else:
					i += 1
					j -= 1
			elif a[i] + a[j] > t:
				j -= 1
			else:
				i += 1
	else:
		c = a.count(t // 2)
		c = c // 2
		for r in range(n):
			if a[r] == t // 2 and c > 0:
				if a[r] not in b:
					b[a[r]] = 1
				else:
					b[a[r]] += 1
				c -= 1
		while i < j:
			if a[i] != t // 2 and a[i] + a[j] == t:
				if a[j] not in b:
					b[a[j]] = 1
				else:
					b[a[j]] += 1
				if a[j] == a[j - 1]:
					j -= 1
				else:
					i += 1
					j -= 1
			elif a[i] + a[j] > t:
				j -= 1
			else:
				i += 1
	for i in range(n):
		if a1[i] not in b or b[a1[i]] == 0:
			print(0, end=' ')
		else:
			b[a1[i]] -= 1
			print(1, end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	num_half = 0 if T % 2 else a.count(T // 2)
	num_half_left = num_half // 2
	assignments = []
	for a_i in a:
		if a_i == T // 2:
			if num_half_left:
				num_half_left -= 1
				assignments.append(1)
			else:
				assignments.append(0)
		else:
			assignments.append(1 if a_i > T // 2 else 0)
	print(*assignments)


k = int(input())
for m in range(k):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	b = [0] * n
	u = 0
	for i in range(n):
		if a[i] < T / 2:
			b[i] = 0
		elif a[i] > T / 2:
			b[i] = 1
		else:
			u ^= 1
			b[i] = u
	for x in b:
		print(x, end=' ')
	print()


def test_case():
	(n, T) = map(int, input().split())
	arr = list(map(int, input().split()))
	s = ''
	flag = 0
	white = set()
	black = set()
	for a in arr:
		if T % 2 == 0 and a == T // 2:
			if flag == 1:
				s += '0 '
				flag = 0
			else:
				s += '1 '
				flag = 1
		elif a in white:
			s += '1 '
		elif a in black:
			s += '0 '
		elif T - a in white:
			black.add(a)
			s += '0 '
		else:
			white.add(a)
			s += '1 '
	print(s.strip())

def main():
	cases = int(input())
	for _ in range(cases):
		test_case()
main()


R = lambda : map(int, input().split())
(t,) = R()
for _ in [0] * t:
	(n, T) = R()
	(a, b) = zip(*sorted(zip(R(), range(n))))
	r = [0] * n
	i = j = 0
	for x in a:
		i += 2 * x < T
		j += 2 * x <= T
	for i in b[i + j + 1 >> 1:]:
		r[i] = 1
	print(*r)


from collections import Counter
for tc in range(int(input())):
	(n, T) = map(int, input().split())
	s = list(map(int, input().split()))
	sB = Counter()
	sW = Counter()
	ans = []
	for i in s:
		if sB[T - i] < sW[T - i]:
			sB[i] += 1
			ans.append('1')
		else:
			sW[i] += 1
			ans.append('0')
	print(' '.join(ans))


t = int(input())
for case in range(t):
	(n, T) = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split(' ')]
	i = 0
	p = []
	for x in a:
		if x < T / 2:
			p.append(0)
		elif x > T / 2:
			p.append(1)
		else:
			p.append(i)
			i = 1 - i
	print(*p)


for I in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	d = []
	if t % 2 != 0:
		for i in range(n):
			if a[i] <= t // 2:
				d.append(1)
			else:
				d.append(0)
	else:
		p = 0
		for i in range(n):
			if a[i] < t // 2:
				d.append(1)
			elif a[i] > t // 2:
				d.append(0)
			else:
				d.append(p)
				p = (p + 1) % 2
	print(*d)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	l = []
	if k % 2 != 0:
		for i in range(n):
			print(a[i] % 2, end=' ')
		print()
	else:
		f = 0
		p = k // 2
		for i in range(n):
			if a[i] < p:
				print(0, end=' ')
			elif a[i] > p:
				print(1, end=' ')
			elif a[i] == p:
				if f == 0:
					print(0, end=' ')
					f = 1
				else:
					print(1, end=' ')
					f = 0
		print()


import math
t = int(input())
for _ in range(t):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	r = t / 2
	ans = []
	m = 1
	for i in range(0, n):
		if a[i] < r:
			ans.append(1)
		elif a[i] > r:
			ans.append(0)
		else:
			ans.append(m)
			m = 1 if m == 0 else 0
	print(*ans)


t = int(input())
for q in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = [None] * len(arr)
	for i in range(len(arr)):
		if arr[i] < k / 2:
			ans[i] = 0
		elif arr[i] > k / 2:
			ans[i] = 1
	cnt = 0
	for i in range(len(arr)):
		if arr[i] == k / 2:
			cnt += 1
			ans[i] = cnt % 2
	for i in ans:
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, t) = [int(p) for p in input().split()]
	arr = [int(p) for p in input().split()]
	freq = {}
	for i in arr:
		if i not in freq:
			freq[i] = 1
		else:
			freq[i] += 1
	counter = {}
	for i in range(len(arr)):
		if t - arr[i] in freq and t - arr[i] not in counter:
			counter[arr[i]] = freq[t - arr[i]]
	clr = [0] * n
	if t % 2 != 0:
		for i in range(len(arr)):
			if arr[i] in counter:
				clr[i] = 1
		print(*clr)
	else:
		sw = 1
		for i in range(len(arr)):
			if arr[i] == t // 2:
				clr[i] = sw
				sw = 1 - sw
		if t // 2 in counter:
			del counter[t // 2]
		for i in range(len(arr)):
			if arr[i] in counter:
				clr[i] = 1
		print(*clr)


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	(values, colours, last) = ([int(i) for i in input().split()], [-1 for i in range(n)], 0)
	for i in range(n):
		if values[i] == t / 2:
			if last % 2:
				colours[i] = 0
			else:
				colours[i] = 1
			last += 1
		elif values[i] > t / 2:
			colours[i] = 1
		else:
			colours[i] = 0
	print(*colours)


test_cases = int(input())
for test_case in range(test_cases):
	(n, t) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	zero = []
	one = []
	x = t // 2
	p = []
	count = 0
	for i in a:
		if i > x:
			p.append(1)
		elif i < x:
			p.append(0)
		elif t % 2 == 1:
			p.append(0)
		elif count % 2 == 0:
			p.append(0)
			count += 1
		else:
			p.append(1)
			count += 1
	print(*p)


t = int(input())
for _ in range(t):
	(_, T) = [int(i) for i in input().split()]
	A = [int(i) for i in input().split()]
	cnt = 0
	P = []
	for a in A:
		if a < T / 2:
			P += ['1']
		elif a > T / 2:
			P += ['0']
		else:
			P += [str(cnt)]
			cnt = (cnt + 1) % 2
	print(' '.join(P))


import collections
T = input()
T = int(T)
for t in range(T):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	arr = [int(v) for v in input().split()]
	counter = collections.Counter(arr)
	d = {}
	for (a, val) in counter.items():
		b = k - a
		if a == b:
			d[a] = -1
			half_count = val // 2
		elif a not in d:
			d[a] = 0
			d[b] = 1
	res = []
	half_counter = 0
	for a in arr:
		c = d[a]
		if c == -1:
			if half_counter < half_count:
				c = 0
			else:
				c = 1
			half_counter += 1
		res.append(c)
	res = ' '.join(map(str, res))
	print(res)


import sys
sys.setrecursionlimit(1000000)
T = int(input())
for _ in range(T):
	(n, t) = (int(x) for x in input().split())
	a = [int(x) for x in input().split()]
	res = []
	flag = 0
	for x in a:
		if x * 2 == t:
			res.append(flag)
			flag = 1 - flag
		elif x * 2 < t:
			res.append(0)
		else:
			res.append(1)
	print(' '.join([str(x) for x in res]))


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	b = False
	for i in a:
		if i < t / 2:
			print(1, end=' ')
		elif i > t / 2:
			print(0, end=' ')
		elif not b:
			print(1, end=' ')
			b = True
		else:
			print(0, end=' ')
			b = False
	print()


def solve():
	(n, T) = map(int, input().split())
	arr = list(map(int, input().split()))
	a = {}
	b = {}
	result = []
	for i in range(len(arr)):
		if arr[i] not in a:
			a[T - arr[i]] = 0
			result.append(1)
		elif arr[i] not in b:
			b[T - arr[i]] = 0
			result.append(0)
		else:
			count_a = a[arr[i]]
			count_b = b[arr[i]]
			if count_a < count_b:
				a[arr[i]] += 1
				result.append(1)
			else:
				b[arr[i]] += 1
				result.append(0)
	print(*result)
t = int(input())
while t:
	solve()
	t -= 1


T = int(input())
for _ in range(T):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	s = set()
	ans = [0] * n
	for i in range(n):
		if not a[i] in s:
			ans[i] = 1
			s.add(t - a[i])
		else:
			ans[i] = 0
			s.add(a[i])
			try:
				s.remove(t - a[i])
			except:
				pass
	print(*ans)


import math

def solve(n, k, l):
	res = [-1] * n
	vals = {}
	for i in range(n):
		if vals.get(l[i]):
			vals[l[i]].append(i)
		else:
			vals[l[i]] = []
			vals[l[i]].append(i)
	for i in range(n):
		x = abs(l[i] - k)
		if res[i] == -1:
			if vals.get(x):
				i2 = vals.get(x).pop()
				if l[i] < l[i2]:
					res[i] = 0
					res[i2] = 1
				else:
					res[i] = 1
					res[i2] = 0
			elif x > l[i]:
				res[i] = 0
			else:
				res[i] = 1
	return res
t = int(input())
while t:
	(n, k) = map(int, input().split(' '))
	l = list(map(int, input().split(' ')))
	res = solve(n, k, l)
	for i in range(n):
		print(res[i], end=' ')
	print()
	t = t - 1


from collections import Counter
for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	if t % 2:
		half = t // 2
		for i in range(n):
			if a[i] <= half:
				print(0, end=' ')
			else:
				print(1, end=' ')
		print()
	else:
		half = t // 2
		count = Counter(a)
		diff = count[half] // 2
		for i in range(n):
			if a[i] < half:
				print(0, end=' ')
			elif a[i] == half:
				if diff > 0:
					print(0, end=' ')
					diff -= 1
				else:
					print(1, end=' ')
			else:
				print(1, end=' ')
		print()


t = int(input())
for _ in range(t):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = []
	cnt = 0
	for i in range(n):
		if T % 2 == 0:
			if a[i] < T // 2:
				ans.append('0')
			elif a[i] > T // 2:
				ans.append('1')
			else:
				ans.append(str(cnt % 2))
				cnt += 1
		elif a[i] <= T // 2:
			ans.append('0')
		elif a[i] > T // 2:
			ans.append('1')
	print(' '.join(ans))


from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor, inf
from heapq import *
from typing import List
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

@lru_cache(None)
def fact(x, mod=0):
	if x < 2:
		return 1
	if not mod:
		return fact(x - 1) * x
	return fact(x - 1, mod) * x % mod

@lru_cache(None)
def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	ans = 1
	for k in range(i - j + 1, i + 1):
		ans = ans * k % mod
	return ans

@lru_cache(None)
def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j) * inverse(fact(j), mod) % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

def linc(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t > f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rinc(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t < f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def ldec(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t < f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rdec(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t > f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def binfun(x):
	c = 0
	for w in arr:
		c += ceil(w / x)
	return c

def lowbit(n):
	return n & -n

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class smt:

	def __init__(self, l, r, arr):
		self.l = l
		self.r = r
		self.value = (1 << 31) - 1 if l < r else arr[l]
		mid = (l + r) // 2
		if l < r:
			self.left = smt(l, mid, arr)
			self.right = smt(mid + 1, r, arr)
			self.value &= self.left.value & self.right.value

	def setvalue(self, x, val):
		if self.l == self.r:
			self.value = val
			return
		mid = (self.l + self.r) // 2
		if x <= mid:
			self.left.setvalue(x, val)
		else:
			self.right.setvalue(x, val)
		self.value = self.left.value & self.right.value

	def ask(self, l, r):
		if l <= self.l and r >= self.r:
			return self.value
		val = (1 << 31) - 1
		mid = (self.l + self.r) // 2
		if l <= mid:
			val &= self.left.ask(l, r)
		if r > mid:
			val &= self.right.ask(l, r)
		return val

class DSU:

	def __init__(self, n):
		self.c = [-1] * n

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def find(self, x):
		if self.c[x] < 0:
			return x
		self.c[x] = self.find(self.c[x])
		return self.c[x]

	def union(self, u, v):
		(u, v) = (self.find(u), self.find(v))
		if u == v:
			return False
		if self.c[u] < self.c[v]:
			(u, v) = (v, u)
		self.c[u] += self.c[v]
		self.c[v] = u
		return True

	def size(self, x):
		return -self.c[self.find(x)]

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return prime

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		for v in graph[u]:
			if v not in d or d[v] > d[u] + graph[u][v]:
				d[v] = d[u] + graph[u][v]
				heappush(heap, (d[v], v))
	return d
t = N()
for i in range(t):
	(n, k) = RL()
	a = RLL()
	ans = []
	if k & 1:
		for x in a:
			if x <= k // 2:
				ans.append(0)
			else:
				ans.append(1)
	else:
		cur = 0
		for x in a:
			if x < k // 2:
				ans.append(0)
			elif x == k // 2:
				ans.append(cur)
				cur ^= 1
			else:
				ans.append(1)
	print(*ans)


import math

def range_input():
	return range(int(input()))

def map_int_input():
	return list(map(int, input().split()))
for t in range_input():
	(n, T) = map_int_input()
	a = map_int_input()
	inverse = {}
	special_inverse = -1
	switch = 0
	for (idx, i) in enumerate(a):
		if T - i in inverse:
			print(1, end=' ')
			continue
		if i == special_inverse:
			if switch == 0:
				print(1, end=' ')
				switch = 1
			else:
				print(0, end=' ')
				switch = 0
			continue
		if i == T / 2:
			special_inverse = i
			print(0, end=' ')
		else:
			inverse[i] = T - i
			print(0, end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	cur = T / 2
	sum_ab = 0
	for ai in a:
		if ai == cur:
			sum_ab += 1
	cst = 0
	for ai in a:
		if ai > cur:
			print(1, end=' ')
		elif ai < cur:
			print(0, end=' ')
		else:
			cst += 1
			if cst * 2 <= sum_ab:
				print(1, end=' ')
			else:
				print(0, end=' ')
	print()


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = 1
num = int(z())
for _ in range(num):
	(n, k) = zz()
	arr = zzz()
	lst = [0] * n
	for (i, j) in enumerate(arr):
		lst[i] = (j, i)
	ans = [0] * n
	p = (k + 1) // 2
	d = -1
	for i in range(n):
		x1 = lst[i]
		x2 = x1[0]
		if d == -1 and x2 + x2 == k:
			ans[x1[1]] = 1
			d = d * -1
			continue
		if d == 1 and x2 + x2 == k:
			ans[x1[1]] = 0
			d = d * -1
			continue
		if x2 >= p:
			ans[x1[1]] = 1
	print(*ans)


def solve(n, T, A):
	ans = []
	C = {}
	D = {}
	for a in A:
		c_count = 0
		d_count = 0
		if T - a in C:
			c_count = C[T - a]
		if T - a in D:
			d_count = D[T - a]
		if c_count <= d_count:
			if a in C:
				C[a] += 1
			else:
				C[a] = 1
			ans.append(0)
		else:
			if a in D:
				D[a] += 1
			else:
				D[a] = 1
			ans.append(1)
	return ans
t = int(input())
for i in range(t):
	(n, T) = map(int, input().split())
	A = list(map(int, input().split()))
	ans = solve(n, T, A)
	for (i, a) in enumerate(ans):
		print(a, end='')
		if i != len(ans) - 1:
			print(' ', end='')
		else:
			print('')


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = []
	c = 0
	for i in range(n):
		if t % 2 == 0 and a[i] == t // 2:
			ans.append(c % 2)
			c += 1
		elif a[i] < t / 2:
			ans.append(0)
		else:
			ans.append(1)
	print(*ans)


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	data = [int(x) for x in input().split()]
	visited = [-1] * n
	pivot = t // 2
	if t % 2:
		for q in range(n):
			if data[q] <= pivot:
				visited[q] = 0
			else:
				visited[q] = 1
	else:
		for q in range(len(data)):
			if data[q] < pivot:
				visited[q] = 0
			elif data[q] > pivot:
				visited[q] = 1
	flag = 1
	for q in range(n):
		if visited[q] == -1:
			if flag == 1:
				flag = 0
				visited[q] = 0
			else:
				flag = 1
				visited[q] = 1
	for q in visited:
		print(q, end=' ')
	print()


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	l = list(map(int, input().split()))
	s = ''
	for i in range(n):
		if l[i] > t / 2:
			s += '1'
		elif l[i] < t / 2:
			s += '0'
		else:
			s += '2'
	c = ['1', '0']
	s = list(s)
	j = 0
	for i in range(n):
		if s[i] == '2':
			s[i] = c[j % 2]
			j += 1
	for i in range(n):
		print(s[i], end=' ')
	print()


for _ in range(int(input())):
	(n, T) = map(int, input().split())
	s = list(map(int, input().split()))
	d = 0
	mid = T / 2
	for i in range(n):
		if s[i] < mid:
			s[i] = '1'
		elif s[i] > mid:
			s[i] = '0'
		else:
			if d % 2 == 0:
				s[i] = '1'
			else:
				s[i] = '0'
			d += 1
	print(*s)


def solve(N, T, a):
	(c_seen, d_seen) = (set(), set())
	cCount = 0
	dCount = 0
	for i in range(N):
		if T - a[i] not in c_seen:
			c_seen.add(a[i])
			print(0, end=' ')
		elif T - a[i] not in d_seen:
			d_seen.add(a[i])
			print(1, end=' ')
		elif cCount <= dCount:
			c_seen.add(a[i])
			print(0, end=' ')
			cCount += 1
		else:
			d_seen.add(a[i])
			print(1, end=' ')
			dCount += 1
for _ in range(int(input())):
	(N, T) = map(int, input().split())
	a = list(map(int, input().split()))
	solve(N, T, a)
	print()


def two_array(n, T, arr):
	brr = []
	j = 0
	for i in arr:
		if i < T / 2:
			brr.append('0')
		elif i > T / 2:
			brr.append('1')
		elif j % 2 == 0:
			brr.append('0')
			j += 1
		else:
			brr.append('1')
			j += 1
	return brr
t = int(input())
for i in range(t):
	(n, T) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	brr = two_array(n, T, arr)
	print(' '.join(brr))


t = int(input())
results = [[] for _ in range(t)]
for i in range(t):
	(n, t) = list(map(int, input().split(' ')))
	nums = list(map(int, input().split(' ')))
	t_2 = t / 2
	toZero = True
	for j in nums:
		if j < t_2:
			results[i].append('0')
		elif j == t_2:
			if toZero:
				results[i].append('0')
				toZero = False
			else:
				results[i].append('1')
				toZero = True
		else:
			results[i].append('1')
for res in results:
	print(' '.join(res))


from collections import defaultdict
for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	c = defaultdict(int)
	d = defaultdict(int)
	ans = [None] * n
	for i in range(n):
		k = t - a[i]
		if c[k] == 0:
			c[a[i]] = 1
			ans[i] = 0
		elif d[k] == 0:
			d[a[i]] = 1
			ans[i] = 1
		elif c[k] >= d[k]:
			d[a[i]] += 1
			ans[i] = 1
		else:
			c[a[i]] += 1
			ans[i] = 0
	print(*ans)


import sys
import math
input = sys.stdin.readline

def algo(arr, n, k):
	mid = k // 2
	c = arr.count(mid) // 2
	res = []
	if k % 2 != 0 or c == 0:
		for i in arr:
			if i <= mid:
				res.append('0')
			else:
				res.append('1')
		return ' '.join(res)
	else:
		count = 0
		for i in arr:
			if i == mid:
				count += 1
				if count <= c:
					res.append('0')
				else:
					res.append('1')
			elif i < mid:
				res.append('0')
			else:
				res.append('1')
		return ' '.join(res)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	res = algo(arr, n, k)
	print(res)


for _ in range(int(input())):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = []
	ind = []
	for i in range(n):
		if T // 2 == T / 2:
			if a[i] < T // 2:
				ans.append(0)
			elif a[i] > T // 2:
				ans.append(1)
			else:
				ans.append(2)
				ind.append(i)
		elif a[i] <= T // 2:
			ans.append(0)
		elif a[i] > T // 2:
			ans.append(1)
	for i in range(len(ind)):
		if i % 2 == 0:
			ans[ind[i]] = 0
		else:
			ans[ind[i]] = 1
	print(*ans, sep=' ')


from collections import defaultdict as dl
from bisect import bisect_left, bisect_right

def solve(n, t):
	s = list(map(int, input().split()))
	ind = dl(list)
	for i in range(n):
		ind[s[i]].append(i)
	s.sort()
	ans = [-1] * n
	for i in range(n):
		if ans[i] != -1:
			continue
		p = t - s[i]
		if p != t / 2:
			o = bisect_left(s, p)
			if o < n and s[o] == p:
				for j in range(o, bisect_right(s, p)):
					ans[j] = 1
			ans[i] = 0
		else:
			for j in range(bisect_left(s, p), bisect_right(s, p)):
				if j % 2 == 0:
					ans[j] = 1
				else:
					ans[j] = 0
	answer = [0] * n
	for i in range(n):
		answer[ind[s[i]][-1]] = ans[i]
		del ind[s[i]][-1]
	print(*answer)
for _ in range(int(input())):
	(n, t) = map(int, input().split())
	solve(n, t)


t = int(input())
for j in range(t):
	(n, t) = map(int, input().split())
	l = list(map(int, input().split()))
	d = {}
	f = []
	w = []
	for j in range(n):
		if t % 2 == 0 and l[j] == t // 2:
			if l[j] not in d:
				d[l[j]] = 0
			d[l[j]] += 1
		elif l[j] not in d:
			d[l[j]] = 0
			d[t - l[j]] = 1
	a = 0
	for j in range(n):
		if t % 2 == 0 and l[j] == t // 2:
			if a == 0:
				w.append(1)
				a = 1
			else:
				a = 0
				w.append(0)
		else:
			w.append(d[l[j]])
	print(*w)


import sys
input = sys.stdin.readline
(T,) = map(int, input().split())
for _ in range(T):
	(N, T) = map(int, input().split())
	d = dict()
	X = list(map(int, input().split()))
	R = [0] * N
	b = 0
	for i in range(N):
		x = X[i]
		if x * 2 == T:
			b = 1 - b
			R[i] = b
			continue
		if x in d:
			R[i] = d[x]
			continue
		d[x] = 0
		d[T - x] = 1
		R[i] = 0
	print(*R)


import sys
t = int(input())
while t > 0:
	t -= 1
	input = sys.stdin.readline()
	(n, k) = map(int, input.split())
	input = sys.stdin.readline()
	arr = list(map(int, input.split()))
	ans = [0 for i in range(n)]
	up_arr = []
	for i in range(n):
		up_arr.append([arr[i], i])
	up_arr.sort()
	(i, j) = (0, n - 1)
	while i < j:
		if up_arr[i][0] + up_arr[j][0] > k:
			j -= 1
		elif up_arr[i][0] + up_arr[j][0] < k:
			i += 1
		elif up_arr[i][0] != up_arr[j][0]:
			m = 0
			while up_arr[i][0] == up_arr[i + m][0]:
				m += 1
			i += m
			m = 0
			while up_arr[j][0] == up_arr[j - m][0]:
				ans[up_arr[j - m][1]] = 1
				m += 1
			j -= m
		else:
			diff = j - i
			for y in range((diff + 1) // 2):
				ans[up_arr[i + y][1]] = 1
			i = j
	print(*ans)


def paint(n, T, a):
	p = [1] * n
	colors = {}
	for i in range(n):
		if T - a[i] in colors:
			p[i] = 1 - colors[T - a[i]]
			colors[a[i]] = p[i]
		else:
			p[i] = 1
			colors[a[i]] = 1
	return p
t = int(input())
for i in range(t):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	print(*paint(n, T, a))


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	a = []
	for i in range(n):
		a.append([l[i], i])
	a.sort()
	ans = [0] * n
	for i in range(1, n):
		if a[i][0] + a[i - 1][0] > k:
			ans[a[i][1]] = 1
		elif a[i][0] + a[i - 1][0] < k:
			ans[a[i][1]] = 0
		else:
			ans[a[i][1]] = 1 if ans[a[i - 1][1]] == 0 else 0
	print(*ans)


from collections import Counter, defaultdict
test = int(input())
for i in range(test):
	(n, t) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = defaultdict(int)
	crr = defaultdict(int)
	ans = []
	for j in range(n):
		if arr[j] <= t:
			diff = t - arr[j]
			if brr[diff] > crr[diff]:
				ans.append(1)
				crr[arr[j]] += 1
			else:
				ans.append(0)
				brr[arr[j]] += 1
		else:
			ans.append(0)
	print(*ans)


import os
import sys
from io import BytesIO, IOBase
_str = str
BUFSIZE = 8192

def str(x=b''):
	return x if type(x) is bytes else _str(x).encode()

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def inp():
	return sys.stdin.readline()

def mpint():
	return map(int, sys.stdin.readline().split(' '))

def itg():
	return int(sys.stdin.readline())
from collections import defaultdict

def solve():
	(n, k) = mpint()
	arr = tuple(mpint())
	d = defaultdict(lambda : [])
	ans = [0] * n
	for (i, a) in enumerate(arr):
		d[a].append(i)
	while d:
		(a, indices) = d.popitem()
		if a + a == k:
			for idx in indices[:len(indices) >> 1]:
				ans[idx] = 1
		elif k - a in d:
			for idx in indices:
				ans[idx] = 1
			del d[k - a]
	return ans
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
for _ in range(itg()):
	print(*solve())


input = __import__('sys').stdin.readline
for _ in range(int(input())):
	(n, T) = map(int, input().split())
	s = list(map(int, input().split()))
	ans = [0] * n
	g = {}
	for i in range(n):
		if T - s[i] in g:
			ans[i] = 1 - ans[g[T - s[i]]]
		g[s[i]] = i
	print(*ans)


from math import floor, log2
t = int(input())
for _ in range(t):
	(n, T) = map(int, input().split())
	arr = list(map(int, input().split()))
	vis = set()
	res = dict()
	for i in range(n):
		if arr[i] not in vis:
			vis.add(arr[i])
			vis.add(T - arr[i])
			res[arr[i]] = 1
			res[T - arr[i]] = 0
	ans = [0] * n
	for i in range(n):
		ans[i] = res[arr[i]]
	f = 0
	for i in range(n):
		if 2 * arr[i] == T:
			ans[i] = f
			f = 1 - f
	for i in range(n):
		print(ans[i], end=' ')
	print()


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def invr():
	return map(int, input().split())
it = inp()
for i in range(it):
	(n, t) = invr()
	t /= 2
	p = 1
	a = inlt()
	for x in a:
		if x < t:
			sys.stdout.write(str(0) + ' ')
		elif x > t:
			sys.stdout.write(str(1) + ' ')
		else:
			sys.stdout.write(str(p) + ' ')
			p = 1 - p
	sys.stdout.write('\n')


import math
a = int(input())
for i in range(a):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	d1 = dict()
	d2 = dict()
	ans = []
	for i in arr:
		if i > k:
			d1[i] = 1
			ans.append(1)
		elif k - i not in d1:
			d1[i] = 1
			ans.append(1)
		elif k - i not in d2:
			d2[i] = 1
			ans.append(0)
		elif d1[i] > d2[i]:
			d2[i] = d2[i] + 1
			ans.append(0)
		else:
			d1[i] = d1[i] + 1
			ans.append(1)
	print(' '.join(map(str, ans)))


from __future__ import division, print_function
import math
import os
import sys
from fractions import *
from sys import *
from decimal import *
from io import BytesIO, IOBase
from itertools import *
from collections import *
M = 10 ** 9 + 7
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def inpu():
	return int(inp())

def regularbracket(t):
	p = 0
	for i in t:
		if i == '(':
			p += 1
		else:
			p -= 1
		if p < 0:
			return False
	else:
		if p > 0:
			return False
		else:
			return True

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def reverse1(string):
	pp = ''
	for i in string[::-1]:
		pp += i
	if pp == string:
		return True
	return False

def reverse2(list1):
	l = []
	for i in list1[::-1]:
		l.append(i)
	if l == list1:
		return True
	return False

def mex(list1):
	p = max(list1) + 1
	for i in range(len(list1)):
		if list1[i] != i:
			p = i
			break
	return p

def sumofdigits(n):
	n = str(n)
	s1 = 0
	for i in n:
		s1 += int(i)
	return s1

def perfect_square(n):
	s = math.sqrt(n)
	if s == int(s):
		return True
	return False

def roman_number(x):
	if x > 15999:
		return
	value = [5000, 4000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
	symbol = ['F', 'MF', 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
	roman = ''
	i = 0
	while x > 0:
		div = x // value[i]
		x = x % value[i]
		while div:
			roman += symbol[i]
			div -= 1
		i += 1
	return roman

def soretd(s):
	for i in range(1, len(s)):
		if s[i - 1] > s[i]:
			return False
	return True

def countRhombi(h, w):
	ct = 0
	for i in range(2, h + 1, 2):
		for j in range(2, w + 1, 2):
			ct += (h - i + 1) * (w - j + 1)
	return ct

def countrhombi2(h, w):
	return h * h // 4 * (w * w // 4)

def binpow(a, b):
	if b == 0:
		return 1
	else:
		res = binpow(a, b // 2)
	if b % 2 != 0:
		return res * res * a
	else:
		return res * res

def binpowmodulus(a, b, m):
	a %= m
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a = a * a % m
		b >>= 1
	return res

def coprime_to_n(n):
	result = n
	i = 2
	while i * i <= n:
		if n % i == 0:
			while n % i == 0:
				n //= i
			result -= result // i
		i += 1
	if n > 1:
		result -= result // n
	return result

def prime(x):
	if x == 1:
		return False
	else:
		for i in range(2, int(math.sqrt(x)) + 1):
			if x % i == 0:
				return False
		else:
			return True

def luckynumwithequalnumberoffourandseven(x, n, a):
	if x >= n and str(x).count('4') == str(x).count('7'):
		a.append(x)
	elif x < 1000000000000.0:
		luckynumwithequalnumberoffourandseven(x * 10 + 4, n, a)
		luckynumwithequalnumberoffourandseven(x * 10 + 7, n, a)
	return a

def luckynum(x, l, r, a):
	if x >= l and x <= r:
		a.append(x)
	if x > r:
		a.append(x)
		return a
	if x < 10000000000.0:
		luckynum(x * 10 + 4, l, r, a)
		luckynum(x * 10 + 7, l, r, a)
	return a

def luckynuber(x, n, a):
	p = set(str(x))
	if len(p) <= 2:
		a.append(x)
	if x < n:
		luckynuber(x + 1, n, a)
	return a

def interact(type, x):
	if type == 'r':
		inp = input()
		return inp.strip()
	else:
		print(x, flush=True)

def findTrailingZeros(n):
	count = 0
	while n >= 5:
		n //= 5
		count += n
	return count

def mergeSort(arr):
	if len(arr) > 1:
		mid = len(arr) // 2
		L = arr[:mid]
		R = arr[mid:]
		mergeSort(L)
		mergeSort(R)
		i = j = k = 0
		while i < len(L) and j < len(R):
			if L[i] < R[j]:
				arr[k] = L[i]
				i += 1
			else:
				arr[k] = R[j]
				j += 1
			k += 1
		while i < len(L):
			arr[k] = L[i]
			i += 1
			k += 1
		while j < len(R):
			arr[k] = R[j]
			j += 1
			k += 1
res = set()

def solven(p, l, a, b, n):
	if p > n or l > 10:
		return
	if p > 0:
		res.add(p)
	solven(p * 10 + a, l + 1, a, b, n)
	solven(p * 10 + b, l + 1, a, b, n)

def subsetsUtil(A, subset, index, d):
	print(*subset)
	s = sum(subset)
	d.append(s)
	for i in range(index, len(A)):
		subset.append(A[i])
		subsetsUtil(A, subset, i + 1, d)
		subset.pop(-1)
	return d

def subsetSums(arr, l, r, d, sum=0):
	if l > r:
		d.append(sum)
		return
	subsetSums(arr, l + 1, r, d, sum + arr[l])
	subsetSums(arr, l + 1, r, d, sum)
	return d

def print_factors(x):
	factors = []
	for i in range(1, x + 1):
		if x % i == 0:
			factors.append(i)
	return factors

def calc(X, d, ans, D):
	if len(X) == 0:
		return
	i = X.index(max(X))
	ans[D[max(X)]] = d
	Y = X[:i]
	Z = X[i + 1:]
	calc(Y, d + 1, ans, D)
	calc(Z, d + 1, ans, D)

def factorization(n, l):
	c = n
	if prime(n) == True:
		l.append(n)
		return l
	for i in range(2, c):
		if n == 1:
			break
		while n % i == 0:
			l.append(i)
			n = n // i
	return l

def good(b):
	l = []
	i = 0
	while len(b) != 0:
		if b[i] < b[len(b) - 1 - i]:
			l.append(b[i])
			b.remove(b[i])
		else:
			l.append(b[len(b) - 1 - i])
			b.remove(b[len(b) - 1 - i])
	if l == sorted(l):
		return True
	return False

def generate(st, s):
	if len(s) == 0:
		return
	if s not in st:
		st.add(s)
		for i in range(len(s)):
			t = list(s).copy()
			t.remove(s[i])
			t = ''.join(t)
			generate(st, t)
	return

def largestincreasingsubsequence(A):
	l = [1] * len(A)
	sub = []
	for i in range(1, len(l)):
		for k in range(i):
			if A[k] < A[i]:
				sub.append(l[k])
		l[i] = 1 + max(sub, default=0)
	return max(l, default=0)

def findOR(nums, N):
	prefix_sum = 0
	result = 0
	for i in range(N):
		result |= nums[i]
		prefix_sum += nums[i]
		result |= prefix_sum
	return result

def OR(a, n):
	ans = a[0]
	for i in range(1, n):
		ans |= a[i]
	return ans

def main():
	for _ in range(inpu()):
		(n, t) = sep()
		arr = lis()
		ans = [0] * n
		g = {}
		for i in range(n):
			if t - arr[i] in g:
				ans[i] = 1 - ans[g[t - arr[i]]]
			g[arr[i]] = i
		print(*ans)
main()


def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for _ in range(t):
	(_, T) = inlt()
	a = inlt()
	if T % 2:
		print(' '.join(['1' if x % 2 else '0' for x in a]))
	else:
		swap = '0'
		for i in range(len(a)):
			if a[i] * 2 == T:
				a[i] = swap
				swap = '1' if swap == '0' else '0'
			elif a[i] < T // 2:
				a[i] = '0'
			else:
				a[i] = '1'
		print(' '.join(a))


import sys
import math

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
t = II()
for q in range(t):
	(n, k) = MI()
	a = LI()
	d = [0] * n
	c = a.count(k // 2)
	boo = k % 2 == 0
	count = 0
	for i in range(n):
		if a[i] < k // 2:
			d[i] = 0
		elif a[i] == k // 2:
			if not boo:
				d[i] = 0
			elif count < c // 2:
				d[i] = 0
				count += 1
			else:
				d[i] = 1
		else:
			d[i] = 1
	print(*d)


for j in range(int(input())):
	(n, t) = map(int, input().split())
	d = [0] * n
	a = list(map(int, input().split()))
	if t % 2 != 0:
		for i in range(n):
			if a[i] <= t // 2:
				d[i] = 1
	else:
		s = 0
		for i in range(n):
			if a[i] < t // 2:
				d[i] = 1
			elif a[i] == t // 2:
				d[i] = s
				s = (s + 1) % 2
	print(*d)


import sys
t = int(input())
for i in range(t):
	l1 = [int(i) for i in input().split()]
	a = l1[0]
	k = l1[1]
	l = [int(i) for i in input().split()]
	z = k // 2
	s = ''
	if k % 2 != 0:
		for i in l:
			if i <= z:
				s += '1 '
			else:
				s += '0 '
	else:
		x = l.count(z)
		x = x // 2
		stop = 0
		for i in l:
			if i < z:
				s += '1 '
			elif i == z:
				stop += 1
				if stop <= x:
					s += '1 '
				else:
					s += '0 '
			else:
				s += '0 '
	print(s)


(n,) = (int(a) for a in input().strip().split())
for _ in range(n):
	(k, T) = (int(a) for a in input().strip().split())
	l = [int(a) for a in input().strip().split()]
	assert len(l) == k
	bl = set([])
	ans = []
	for i in range(k):
		if l[i] not in bl:
			ans.append(1)
			bl.add(T - l[i])
		else:
			ans.append(0)
			if 2 * l[i] == T:
				bl.remove(l[i])
	print(' '.join([str(a) for a in ans]))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, t) = map(int, input().split())
	ar = list(map(int, input().split()))
	dic = {}
	for i in range(n):
		if ar[i] in dic:
			dic[ar[i]].append(i)
		else:
			dic[ar[i]] = [i]
	li = [0] * n
	for i in dic:
		if i != t - i:
			for j in dic[i]:
				li[j] = 1
			if t - i in dic:
				dic[t - i] = []
		else:
			for j in range(len(dic[i]) // 2):
				li[dic[i][j]] = 1
	print(*li)


def solve(n, T, l):
	s = sorted(l)
	a = [0 for i in range(n)]
	if T % 2 == 0:
		half = T // 2
		count = l.count(half)
		c = 0
		for i in range(n):
			if l[i] < half:
				a[i] = 0
			elif l[i] > half:
				a[i] = 1
			else:
				c += 1
				if c > count // 2:
					a[i] = 1
				else:
					a[i] = 0
	else:
		half = T // 2
		for i in range(n):
			if l[i] <= half:
				a[i] = 0
			else:
				a[i] = 1
	return a
t = int(input())
for we in range(t):
	(n, T) = map(int, input().split())
	l = list(map(int, input().split()))
	print(*solve(n, T, l))


from collections import *
from itertools import *
from bisect import *

def inp():
	return int(input())

def arrinp():
	return [int(x) for x in input().split()]

def main():
	t = inp()
	for _ in range(t):
		(n, T) = arrinp()
		A = arrinp()
		dummy = sorted(A)
		(dict_w, dict_b) = (dict(), dict())
		left = 0
		dict_w[dummy[left]] = 1
		while left < n - 1:
			if dummy[left] + dummy[left + 1] < T:
				dict_w[dummy[left + 1]] = dict_w.get(dummy[left + 1], 0) + 1
				left += 1
			else:
				break
		count = 0
		while left + 1 < n and (dummy[left] == dummy[left + 1] and dummy[left] + dummy[left + 1] == T):
			count += 1
			left += 1
		x = count // 2
		y = count - x
		dict_w[dummy[left]] = dict_w.get(dummy[left], 0) + x
		dict_b[dummy[left]] = dict_b.get(dummy[left], 0) + y
		left += 1
		while left < n:
			dict_b[dummy[left]] = dict_b.get(dummy[left], 0) + 1
			left += 1
		ans = []
		for a in A:
			if dict_w.get(a, 0) > 0:
				ans.append(1)
				dict_w[a] -= 1
			elif dict_b.get(a, 0) > 0:
				ans.append(0)
				dict_b[a] -= 1
		print(*ans, sep=' ')
main()


T = int(input())
ans = ''
for _ in range(T):
	nk = input().split()
	n = int(nk[0])
	t = int(nk[1])
	a = [int(i) for i in input().split()]
	r = t // 2
	if t % 2 == 1:
		for i in range(n):
			if a[i] <= r:
				ans += '0 '
			else:
				ans += '1 '
	else:
		k = '0'
		for i in range(n):
			if a[i] < r:
				ans += '0 '
			elif a[i] > r:
				ans += '1 '
			else:
				ans += k + ' '
				if k == '1':
					k = '0'
				else:
					k = '1'
	ans += '\n'
print(ans)


from collections import defaultdict
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	q = [-1] * n
	f = 0
	d = defaultdict(list)
	for j in range(n):
		d[a[j]].append(j)
	for v in d:
		if v == k - v:
			r = len(d[v]) // 2
			for j in range(r):
				te = d[v].pop()
				q[te] = 0
			while len(d[v]) > 0:
				te = d[v].pop()
				q[te] = 1
		else:
			while len(d[v]) > 0:
				te = d[v].pop()
				q[te] = 0
			if k - v in d:
				while len(d[k - v]) > 0:
					te = d[k - v].pop()
					q[te] = 1
	print(' '.join(map(str, q)))


import math
from collections import Counter, defaultdict

def solve():
	(n, T) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = sorted(a)
	c = Counter(b)
	white = defaultdict(int)
	black = defaultdict(int)
	b = set()
	r = dict()
	for n in c:
		if T - n in c:
			if T - n in b:
				continue
			if T - n == n:
				white[n] += c[n] // 2
				black[n] += math.ceil(c[2] / 2)
			else:
				white[n] += c[n]
				black[T - n] += c[T - n]
			b.add(n)
			b.add(T - n)
		elif len(white) == 0:
			white[n] += 1
		elif len(black) == 0:
			black[n] += 1
		else:
			white[n] += 1
	ans = ''
	for (i, x) in enumerate(a):
		if x in white and white[x] > 0:
			white[x] -= 1
			ans += ' 0'
		else:
			black[x] -= 1
			ans += ' 1'
	return ans.strip()
t = int(input())
for case in range(t):
	print(solve())


def two_array(n, T, arr):
	brr = []
	(dic_c, dic_d) = ({}, {})
	for i in range(n):
		b = arr[i]
		a = T - b
		if a in dic_c and a in dic_d:
			k = min(dic_c[a], dic_d[a])
			if k == dic_c[a]:
				dic_c[b] += 1
				brr.append('0')
			else:
				dic_d[b] += 1
				brr.append('1')
		elif a in dic_c:
			dic_d[b] = 1
			brr.append('1')
		elif a in dic_d:
			dic_c[b] = 1
			brr.append('0')
		else:
			dic_c[b] = 1
			brr.append('0')
	return brr
t = int(input())
for i in range(t):
	(n, T) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	brr = two_array(n, T, arr)
	print(' '.join(brr))


for _ in ' ' * int(input()):
	(n, m) = map(int, input().split())
	a = sorted([(int(x), i) for (x, i) in zip(input().split(), range(n))])
	b = [0] * n
	v = m // 2
	if m % 2:
		for (x, i) in a:
			b[i] = 0 + (x > v)
	else:
		t = 0
		for (x, i) in a:
			if x == v:
				b[i] = t
				t = 1 - t
			else:
				b[i] = 0 + (x > v)
	print(*b)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	val = a.count(k // 2) // 2 if k % 2 == 0 else 0
	ans = [0] * n
	for i in range(n):
		if a[i] > k // 2:
			ans[i] = 1
		if a[i] == k // 2 and val > 0:
			ans[i] = 1
			val -= 1
	for i in ans:
		print(i, end=' ')
	print()


import sys, math, cmath, time
start_time = time.time()

def solve():
	(n, t) = invr()
	a = inlt()
	q = [0] * len(a)
	qw = 0
	for i in range(len(a)):
		if t % 2 == 0:
			if a[i] == t // 2:
				if qw == 1:
					q[i] = 1
					qw = 0
				else:
					qw = 1
		if a[i] > t // 2:
			q[i] = 1
	print(*q)

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(1, t + 1):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def factorial(n, m=1000000007):
	q = 1
	for i in range(n):
		q = q * (i + 1) % m
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b

def ceil(a, b):
	return -(-a // b)
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


import math
t = int(input())
while t:
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	c = {}
	d = {}
	ans = []
	for i in range(n):
		if T - a[i] in c:
			if T - a[i] in d:
				if c[T - a[i]] > d[T - a[i]]:
					d[a[i]] += 1
					ans.append(1)
				else:
					c[a[i]] += 1
					ans.append(0)
			else:
				d[a[i]] = 1
				ans.append(1)
		else:
			c[a[i]] = 1
			ans.append(0)
	for i in ans:
		print(i, end=' ')
	print()
	t -= 1


for _ in range(int(input())):
	(n, T) = map(int, input().split())
	a = [*map(int, input().split())]
	ans = [0] * n
	t = 0
	for i in range(n):
		if T % 2 == 0 and a[i] == T // 2:
			ans[i] = t
			t ^= 1
		elif a[i] <= (T - 1) // 2:
			ans[i] = 1
		elif a[i] > (T - 1) // 2:
			ans[i] = 0
	print(*ans)


def solve(n, t, seq):
	refer = {}
	ans = ''
	for x in seq:
		diff = abs(t - x)
		if x not in refer:
			if diff not in refer:
				refer[x] = 0
				ans += '0 '
			elif refer[diff] == 0:
				refer[x] = 1
				ans += '1 '
			else:
				refer[x] = 0
				ans += '0 '
		else:
			if diff != x:
				pass
			elif refer[x] == 0:
				refer[x] = 1
			else:
				refer[x] = 0
			ans += str(refer[x]) + ' '
	print(ans)
test = int(input())
for x in range(test):
	(n, t) = list(map(int, input().split()))
	seq = list(map(int, input().split()))
	solve(n, t, seq)


import collections
t = int(input())
for _ in range(t):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	b = []
	c = [0] * n
	for (i, aa) in enumerate(a):
		b.append([aa, i])
	b.sort()
	(lo, hi) = (0, n - 1)
	while lo < hi:
		if b[lo][0] + b[hi][0] < T:
			lo += 1
		elif b[lo][0] + b[hi][0] > T:
			hi -= 1
		else:
			if hi + 1 == n or c[b[hi + 1][1]] == 0:
				c[b[hi][1]] = 1
			elif hi + 1 < n and b[hi + 1][0] != b[hi][0]:
				c[b[hi][1]] = 1
			elif hi + 1 < n and b[hi + 1][0] + b[hi][0] != T:
				c[b[hi][1]] = 1
			hi -= 1
	print(*c)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	d = {}
	col = {}
	for i in arr:
		if i not in d.keys():
			d[i] = 1
			col[i] = 0
		else:
			d[i] += 1
	for i in range(n):
		if k - arr[i] == arr[i]:
			col[arr[i]] = 2
		elif k - arr[i] in d.keys() and col[arr[i]] == 0:
			col[k - arr[i]] = 1
	ans = [0] * n
	for i in range(n):
		if col[arr[i]] != 2:
			ans[i] = col[arr[i]]
		else:
			if d[arr[i]] % 2:
				ans[i] = 1
			d[arr[i]] -= 1
	for i in ans:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	(n, T) = map(int, input().split())
	a = [int(i) for i in input().split()]
	cnt = 0
	for i in range(len(a)):
		if a[i] < T / 2:
			a[i] = 1
		elif a[i] > T / 2:
			a[i] = 0
		else:
			if cnt % 2 == 0:
				a[i] = 0
			else:
				a[i] = 1
			cnt += 1
	for i in a:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	p = []
	t = T // 2
	f = 0
	for item in a:
		if T % 2 == 0 and item == t:
			p.append(f)
			if f == 1:
				f = 0
			else:
				f = 1
		elif item <= t:
			p.append(0)
		else:
			p.append(1)
	print(*p)


import math
t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = []
	c = 0
	for i in range(n):
		if a[i] * 2 == k:
			if c == 0:
				ans.append(0)
				c = 1
			else:
				ans.append(1)
				c = 0
		elif a[i] * 2 < k:
			ans.append(0)
		else:
			ans.append(1)
	print(*ans)


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	b = []
	g = t // 2
	fir = 0
	for i in range(n):
		if a[i] < g:
			b.append(0)
		elif a[i] > g:
			b.append(1)
		elif t % 2 != 0:
			b.append(0)
		elif fir == 0:
			fir = 1
			b.append(0)
		else:
			fir = 0
			b.append(1)
	print(*b)


try:
	t = int(input())
	for i in range(0, t):
		(n, k) = list(map(int, input().split(' ')))
		a = list(map(int, input().split(' ')))
		b = [0] * n
		p = a.count(k / 2)
		c = 0
		for i in range(0, len(a)):
			if a[i] < k / 2:
				b[i] = 0
			elif a[i] > k / 2:
				b[i] = 1
			elif a[i] == k / 2:
				if c < p // 2:
					b[i] = 0
					c += 1
				else:
					b[i] = 1
					c += 1
		print(*b, sep=' ')
except:
	pass


t = int(input())
for tc in range(t):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	j = 0
	out = [0] * n
	for i in range(n):
		value = float(a[i])
		if value < T / 2:
			out[i] = 1
		elif value == T / 2:
			if j % 2 == 0:
				out[i] = 1
			j += 1
	for num in out:
		print(num, end=' ')
	print()


try:
	t = int(input())
	while t:
		(n, T) = [int(x) for x in input().split()]
		a = [int(x) for x in input().split()]
		c = 0
		for i in a:
			if i > T / 2:
				print(1, end=' ')
			elif i < T / 2:
				print(0, end=' ')
			else:
				print(c, end=' ')
				c = (c + 1) % 2
		print()
		t -= 1
except:
	pass


t = int(input())
for i in range(t):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	c = {}
	d = {}
	output = []
	for j in a:
		rest = T - j
		if rest in c and rest in d:
			if c[rest] > d[rest]:
				d[j] += 1
				output.append(1)
			else:
				c[j] += 1
				output.append(0)
		elif rest in c:
			d[j] = 1
			output.append(1)
		elif rest in d:
			c[j] = 1
			output.append(0)
		else:
			c[j] = 1
			output.append(0)
	print(' '.join(map(str, output)))


import sys, os, io
input = sys.stdin.readline
T = int(input())
from collections import defaultdict
for t in range(T):
	(N, S) = map(int, input().split())
	A = list(map(int, input().split()))
	dic = defaultdict(lambda : False)
	ans = [0] * N
	target = -1
	if S % 2 == 0:
		target = S // 2
	t_cnt = A.count(target) // 2
	cnt = 0
	for i in range(N):
		if A[i] == target:
			if cnt < t_cnt:
				cnt += 1
				ans[i] = 1
			continue
		if dic[S - A[i]] == False:
			dic[A[i]] = True
			ans[i] = 1
	print(*ans)


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	s = set()
	for j in range(len(a)):
		if t - a[j] not in s:
			s.add(a[j])
			a[j] = 1
		else:
			if a[j] in s:
				s.remove(a[j])
			a[j] = 0
	print(' '.join(map(str, a)))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
import bisect
from collections import Counter
import bisect
for _ in range(int(input())):
	(n, t) = map(int, input().split())
	arr = list(map(int, input().split()))
	d = {}
	ans = [-1] * n
	dd = {}
	for i in range(n):
		if arr[i] > t:
			ans[i] = 0
		else:
			var = t - arr[i]
			if var in d:
				if var == arr[i]:
					if dd[var] % 2 == 0:
						ans[i] = 0
					else:
						ans[i] = 1
				else:
					ans[i] = (d[var] + 1) % 2
			else:
				d[arr[i]] = 0
				ans[i] = 0
		if arr[i] in dd:
			dd[arr[i]] += 1
		else:
			dd[arr[i]] = 1
	print(*ans)


for _ in range(int(input())):
	(n, m) = [int(token) for token in input().split()]
	a = [int(token) for token in input().split()]
	black_set = set()
	white_set = set()
	corner_case_counter = 0
	for num in a:
		if num * 2 == m:
			corner_case_counter += 1
		elif num not in white_set and num not in black_set:
			white_set.add(num)
			black_set.add(m - num)
	corner_case_size = (corner_case_counter + 1) / 2
	answer = []
	for num in a:
		if num * 2 == m:
			answer.append(0 if corner_case_counter > corner_case_size else 1)
			corner_case_counter -= 1
		else:
			answer.append(0 if num in white_set else 1)
	print(*answer)


from collections import defaultdict
for q in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	d = defaultdict(list)
	for i in range(n):
		if d.get(a[i], -1) == -1:
			d[a[i]].append(1)
			d[a[i]].append('n')
		else:
			d[a[i]][0] += 1
	for i in range(n):
		if d[a[i]][1] == 'n':
			y = t - a[i]
			if d.get(y, -1) == -1:
				d[a[i]][1] = 'w'
			elif a[i] != y:
				d[a[i]][1] = 'w'
				d[y][1] = 'b'
			else:
				d[a[i]][0] //= 2
				d[a[i]][1] = 'm'
	res = [0] * n
	for i in range(n):
		if d[a[i]][1] == 'b':
			res[i] = 1
		elif d[a[i]][1] == 'm':
			if d[a[i]][0] > 0:
				d[a[i]][0] -= 1
				res[i] = 1
	print(*res)


from collections import defaultdict

def classfyArr(arr, t):
	mapC = defaultdict(int)
	mapD = defaultdict(int)
	for num in arr:
		complement = t - num
		if complement not in mapC:
			mapC[num] += 1
		elif complement not in mapD:
			mapD[num] += 1
		elif mapC[complement] == mapD[complement]:
			mapC[num] += 1
		elif mapC[complement] > mapD[complement]:
			mapD[num] += 1
		elif mapC[complement] < mapD[complement]:
			mapC += 1
	return (mapC, mapD)
testCases = input()
for i in range(int(testCases)):
	(n, t) = map(int, input().split())
	arr = list(map(int, input().split()))
	(mapA, mapB) = classfyArr(arr, t)
	resList = []
	for i in range(n):
		if arr[i] in mapA:
			resList.append('1')
			mapA[arr[i]] -= 1
			if mapA[arr[i]] == 0:
				mapA.pop(arr[i])
		else:
			resList.append('0')
			mapB[arr[i]] -= 1
			if mapB[arr[i]] == 0:
				mapB.pop(arr[i])
	print(' '.join(resList))


ll = lambda : map(int, input().split())
t = lambda : int(input())
ss = lambda : input()
for _ in range(t()):
	(n, k) = ll()
	a = list(ll())
	ans = 0
	for i in range(n):
		if a[i] > k / 2:
			a[i] = 1
		elif a[i] < k / 2:
			a[i] = 0
		else:
			a[i] = ans & 1
			ans += 1
	print(*a)


from sys import stdin, stdout
from collections import Counter
for _ in range(int(stdin.readline())):
	(n, k) = list(map(int, stdin.readline().split()))
	a = list(map(int, stdin.readline().split()))
	d = Counter(a)
	ans = []
	half = 0
	zero = set()
	if k & 1 == 0 and k // 2 in d:
		half = d[k // 2] // 2
	for v in a:
		if v == k // 2:
			if half:
				ans += [1]
				half -= 1
			else:
				ans += [0]
		elif v in zero:
			ans += [0]
		else:
			ans += [1]
			zero.add(k - v)
	print(*ans)


import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	l = [0] * n
	if k & 1:
		for j in range(n):
			if a[j] <= k // 2:
				l[j] = 1
	else:
		flag = 0
		for j in range(n):
			if a[j] < k // 2:
				l[j] = 1
			elif a[j] == k // 2:
				if flag == 0:
					l[j] = 1
					flag = 1
				else:
					flag = 0
	print(*l)


from sys import stdin, stdout, maxsize
tup = lambda : map(int, stdin.readline().split())
I = lambda : int(stdin.readline())
lint = lambda : [int(x) for x in stdin.readline().split()]
S = lambda : stdin.readline().replace('\n', '').strip()
stpr = lambda x: stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
from math import ceil, floor
from _collections import defaultdict
from bisect import bisect_left, bisect_right
for _ in range(I()):
	(n, k) = tup()
	ls = lint()
	ans = [-1] * n
	cnt = 0
	for i in range(n):
		if ls[i] * 2 < k:
			ans[i] = 1
		elif ls[i] * 2 > k:
			ans[i] = 0
		else:
			cnt += 1
	for i in range(n):
		if ans[i] == -1:
			if cnt > 0:
				ans[i] = 1
			else:
				ans[i] = 0
			cnt -= 2
	print(*ans)


t = int(input())
for i in range(t):
	(n, T) = map(int, input().split())
	array = map(int, input().split())
	a = []
	b = []
	for j in array:
		a.append(j)
	if T % 2:
		for k in a:
			b.append(k % 2)
	else:
		mid = T // 2
		x = 0
		for k in a:
			if k < mid:
				b.append(0)
			elif k > mid:
				b.append(1)
			else:
				b.append(x)
				x = 1 - x
	ans = str(b[0])
	for y in b[1:]:
		ans += ' ' + str(y)
	print(ans)


from sys import stdin, stdout
import math, sys
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict, Counter
from os import path
from bisect import bisect_left
import heapq
mod = 10 ** 9 + 7

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def inp():
		return int(input())

	def minp():
		return map(int, input().split())
else:

	def inp():
		return int(stdin.readline())

	def minp():
		return map(int, stdin.readline().split())
for _ in range(inp()):
	(n, t) = minp()
	a = list(minp())
	for i in range(n):
		if a[i] > t / 2:
			a[i] = 0
		elif a[i] < t / 2:
			a[i] = 1
		else:
			a[i] = 2
	equal = a.count(2)
	for i in range(n):
		if a[i] == 2:
			if equal & 1:
				a[i] = 0
			else:
				a[i] = 1
			equal -= 1
	print(*a)


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	usedA = dict.fromkeys(a, 0)
	usedB = dict.fromkeys(a, 0)
	ans = [None] * n
	for i in range(n):
		cntA = usedA.get(t - a[i], 0)
		cntB = usedB.get(t - a[i], 0)
		if cntA <= cntB:
			ans[i] = 0
			usedA[a[i]] += 1
		else:
			ans[i] = 1
			usedB[a[i]] += 1
	print(*ans)


def paint(l, res, mode=-1):
	if mode == -1:
		for j in range(len(l)):
			if j < len(l) // 2:
				res[l[j]] = 1
			else:
				res[l[j]] = 0
	else:
		for j in l:
			res[j] = mode
t = int(input())
while t > 0:
	t -= 1
	(n, k) = (int(i) for i in input().split())
	a = [int(i) for i in input().split()]
	m = {}
	res = [-1 for i in range(n)]
	for i in range(n):
		if a[i] in m:
			m[a[i]].append(i)
		else:
			m[a[i]] = [i]
	for i in range(n):
		if res[i] == -1 and k - a[i] in m:
			if a[i] == k - a[i]:
				paint(m[a[i]], res)
			else:
				paint(m[a[i]], res, 1)
				paint(m[k - a[i]], res, 0)
	for i in res:
		if i == -1:
			print(0, end=' ')
		else:
			print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	j = set()
	(n, T) = [int(x) for x in input().split()]
	ans = [0] * n
	ad = [int(x) for x in input().split()]
	l = 0
	r = n - 1
	a = sorted(ad)
	while l < r:
		if a[l] + a[r] == T:
			j.add(min(a[l], a[r]))
		if a[l] + a[r] <= T:
			l += 1
		else:
			r -= 1
	if T % 2 == 0:
		j.discard(T // 2)
	for u in range(n):
		if ad[u] in j:
			ans[u] = 1
	te = ad.count(T // 2)
	te = te // 2
	if T % 2 == 0 and te != 0:
		for u in range(n):
			if ad[u] == T // 2:
				ans[u] = 1
				te -= 1
			if te == 0:
				break
	print(*ans)


T = int(input())
for _ in range(T):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	d = {}
	ans = [0] * n
	for i in range(n):
		d[t - a[i]] = False
		d[a[i]] = False
	count = [0, 0]
	for i in range(n):
		if a[i] * 2 == t:
			if count[0] >= count[1]:
				count[1] += 1
				ans[i] = 1
			else:
				count[0] += 1
		elif d[t - a[i]] == True:
			ans[i] = 1
		elif d[a[i]] == False:
			d[a[i]] = True
	print(*ans)


from sys import stdin
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, t) = [int(x) for x in inp().split()]
	a = [int(x) for x in inp().split()]
	c = set()
	d = set()
	ans = []
	for i in range(n):
		if a[i] in c:
			ans.append(1)
		elif a[i] in d:
			ans.append(0)
		else:
			c.add(a[i])
			ans.append(1)
			d.add(t - a[i])
		if a[i] == t - a[i]:
			if a[i] in c:
				c.remove(a[i])
				d.add(a[i])
			else:
				if a[i] in d:
					d.remove(a[i])
				c.add(a[i])
	print(*ans)


from collections import defaultdict
for _ in range(int(input())):
	(n, t) = map(int, input().split())
	arr = list(map(int, input().split()))
	d1 = defaultdict(int)
	for i in arr:
		want = t - i
		if want in d1:
			d1[want] = 1
		elif i not in d1:
			d1[i] = 0
	ans = [0] * n
	for i in range(n):
		ans[i] = d1[arr[i]]
	if t % 2:
		print(*ans)
	else:
		cnt = arr.count(t // 2)
		temp = 0
		for i in range(n):
			if arr[i] == t // 2:
				if temp == cnt // 2:
					break
				ans[i] = 0
				temp += 1
		print(*ans)


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	l = list(map(int, input().split()))
	s = set(l)
	s1 = set()
	s2 = set()
	for i in s:
		if i not in s2:
			s1.add(i)
			if t - i in s:
				s2.add(t - i)
	l2 = []
	mid = -1
	if t % 2 == 0 and t // 2 in s:
		mid = t // 2
	flag = True
	for i in l:
		if i == mid:
			l2.append(int(flag))
			flag = not flag
		elif i in s1:
			l2.append(1)
		else:
			l2.append(0)
	print(*(i for i in l2))


from sys import stdin
input = stdin.readline
q = int(input())
for _ in range(q):
	(n, t) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	s = set()
	p = [0] * n
	m = 0
	for i in range(n):
		if t % 2 == 0 and t // 2 == a[i]:
			p[i] = m
			m = 1 - m
		elif t - a[i] in s:
			p[i] = 1
		else:
			s.add(a[i])
	print(*p)


t = int(input())
for i in range(t):
	(n, T) = map(int, input().split())
	v = list(map(int, input().split()))
	c = []
	d = []
	flag = 0
	for j in range(n):
		if v[j] < T / 2:
			print(0, end=' ')
		elif v[j] == T / 2 and flag == 0:
			print(0, end=' ')
			flag = 1 - flag
		elif v[j] == T / 2:
			print(1, end=' ')
			flag = 1 - flag
		else:
			print(1, end=' ')
	print()


def solve(n, T, a):
	res = [0] * n
	c = [{}, {}]
	for i in range(n):
		color = 0
		rest = T - a[i]
		if rest in c[0]:
			x = c[0][rest]
			if not rest in c[1] or c[1][rest] < x:
				color = 1
		res[i] = color
		if a[i] in c[color]:
			c[color][a[i]] += 1
		else:
			c[color][a[i]] = 1
	return res
tests = int(input())
for test in range(tests):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	print(*solve(n, T, a))


import sys
ii = lambda : sys.stdin.readline().strip()
idata = lambda : [int(x) for x in ii().split()]

def solve():
	(n, t) = idata()
	data = idata()
	ans = []
	f = 1
	for i in range(n):
		if t % 2 == 0 and data[i] == t // 2:
			ans += [f % 2]
			f += 1
		elif data[i] < (t + 1) // 2:
			ans += [1]
		else:
			ans += [0]
	print(*ans)
	return
for t1 in range(int(ii())):
	solve()


T = int(input())
for j in range(0, T):
	(n, t) = map(int, input().split())
	ar = list(map(int, input().split()))
	trace = {}
	for i in range(0, len(ar)):
		if t - ar[i] in trace:
			trace[ar[i]] = 1 - trace[t - ar[i]]
		else:
			trace[ar[i]] = 1
		print(trace[ar[i]], end=' ')
	print('\n')


from sys import stdin, stdout
ans = []

def main():
	subans = []
	(n, T) = list(map(int, stdin.readline().split()))
	arr = list(map(int, stdin.readline().split()))
	jump = 1
	for item in arr:
		if item < T / 2:
			subans.append('0')
		elif item > T / 2:
			subans.append('1')
		elif jump:
			subans.append('0')
			jump = 0
		else:
			subans.append('1')
			jump = 1
	ans.append(' '.join(subans))
	return
for i in range(int(stdin.readline())):
	main()
stdout.write('\n'.join(ans))


for _ in range(int(input())):
	target = list(map(int, input().split()))[1]
	numbers = list(map(int, input().split()))
	(ans, aux) = ([0] * len(numbers), 0)
	for i in range(len(numbers)):
		if target % 2 == 0 and numbers[i] == target // 2:
			ans[i] = int(aux)
			aux = not aux
			continue
		if numbers[i] <= target // 2:
			ans[i] = 1
	print(*ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = [0] * n
	if k % 2 != 0:
		p = k // 2
		for i in range(0, len(a)):
			if a[i] <= p:
				ans[i] = 0
			else:
				ans[i] = 1
	else:
		p = k // 2
		count = 0
		for i in range(0, len(a)):
			if a[i] < p:
				ans[i] = 1
			elif a[i] == p:
				if count == 0:
					ans[i] = 0
					count = 1
				else:
					ans[i] = 1
					count = 0
			else:
				ans[i] = 0
	print(*ans)


import collections
t = int(input())
for _ in range(t):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	b = []
	c = [0] * n
	for (i, aa) in enumerate(a):
		b.append([aa, i])
	b.sort()
	flag = 0
	for i in range(len(b)):
		if b[i][0] * 2 > T:
			c[b[i][1]] = 1
		elif b[i][0] * 2 == T:
			if flag == 1:
				c[b[i][1]] = 1
			flag ^= 1
	print(*c)


t = int(input())
i = 0
while i < t:
	A = list(map(int, input().split()))
	n = A[0]
	T = A[1]
	a = list(map(int, input().split()))
	C = 0
	NUM = -1
	g = T // 2 + 1
	answer = ''
	if T % 2 == 0:
		NUM = T // 2
	for index in range(0, n):
		if a[index] == NUM:
			if C % 2 == 0:
				answer += '0 '
			else:
				answer += '1 '
			C += 1
		elif a[index] < g:
			answer += '0 '
		elif a[index] >= g:
			answer += '1 '
	print(answer)
	i += 1


import random

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)
for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	d = {}
	for i in range(n):
		if a[i] in d:
			d[a[i]].append(i)
		else:
			d[a[i]] = [i]
	ans = [-1] * n
	for i in d.keys():
		if ans[d[i][0]] == -1:
			if i == t // 2:
				for j in range(len(d[i]) // 2):
					ans[d[i][j]] = 0
				for j in range(len(d[i]) // 2, len(d[i])):
					ans[d[i][j]] = 1
			else:
				for j in range(len(d[i])):
					ans[d[i][j]] = 0
				if t - i in d:
					for j in range(len(d[t - i])):
						ans[d[t - i][j]] = 1
	for i in ans:
		print(i, end=' ')
	print('')


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	mp = {}
	cn = {}
	for i in range(n):
		mp[a[i]] = 0
	grp = [0] * n
	for i in range(n):
		if t - a[i] in mp.keys() and mp[t - a[i]] == mp[a[i]] and (t != 2 * a[i]):
			mp[t - a[i]] = 1 - mp[t - a[i]]
	if t % 2 == 0:
		x = a.count(t // 2)
		ct = x // 2
		for i in range(n):
			if grp[i] == 0:
				if a[i] == t // 2 and ct > 0:
					ct -= 1
					grp[i] = 1
				else:
					grp[i] = mp[a[i]]
	else:
		for i in range(n):
			if grp[i] == 0:
				grp[i] = mp[a[i]]
	print(*grp)


import bisect
import collections
import copy
import fractions
import functools
import heapq
import math
import random
import sys

def _p(str):
	sys.stdout.write(str + '\n')

def _i():
	return sys.stdin.readline()
T = int(_i())
for t in range(T):
	(N, U) = tuple(map(int, _i().split()))
	A = list(map(int, _i().split()))
	half_z = True
	paint = []
	for a in A:
		if a == U / 2:
			if half_z:
				paint.append('0')
			else:
				paint.append('1')
			half_z = not half_z
		elif a > U / 2:
			paint.append('1')
		else:
			paint.append('0')
	_p(' '.join(paint))
sys.stdout.flush()


from collections import defaultdict

def solve():
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	white = defaultdict(int)
	black = defaultdict(int)
	ans = [0] * n
	for (i, x) in enumerate(a):
		if white[T - x] > black[T - x]:
			black[x] += 1
			ans[i] = 1
		else:
			white[x] += 1
			ans[i] = 0
	print(*ans)
	return

def main():
	T = int(input())
	for i in range(T):
		solve()
	return
main()


for h in range(int(input())):
	(n, T) = map(int, input().strip().split())
	arr = list(map(int, input().strip().split()))
	dicti1 = {}
	dicti2 = {}
	ans = []
	for i in arr:
		if i in dicti1 and i in dicti2:
			if dicti1[i] < dicti2[i]:
				ans.append(0)
				dicti1[T - i] += 1
			else:
				ans.append(1)
				dicti2[T - i] += 1
		elif i in dicti1:
			dicti2[T - i] = 1
			ans.append(1)
		else:
			dicti1[T - i] = 1
			ans.append(0)
	print(*ans)


import sys
from copy import *
from bisect import *
from heapq import *
from itertools import permutations as prm, product

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def string(s):
	return ''.join(s)

def fori(n):
	return [fi() for i in range(n)]

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def bo(i):
	return ord(i) - ord('A')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < m and (a[i][j] != '.')

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = fi()
while t > 0:
	t -= 1
	(n, k) = mi()
	a = li()
	c = 0
	d = {}
	ans = [-1] * n
	for i in range(n):
		if a[i] == k // 2 and k % 2 == 0:
			c += 1
			continue
		elif a[i] > k:
			ans[i] = 0
			d[a[i]] = i
		elif k - a[i] in d:
			ans[i] = ans[d[k - a[i]]] ^ 1
		else:
			ans[i] = 0
			d[a[i]] = i
	p = 0
	for i in range(n):
		if a[i] == k // 2 and k % 2 == 0:
			if p >= c // 2:
				ans[i] = 1
			else:
				ans[i] = 0
				p += 1
	print(*ans)


import collections
t = input()
t = int(t)

def solve(n, T, arr):
	colors = [0] * n
	for i in range(n):
		if arr[i] > T // 2:
			colors[i] = 0
		else:
			colors[i] = 1
	if T % 2 == 1:
		print(*colors)
		return
	cpk = True
	for i in range(n):
		if arr[i] == T // 2:
			colors[i] = int(cpk)
			if cpk:
				cpk = False
			else:
				cpk = True
	print(*colors)
for i in range(t):
	(n, T) = map(int, input().split())
	arr = list(map(int, input().split()))
	solve(n, T, arr)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lis = list(map(int, input().split()))
	output = []
	se = set(lis)
	dic = {}
	for i in lis:
		if k - i in se and i not in dic:
			dic[i] = 0
			dic[k - i] = 1
			continue
		if i not in dic:
			dic[i] = 0
	count = 0
	for i in lis:
		if 2 * i == k:
			count += 1
	zero = count // 2
	one = count - zero
	for i in lis:
		if 2 * i == k:
			if zero:
				output.append(0)
				zero -= 1
			else:
				output.append(1)
			continue
		output.append(dic[i])
	for i in output:
		print(i, end=' ')
	print()


import sys
from collections import defaultdict as dd
from collections import Counter as cc
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = lambda : sys.stdin.buffer.readline().rstrip()

def binarySearch(arr, l, r, x):
	while l <= r:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1
for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	b = sorted(list(set(a)))
	l = 0
	r = len(b) - 1
	q = dd()
	for i in b:
		q[i] = 0
	while l < r:
		k = b[l] + b[r]
		if k == t:
			q[b[l]] = 1
			l += 1
			q[b[r]] = 0
			r -= 1
		elif k > t:
			r -= 1
		else:
			l += 1
	r = 0
	for i in range(n):
		if a[i] == t / 2:
			a[i] = r
			r = abs(r - 1)
		else:
			a[i] = q[a[i]]
	print(*a)


t = int(input())
i = 0
while i < t:
	nt = list(map(int, input().split()))
	n = nt[0]
	T = nt[1]
	a = list(map(int, input().split()))
	count = 0
	NUM = -1
	gran = T // 2 + 1
	answer = []
	if T % 2 == 0:
		NUM = T // 2
	index = 0
	while index < n:
		if a[index] == NUM:
			if count % 2 == 0:
				answer.append(0)
			else:
				answer.append(1)
			count += 1
		elif a[index] < gran:
			answer.append(0)
		elif a[index] >= gran:
			answer.append(1)
		index += 1
	ans = ''
	for j in answer:
		ans += str(j) + ' '
	print(ans)
	i += 1


tc = int(input())
for _ in range(tc):
	[n, k] = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	if n == 1:
		print(1)
		continue
	i = 0
	narr = [0] * n
	flag = True
	while i < n:
		if k % 2 == 0:
			if arr[i] < k // 2:
				narr[i] = 1
			elif arr[i] == k // 2:
				if flag == True:
					flag = False
					narr[i] = 1
				else:
					flag = True
					narr[i] = 0
		elif arr[i] <= k // 2:
			narr[i] = 1
		i += 1
	print(*narr)


from datetime import datetime
import datetime
import random
for _ in range(int(input())):
	n: object
	(n, k) = [int(x) for x in input().split()]
	L = [int(x) for x in input().split()]
	ans = [0] * n
	g = {}
	y = 0
	for x in range(n):
		if L[x] == k // 2 and k & 1 == 0:
			ans[x] = 1 - y
			y = y ^ 1
		elif L[x] > k // 2:
			ans[x] = 1
		else:
			ans[x] = 0
	print(*ans)


from collections import defaultdict
cases = int(input())
for _ in range(cases):
	(n, T) = [int(v) for v in input().split()]
	a = [int(v) for v in input().split()]
	sa = sorted(a)
	hs = defaultdict(int)
	s = 0
	e = n - 1
	while s <= e:
		cav = sa[s] + sa[e]
		if cav == T:
			hs[sa[s]] += 1
			s += 1
			e -= 1
		elif cav > T:
			e -= 1
		else:
			hs[sa[s]] += 1
			s += 1
	result = []
	for v in a:
		if hs[v] > 0:
			result.append(0)
			hs[v] -= 1
		else:
			result.append(1)
	for v in result:
		print(v, end=' ')
	print()


s = int(input())
for _ in range(s):
	(n, t) = [int(i) for i in input().split(' ')]
	a = [int(i) for i in input().split(' ')]
	ans = [-1] * n
	count = 0
	lo = (t - 1) // 2
	hi = (t + 2) // 2
	toggle = 0
	for i in range(n):
		if a[i] <= lo:
			ans[i] = 0
		elif a[i] >= hi:
			ans[i] = 1
		else:
			ans[i] = toggle
			toggle = 1 - toggle
	print(' '.join((str(i) for i in ans)))


import bisect
import array
import functools
import math
T = int(input())
for Tid in range(T):
	(n, k) = map(int, input().split())
	a = array.array('i', map(int, input().split()))
	b = array.array('i', [0 for i in range(n)])
	s = 0
	for i in range(n):
		if a[i] * 2 == k:
			s = s + 1
		elif a[i] * 2 < k:
			b[i] = 1
	s = (s + 1) // 2
	for i in range(n):
		if a[i] * 2 == k and s != 0:
			s = s - 1
			b[i] = 1
		print(b[i], end=' ')
	print()


for i in range(int(input())):
	(n, t) = map(int, input().split())
	t /= 2
	p = 1
	for x in map(int, input().split()):
		if x < t:
			print(0, end=' ')
		elif x > t:
			print(1, end=' ')
		else:
			print(p, end=' ')
			p = 1 - p
	print()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	ll = [0] * n
	count = 0
	for i in range(n):
		if l[i] > m / 2:
			ll[i] = 1
		elif l[i] == m / 2:
			ll[i] = count & 1
			count += 1
	print(*ll)


def solve(arr, T):
	n = len(arr)
	painted = [0 for _ in range(n)]
	setA = dict()
	setB = dict()
	for i in range(n):
		ele = arr[i]
		if not T - ele in setA:
			setA[ele] = setA.get(ele, 0) + 1
			painted[i] = 1
		elif not T - ele in setB:
			setB[ele] = setB.get(ele, 0) + 1
			painted[i] = 0
		elif setA[T - ele] < setB[T - ele]:
			setA[ele] = setA.get(ele, 0) + 1
			painted[i] = 1
		else:
			setB[ele] = setB.get(ele, 0) + 1
			painted[i] = 0
	return painted
t = int(input())
for _ in range(t):
	(n, T) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = solve(arr, T)
	print(*ans)


t = int(input())
for case in range(t):
	(n, T) = map(int, input().split())
	a = [int(x) for x in input().split()]
	halfTticker = False
	halfT = T / 2
	white = set()
	for x in a:
		if x == halfT:
			print(int(halfTticker), end=' ')
			halfTticker = not halfTticker
		elif x in white:
			print(0, end=' ')
		elif T - x in white:
			print(1, end=' ')
		else:
			white.add(x)
			print(0, end=' ')
	print()


for _ in range(int(input())):
	(n, T) = map(int, input().split())
	a = [int(i) for i in input().split()]
	c_and_d = [-1] * n
	relationship = {}
	for (ind, num) in enumerate(a):
		if num in relationship:
			if num + num == T:
				del relationship[num]
			c_and_d[ind] = 1
		else:
			if T - num in relationship:
				relationship[T - num].append(num)
			else:
				relationship[T - num] = [num]
			c_and_d[ind] = 0
	print(*c_and_d)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	from collections import defaultdict
	d = defaultdict(lambda : -1)
	r = -1
	fa = [-1] * n
	if k % 2 == 0:
		r = k // 2
		fo = 0
	for i in range(n):
		if a[i] == r:
			fa[i] = fo
			fo = abs(1 - fo)
		elif d[a[i]] != -1:
			fa[i] = d[a[i]]
		else:
			fa[i] = 0
			d[k - a[i]] = 1
	print(*fa)


t = int(input())
for i in range(t):
	(n, t) = map(int, input().split())
	l = list(map(int, input().split()))
	d = dict()
	for i in l:
		d[i] = 0
	for i in l:
		if t - i in d.keys() and d[i] == 0:
			d[t - i] = 1
	b = True
	for i in l:
		if i == t / 2:
			if b:
				print('0 ', end='')
			else:
				print('1 ', end='')
			b = not b
		else:
			print(d[i], end=' ')
	print()


from collections import *
from functools import *
import math
import sys
inp = sys.stdin.readline
out = sys.stdout.write

def mi():
	return map(int, inp().split())

def li():
	return list(mi())

def ii():
	return int(inp())

def main():
	for _ in range(ii()):
		(n, t) = mi()
		a = li()
		aa = [0] * n
		f = 1
		for i in range(n):
			if 2 * a[i] > t:
				aa[i] = 1
			if 2 * a[i] == t:
				if f == 0:
					f = 1
					aa[i] = 1
				else:
					f = 0
		print(*aa)
main()


for _ in range(int(input())):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	temp = set()
	for i in range(n):
		if a[i] > T / 2:
			a[i] = 1
		elif a[i] < T / 2:
			a[i] = 0
		elif a[i] == T / 2:
			if a[i] not in temp:
				temp.add(a[i])
				a[i] = 0
			else:
				temp.remove(a[i])
				a[i] = 1
	print(*a)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	c = list(map(int, input().split()))
	d = []
	num = 0
	for i in range(len(c)):
		if c[i] < b // 2:
			d.append(1)
		elif c[i] > b // 2:
			d.append(0)
		elif c[i] == b // 2 and b % 2 != 0:
			d.append(1)
		elif c[i] == b // 2 and b % 2 == 0:
			if num % 2 == 1:
				d.append(1)
				num += 1
			else:
				d.append(0)
				num += 1
	print(' '.join((str(y) for y in d)))


for _ in range(int(input())):
	(m, n) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = ''
	p = 0
	for i in range(m):
		if a[i] > n / 2:
			ans += '1'
		elif a[i] < n / 2:
			ans += '0'
		else:
			ans += str((p + 1) % 2)
			p = p + 1
	print(' '.join(ans))


for i in range(int(input())):
	(n, T) = map(int, input().split())
	l = list(map(int, input().split()))
	b = set()
	a = []
	alt = 0
	for i in l:
		if i == T / 2:
			a.append(alt)
			alt ^= 1
		elif T - i in b:
			a.append(1)
		else:
			b.add(i)
			a.append(0)
	for i in range(n):
		print(a[i], end=' ')
		if i == n - 1:
			print('')


def main():
	t = int(input())
	for _ in range(t):
		(n, T) = map(int, input().split())
		a = list(map(int, input().split()))
		if T % 2 == 0:
			self_soulmate = T // 2
		else:
			self_soulmate = -1
		ss_count = 0
		s = set()
		p = []
		for e in a:
			if e == self_soulmate:
				p.append(ss_count % 2)
				ss_count += 1
				continue
			soulmate = T - e
			if e not in s:
				if soulmate not in s:
					s.add(e)
					p.append(0)
				else:
					p.append(1)
			else:
				p.append(0)
		print(*p)
main()


from sys import stdin

def get_int():
	return int(stdin.readline())

def get_str():
	return stdin.readline().strip()

def get_ints():
	return map(int, stdin.readline().strip().split())

def get_array():
	return list(map(int, stdin.readline().strip().split()))

def get_array2d(row):
	return [list(map(int, stdin.readline().strip().split())) for _ in range(row)]
T = get_int()
for _ in range(T):
	(N, T) = get_ints()
	A = get_array()
	if T % 2 == 0:
		(halfT, cnt0) = (T // 2, 0)
		cnt0 = A.count(halfT) // 2
		for a in A:
			if cnt0 > 0 and a == halfT:
				print('0', end=' ')
				cnt0 -= 1
			elif a < halfT:
				print('0', end=' ')
			else:
				print('1', end=' ')
	else:
		halfT = T // 2
		for a in A:
			if a <= halfT:
				print('0', end=' ')
			else:
				print('1', end=' ')
	print()


for _ in range(int(input())):
	(m, k1) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	sa = [0 for j in range(0, m)]
	n = 0
	for i in range(0, m):
		if arr[i] <= k1 // 2 and arr[i] // 2 != k1 / 2:
			sa[i] = 1
		if arr[i] == k1 / 2:
			n = n + 1
			if n % 2 == 0:
				sa[i] = 0
			else:
				sa[i] = 1
	for i in range(0, m):
		print(sa[i], end=' ')
	print()


import sys
import math
input = sys.stdin.readline

def algo(arr, n, k):
	res = []
	midcur = 0
	for i in arr:
		if 2 * i < k:
			res.append('0')
		elif 2 * i > k:
			res.append('1')
		elif 2 * i == k:
			res.append(str(midcur % 2))
			midcur += 1
	return ' '.join(res)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	res = algo(arr, n, k)
	print(res)


def iinput():
	return [int(i) for i in input().split()]
t = int(input())
for _ in range(t):
	(n, t) = iinput()
	mas = iinput()
	fl = True
	ans = []
	for i in range(n):
		if mas[i] < t / 2:
			ans += [0]
		elif mas[i] == t / 2 and fl:
			ans += [0]
			fl = not fl
		elif mas[i] == t / 2 and (not fl):
			ans += [1]
			fl = not fl
		else:
			ans += [1]
	print(*ans)


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	li = list(map(int, input().split()))
	tmp = 0
	for i in range(n):
		if li[i] < t / 2:
			li[i] = 0
		elif li[i] > t / 2:
			li[i] = 1
		else:
			li[i] = tmp % 2
			tmp += 1
	print(*li)


import bisect
for _ in range(int(input())):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	c = [0] * n
	p = 1
	for i in range(n):
		if a[i] > T // 2:
			c[i] = 1
		elif a[i] == T // 2 and T & 1 == 0:
			c[i] = p & 1
			p += 1
	print(*c)


import sys

def main():
	(n, t) = map(int, sys.stdin.readline().split())
	q = list(map(int, sys.stdin.readline().split()))
	d = {}
	for i in range(n):
		if q[i] in d:
			d[q[i]].append(i)
		else:
			d[q[i]] = [i]
	res = [0 for i in range(n)]
	g = []
	for i in d:
		if t - i in d and t - i not in g:
			g.append(i)
			for o in d[i]:
				res[o] = 1
	if t % 2 == 0:
		if t // 2 in d:
			f = d[t // 2]
			l = len(f) // 2
			for i in f[:l]:
				res[i] = 0
	print(*res)
for i in range(int(sys.stdin.readline().strip())):
	main()


from enum import *
from copy import *
from sys import *
from collections import *
from itertools import *
from functools import *
from math import *

def l2i(fr=None):
	return map_type_to_fr(int, fr)[0]

def i2i(fr=None):
	return l2i(fr)

def dbg(*args):
	print(*args, file=stderr)

def dbv(var_name):
	print(f'{var_name} = {eval(var_name)}', file=stderr)

def map_type_to_fr(t, fr):
	global GETLINE_OFFSET
	if fr is None:
		if RUNNING_ON_MY_PC:
			fr = TEST_INP[GETLINE_OFFSET].split()
			GETLINE_OFFSET += 1
		else:
			fr = input().split()
	return list(map(t, fr))

def mis(fr=None):
	return map_type_to_fr(int, fr)

def mbs(fr=None):
	return map_type_to_fr(bool, fr)

def gs(fr=None):
	return map_type_to_fr(str, fr)[0]
import os
import sysconfig
RUNNING_ON_MY_PC = os.name == 'nt' and platform == 'win32' and (sysconfig.get_platform() == 'win-amd64')
GETLINE_OFFSET = 0
TEST_INP = '2\n6 7\n1 2 3 4 5 6\n3 6\n3 3 3\n'.split('\n')

def my_r(x):
	c = ceil(x)
	if c - x > 0.5:
		return floor(x)
	return c
for _ in range(i2i()):
	clr = dict()
	(n, T) = mis()
	a = mis()
	s = sorted(a)
	c = Counter(a)
	sc = sorted(c.items())
	for el in sc:
		if clr.get(el) is not None:
			break
		v = el[0]
		opp = T - v
		if opp != v:
			clr[v] = 'w'
			if c.get(opp) is not None:
				clr[opp] = 'b'
			continue
		clr[v] = 'x'
	ptr = defaultdict(bool)
	ans = [None for _ in range(n)]
	for (i, x) in enumerate(a):
		curr_clr = clr[x]
		if curr_clr != 'x':
			ans[i] = 0 if curr_clr == 'b' else 1
		else:
			ans[i] = int(ptr[x])
			ptr[x] = not ptr[x]
	print(*ans)


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	q = int(input())
	for i in range(q):
		(n, t) = map(int, input().split())
		a = list(map(int, input().split()))
		d = collections.defaultdict(list)
		ans = [0] * n
		for j in range(n):
			d[a[j]].append(j)
		k = set(d.keys())
		if t % 2 == 0 and t // 2 in k:
			for j in range(len(d[t // 2]) // 2):
				temp = d[t // 2][j]
				ans[temp] = 1
		v = set()
		for j in k:
			if t % 2 == 0 and t // 2 == j:
				continue
			if t - j not in v and t - j in k:
				v.add(t - j)
				v.add(j)
				for x in d[j]:
					ans[x] = 1
		print(' '.join([str(x) for x in ans]))
main()


def solve():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = [0] * n
	d = {}
	for i in range(n):
		if a[i] <= k:
			p = a[i]
			q = k - a[i]
			if p == q:
				if not p in d:
					d[p] = 0
				d[p] += 1
				if d[p] % 2 == 0:
					b[i] = 1
			elif p > q:
				b[i] = 1
	print(' '.join(map(str, b)))
t = int(input())
i = 0
while i < t:
	solve()
	i += 1


import typing
import sys
import math
import collections
import bisect
import itertools
import fractions
import copy
import heapq
import decimal
import queue
INF = 10 ** 16
MOD = 998244353

def ni():
	return int(sys.stdin.readline())

def ns():
	return map(int, sys.stdin.readline().split())

def na():
	return list(map(int, sys.stdin.readline().split()))

def main():
	t = ni()
	for _ in range(t):
		(n, lim) = ns()
		a = na()
		ans = [-1 for _ in range(n)]
		flg = not lim % 2
		cnt = 0
		for (i, ai) in enumerate(a):
			if flg and ai == lim // 2:
				ans[i] = cnt
				cnt ^= 1
				continue
			if ai <= lim // 2:
				ans[i] = 0
			else:
				ans[i] = 1
		print(*ans, sep=' ')
main()


t = int(input())
for _ in range(t):
	(n, u) = map(int, input().split())
	a = list(map(int, input().split()))
	k = u // 2
	p = [-1 for i in range(n)]
	if u % 2 != 0:
		for i in range(n):
			if a[i] <= k:
				p[i] = 0
			else:
				p[i] = 1
	else:
		x = 0
		for i in range(n):
			if a[i] < k:
				p[i] = 0
			elif a[i] > k:
				p[i] = 1
			elif a[i] == k:
				if x == 0:
					p[i] = 0
					x = 1
				else:
					p[i] = 1
					x = 0
	print(*p)


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	d = {}
	ans = [0] * n
	for (i, v) in enumerate(l):
		if v > k:
			continue
		if k - v in d:
			if not d[k - v]:
				ans[i] = 1
		d[v] = ans[i]
	print(*ans)


t = int(input())
for _ in range(t):
	(n, T) = (int(i) for i in input().split())
	a = [int(i) for i in input().split()]
	m = T / 2
	nextc = 0
	r = []
	for i in a:
		if i < m:
			r.append(0)
		elif i > m:
			r.append(1)
		else:
			r.append(nextc)
			nextc = 1 - nextc
	print(' '.join([str(i) for i in r]))


MOD = 1000000007
from collections import defaultdict as dd, Counter, deque

def si():
	return input()

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def mi():
	return map(int, input().split())

def out(v):
	print(v)

def spout():
	print(v, end=' ')

def d2b(n):
	return bin(n).replace('0b', '')

def twod(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def vow():
	return ['a', 'e', 'i', 'o', 'u']

def let():
	return [chr(i) for i in range(97, 123)]

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ispow2(x):
	return x and (not x & x - 1)

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)
t = ii()
while t:
	t -= 1
	(n, k) = mi()
	a = li()
	ans = [0 for _ in range(n)]
	div = k // 2
	c = 0
	if k % 2 == 1:
		for i in range(n):
			if a[i] <= div:
				ans[i] = 1
	else:
		for i in range(n):
			if a[i] < div:
				ans[i] = 1
			elif a[i] == div:
				if c % 2 == 0:
					ans[i] = 1
					c += 1
				else:
					c += 1
	print(' '.join((str(i) for i in ans)))


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True

def main():
	for _ in range(ii()):
		d = collections.defaultdict(list)
		(n, t) = mi()
		arr = li()
		j = 0
		for (i, ele) in enumerate(arr):
			if ele * 2 < t:
				arr[i] = '0'
			elif ele * 2 > t:
				arr[i] = '1'
			else:
				arr[i] = ['0', '1'][j]
				j = 1 - j
		print(*arr)
main()


testcases = int(input())
for _ in range(testcases):
	(n, t) = map(int, input().split())
	l = list(map(int, input().split()))
	result = [0 for i in range(len(l))]
	worb = 0
	for i in range(len(l)):
		if l[i] < t / 2:
			result[i] = 0
		elif l[i] == t / 2:
			if worb % 2 == 0:
				result[i] = 0
			else:
				result[i] = 1
			worb += 1
		else:
			result[i] = 1
	print(*result)


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	b = [0] * n
	if t % 2 == 1:
		r = t // 2
		for i in range(n):
			if a[i] > r:
				b[i] = 1
		print(*b)
	else:
		r = t // 2
		s = a.count(r)
		for i in range(n):
			if a[i] > r:
				b[i] = 1
		ch = 0
		for i in range(n):
			if a[i] == r and ch < s // 2:
				b[i] = 1
				ch += 1
		print(*b)


from sys import *
from math import *
t = int(stdin.readline())
for _ in range(t):
	(n, k) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	d = {}
	for i in range(n):
		d[a[i]] = 0
	for i in range(n):
		d[k - a[i]] = 0
	for i in range(n):
		d[a[i]] += 1
	for i in range(n):
		if a[i] == k - a[i]:
			if d[k - a[i]] > 0 and d[a[i]] > 0:
				d[a[i]] -= 1
				d[k - a[i]] -= 1
				a[i] = -1
		elif a[i] < k - a[i]:
			if d[k - a[i]] > 0:
				d[a[i]] -= 1
				a[i] = -1
	for i in range(n):
		if a[i] == -1:
			a[i] = 1
		else:
			a[i] = 0
	print(*a)


def f(a, t):
	n = len(a)
	p = 0
	t /= 2
	ans = []
	for i in range(n):
		if a[i] > t:
			ans.append(0)
		elif a[i] < t:
			ans.append(1)
		else:
			ans.append(p)
			p = 1 - p
	for i in range(n):
		print(ans[i], end=' ')
tc = int(input())
for i in range(tc):
	(n, t) = [int(j) for j in input().split()]
	a = list(map(int, input().split()))
	f(a, t)
	print()


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = []
	val = t // 2
	if t % 2 != 0:
		for i in range(n):
			if arr[i] > val:
				ans.append(1)
			else:
				ans.append(0)
	else:
		cnt = True
		for i in range(n):
			if arr[i] == val:
				if cnt:
					ans.append(1)
					cnt = False
				else:
					ans.append(0)
					cnt = True
			elif arr[i] > val:
				ans.append(1)
			else:
				ans.append(0)
	print(*ans)


from collections import defaultdict
for i in range(int(input())):
	(n, t) = [int(i) for i in input().split()]
	app = defaultdict(lambda : -1)
	arr = [int(i) for i in input().split()]
	ans = [0 for i in range(n)]
	for i in range(n):
		if arr[i] > t:
			continue
		elif app[t - arr[i]] != -1:
			ans[i] = ans[app[t - arr[i]]] ^ 1
			app[arr[i]] = i
		else:
			app[arr[i]] = i
	print(*ans)


import itertools
import math
import sys
from collections import defaultdict

def stdinWrapper():
	data = '4\n6 7\n1 2 3 4 5 6\n3 6\n3 3 3\n8 4\n2 2 2 2 2 2 2 2 2\n8 7\n4 3 4 3 1 6 2 2 3 3\n\n'
	for line in data.split('\n'):
		yield line
if '--debug' not in sys.argv:

	def stdinWrapper():
		while True:
			yield sys.stdin.readline()
inputs = stdinWrapper()

def inputWrapper():
	return next(inputs)

def getType(_type):
	return _type(inputWrapper())

def getArray(_type):
	return [_type(x) for x in inputWrapper().split()]

def solve(a, t):
	a = [[i, v] for (i, v) in enumerate(a)]
	a.sort(key=lambda x: x[1])
	target = t / 2
	last_equal = 0
	for i in range(len(a)):
		if a[i][1] < target:
			a[i][1] = 0
		elif a[i][1] > target:
			a[i][1] = 1
		else:
			a[i][1] = last_equal
			last_equal = 1 - last_equal
	a.sort(key=lambda x: x[0])
	return ' '.join([str(x[1]) for x in a])
t = getType(int)
for _ in range(t):
	(n, T) = getArray(int)
	a = getArray(int)
	res = solve(a, T)
	print(res)


from collections import defaultdict

def put():
	return map(int, input().split())
t = int(input())
for _ in range(t):
	(n, k) = put()
	l = list(put())
	white = defaultdict()
	same = defaultdict()
	c = []
	for i in l:
		if i * 2 == k:
			if i not in same:
				same[i] = 0
			c.append(same[i])
			same[i] = 1 - same[i]
		elif k - i not in white:
			c.append(0)
			white[i] = 1
		else:
			c.append(1)
	print(*c)


for _ in range(int(input())):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = []
	h = 0
	for x in a:
		if 2 * x < T:
			ans += [0]
		elif 2 * x > T:
			ans += [1]
		else:
			ans.append(h)
			h = 1 - h
	print(*ans)


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split(' '))
		a = list(map(int, input().split(' ')))
		temp = []
		ans = [0 for x in range(n)]
		chk = 0
		if k % 2 == 0:
			chk = 1
		boss = []
		for x in range(n):
			if chk == 1:
				if k // 2 == a[x]:
					boss.append(x)
					continue
			temp.append([a[x], x])
		temp.sort()
		chk = 0
		for x in boss:
			if chk == 0:
				ans[x] = 1
				chk = 1
			else:
				ans[x] = 0
				chk = 0
		low = 0
		high = len(temp) - 1
		while low < high:
			if temp[low][0] + temp[high][0] == k:
				ans[temp[high][1]] = 1
				high -= 1
			elif temp[low][0] + temp[high][0] < k:
				ans[temp[low][1]] = 0
				low += 1
			else:
				ans[temp[high][1]] = 1
				high -= 1
		print(*ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


testcases = int(input())
for testcase in range(testcases):
	temparr = input()
	temparr = temparr.split()
	n = int(temparr[0])
	k = int(temparr[1])
	arr = []
	temparr = input()
	temparr = temparr.split()
	for i in temparr:
		arr.append(int(i))
	ans = []
	dicts1 = {}
	dicts0 = {}
	for i in arr:
		if k - i not in dicts0:
			if i not in dicts0:
				dicts0[i] = 1
			else:
				dicts0[i] += 1
			ans.append('0')
			continue
		if k - i not in dicts1:
			if i not in dicts1:
				dicts1[i] = 1
			else:
				dicts1[i] += 1
			ans.append('1')
			continue
		diff = k - i
		getmin0 = dicts0[diff]
		getmin1 = dicts1[diff]
		if getmin0 >= getmin1:
			ans.append('1')
			if i not in dicts1:
				dicts1[i] = 1
			else:
				dicts1[i] += 1
			continue
		else:
			ans.append('0')
			if i not in dicts0:
				dicts0[i] = 1
			else:
				dicts0[i] += 1
			continue
	print(' '.join(ans))


from collections import Counter

def read_int():
	n = int(input())
	return n

def read_ints():
	ints = [int(x) for x in input().split(' ')]
	return ints

def solve(n, T, a):
	sol = [0] * n
	c = Counter()
	d = Counter()
	c[T - a[0]] += 1
	sol[0] = 1
	for i in range(1, n):
		c_cnt = 0
		d_cnt = 0
		if a[i] in c.keys():
			c_cnt += c[a[i]]
		if a[i] in d.keys():
			d_cnt += d[a[i]]
		if min(c_cnt, d_cnt) == c_cnt:
			c[T - a[i]] += 1
			sol[i] = 1
		else:
			d[T - a[i]] += 1
	return ' '.join([str(x) for x in sol])
t = read_int()
for case in range(t):
	(n, T) = read_ints()
	a = read_ints()
	sol = solve(n, T, a)
	print(sol)


from itertools import combinations
for _ in range(int(input())):
	(n, T) = map(int, input().split())
	arr = list(map(int, input().split()))
	p = [0 for i in range(n)]
	if T % 2 == 0:
		m = T // 2
		mf = 0
	else:
		m = mf = -1
	t = []
	for i in range(n):
		if arr[i] == m:
			if mf:
				p[i] = 1
			mf = 1 - mf
		elif arr[i] in t:
			p[i] = 1
		else:
			t.append(T - arr[i])
	print(*p)


import sys
from collections import defaultdict
input = sys.stdin.readline

def solve():
	(n, x) = map(int, input().split())
	L = list(map(int, input().split()))
	d = defaultdict(int)
	for i in range(n):
		d[L[i]] += 1
	ans = [0] * n
	visit = set()
	flag = 0
	for i in range(n):
		diff = x - L[i]
		if diff == L[i]:
			d[diff] -= 1
			ans[i] = 1 ^ flag
			flag = 1 ^ flag
		elif d[diff] > 0:
			d[L[i]] = 0
			ans[i] = 1
	print(*ans)
for _ in range(int(input())):
	solve()


x1 = int(input())
for i in range(x1):
	(n, t) = map(int, input().split())
	l = list(map(int, input().split()))
	c = 0
	d = 0
	ff = 0
	f = []
	for i in range(n):
		if l[i] < t / 2:
			l[i] = 0
			c += 1
		elif l[i] > t / 2:
			l[i] = 1
			d += 1
		else:
			l[i] = ff % 2
			ff += 1
	print(*l)


import sys
sys.setrecursionlimit(10000000)
mod = 10 ** 9 + 7
INF = float('inf')
from sys import stdin
readline = stdin.readline

def readInts():
	return list(map(int, readline().split()))

def readTuples():
	return tuple(map(int, readline().split()))

def I():
	return int(readline())
from collections import Counter
q = I()
for i in range(q):
	(n, T) = readInts()
	A = readInts()
	ans = []
	cnt = 0
	for i in range(n):
		v = A[i]
		if T % 2 == 0 and v * 2 == T:
			ans.append(cnt % 2)
			cnt += 1
		elif v * 2 <= T:
			ans.append(0)
		else:
			ans.append(1)
	print(*ans)


N = int(input())
for _ in range(N):
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	d = 0
	for j in range(A[0]):
		if j != A[0] - 1:
			if B[j] < A[1] / 2:
				print(1, end=' ')
			elif B[j] == A[1] / 2:
				print(d % 2, end=' ')
				d += 1
			else:
				print(0, end=' ')
		elif B[j] < A[1] / 2:
			print(1, end=' ')
		elif B[j] == A[1] / 2:
			print(d % 2, end=' ')
			d += 1
		else:
			print(0, end=' ')


from collections import defaultdict
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	d = defaultdict(list)
	for i in range(n):
		d[arr[i]].append(i)
	ans = [-1] * n
	s = set(arr)
	for i in s:
		if i == m - i:
			for j in range(len(d[i]) // 2):
				ans[d[i][j]] = 0
			for j in range(len(d[i]) // 2, len(d[i])):
				ans[d[i][j]] = 1
		else:
			for j in d[i]:
				ans[j] = 0
			for j in d[m - i]:
				ans[j] = 1
	print(*ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = [0] * n
	cur = 0
	for i in range(n):
		if a[i] > k // 2:
			ans[i] = 1
		elif k % 2 == 0 and a[i] == k // 2:
			ans[i] = cur % 2
			cur += 1
		else:
			ans[i] = 0
	print(*ans)


for aww in range(int(input())):
	(a, b) = [*map(int, input().split())]
	c = [*map(int, input().split())]
	d = [i for i in range(len(c))]
	f = []
	g = []
	if b % 2 == 1:
		for i in range(len(c)):
			if c[i] % 2 == 0:
				d[i] = 1
			else:
				d[i] = 0
	else:
		x = 0
		for i in range(len(c)):
			if c[i] < b // 2:
				d[i] = 1
			elif c[i] > b // 2:
				d[i] = 0
			else:
				d[i] = x
				x = 1 - x
	print(' '.join(map(str, d)))


t = int(input())
for _ in range(t):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	white = set()
	if not T % 2 and T // 2 in a:
		halfcount = 0
		for i in range(len(a)):
			if a[i] == T // 2:
				if halfcount % 2:
					a[i] = 1
				else:
					a[i] = 0
				halfcount += 1
			elif T - a[i] in white:
				a[i] = 1
			else:
				white.add(a[i])
				a[i] = 0
	else:
		for i in range(len(a)):
			if T - a[i] in white:
				a[i] = 1
			else:
				white.add(a[i])
				a[i] = 0
	print(*a)


import os, sys
from io import IOBase, BytesIO
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def solve():
	t = int(input())
	for _ in range(t):
		(n, T) = map(int, input().split())
		arr = list(map(int, input().split()))
		x = []
		for a in range(len(arr)):
			x.append((arr[a], a))
		x.sort()
		st_ptr = 0
		en_ptr = n - 1
		res = [0] * n
		while st_ptr <= en_ptr:
			if x[st_ptr][0] + x[en_ptr][0] == T:
				res[x[st_ptr][1]] = 1
				st_ptr += 1
				en_ptr -= 1
			elif x[st_ptr][0] + x[en_ptr][0] < T:
				res[x[st_ptr][1]] = 1
				st_ptr += 1
			elif x[st_ptr][0] + x[en_ptr][0] > T:
				en_ptr -= 1
		cout << ' '.join(map(str, res)) << endl

def main():
	solve()
main()


t = int(input())
for _ in range(t):
	(n, T) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	ans = [0 for __ in range(n)]
	zeroNext = True
	for i in range(n):
		x = arr[i]
		if 0 <= x <= T:
			if x * 2 == T:
				if zeroNext:
					ans[i] = 0
				else:
					ans[i] = 1
				zeroNext = not zeroNext
			elif x * 2 < T:
				ans[i] = 0
			elif x * 2 > T:
				ans[i] = 1
	print(' '.join([str(x) for x in ans]))


import math
cases = int(input())
for tc in range(cases):
	(n, t) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	nt = t // 2
	c = [i for i in range(n) if a[i] <= nt]
	dc = {}
	for i in c:
		if a[i] in dc:
			dc[a[i]].append(i)
		else:
			dc[a[i]] = [i]
	c = []
	for i in dc:
		li = len(dc[i])
		if li > 1 and 2 * i == t:
			mid = math.ceil(li / 2)
			c.extend(dc[i][:mid])
		else:
			c.extend(dc[i])
	a = [1] * n
	for i in c:
		a[i] = 0
	print(*a)


import sys
import math
input = sys.stdin.readline

def inInt():
	return int(input())

def inStr():
	return input().strip('\n')

def inIList():
	return list(map(int, input().split()))

def inSList():
	return input().split()

def solve(n, a, k):
	ret = []
	if k % 2 != 0:
		t = k // 2
		for x in range(n):
			if a[x] <= t:
				ret.append(0)
			else:
				ret.append(1)
	else:
		t = k // 2
		c = 0
		for x in range(n):
			if a[x] == t:
				c = c + 1
		p = 0
		for x in range(n):
			if a[x] < t:
				ret.append(0)
			elif a[x] > t:
				ret.append(1)
			else:
				if p < c / 2:
					ret.append(0)
				else:
					ret.append(1)
				p = p + 1
	print(*ret)
tasks = inInt()
for t in range(tasks):
	params = inIList()
	n = params[0]
	k = params[1]
	l = inIList()
	solve(n, l, k)


import math
for t in range(int(input())):
	(num, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	col = [-1] * num
	flag = 0
	for i in range(len(arr)):
		if k % 2 == 0:
			if arr[i] < math.ceil(k / 2):
				col[i] = 0
			elif arr[i] == k // 2:
				if flag == 0:
					col[i] = 0
					flag = 1
				else:
					col[i] = 1
					flag = 0
			else:
				col[i] = 1
		elif arr[i] < math.ceil(k / 2):
			col[i] = 0
		else:
			col[i] = 1
	print(*col)


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = []
	flag = 0
	for i in range(n):
		if arr[i] < t / 2:
			ans.append(0)
		elif arr[i] > t / 2:
			ans.append(1)
		else:
			ans.append(flag)
			flag = (flag + 1) % 2
	print(*ans)


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
sys.setrecursionlimit(10 ** 6)
I = sys.stdin.readline

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

def mi():
	return map(int, I().strip().split())

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def divi(n):
	ans = []
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			ans.append((i, n // i))
	return ans

def main():
	ans = ''
	for _ in range(ii()):
		(n, t) = mi()
		arr = li()
		flag = 0
		for i in range(n):
			if t % 2 == 0 and arr[i] == t // 2:
				arr[i] = flag
				flag = 1 - flag
			elif arr[i] <= t // 2:
				arr[i] = 0
			else:
				arr[i] = 1
		print(*arr)
main()


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	arr = [int(i) for i in input().split()]
	a = 1
	for i in arr:
		if i == k / 2:
			print(a, end=' ')
			a = int(not a)
		elif i < k / 2:
			print(1, end=' ')
		else:
			print(0, end=' ')
	print()


t = int(input())
for i in range(0, t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	s = [0 for j in range(0, n)]
	q = 0
	m = 0
	for j in range(0, n):
		if a[j] <= k // 2 and a[j] // 2 != k / 2:
			s[j] = 1
		if a[j] == k / 2:
			m = m + 1
			if m % 2 == 0:
				s[j] = 0
			else:
				s[j] = 1
	print(*s)


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	b = True if k % 2 == 0 else False
	num = 0
	if b == True:
		num = arr.count(k / 2)
	num //= 2
	for i in range(n):
		if arr[i] < k // 2:
			print(1, end=' ')
		elif arr[i] > k // 2:
			print(0, end=' ')
		elif b == False:
			print(1, end=' ')
		elif num > 0:
			print(1, end=' ')
			num -= 1
		else:
			print(0, end=' ')
	print()
	t -= 1


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	x = t / 2
	sol = []
	y = True
	for i in a:
		if i < x:
			sol.append(0)
		elif i > x:
			sol.append(1)
		else:
			sol.append(1 if y else 0)
			y = not y
	print(' '.join([str(i) for i in sol]))


t = int(input())
for i in range(t):
	(n, T) = map(int, input().split())
	s = [int(i) for i in input().split()]
	h = 0
	d = []
	for i in range(n):
		if s[i] < T / 2:
			d.append(0)
		elif s[i] > T / 2:
			d.append(1)
		else:
			d.append(str(h))
			h = (h + 1) % 2
	print(*d)


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = [int(x) for x in input().split()]
	dicti = {}
	ans = [1] * n
	for z in range(n):
		p = t - a[z]
		if p in dicti:
			ans[z] = 1 - dicti[p]
			dicti[a[z]] = ans[z]
		else:
			dicti[a[z]] = 1
	print(*ans)


from collections import defaultdict
for _ in range(int(input())):
	(n, t) = [int(i) for i in input().split()]
	arr = [int(i) for i in input().split()]
	Dict_pre = defaultdict(list)
	Dict_1 = defaultdict(int)
	Dict_0 = defaultdict(int)
	col = [-1] * n
	for i in range(n):
		temp = abs(t - arr[i])
		if Dict_1[temp] <= Dict_0[temp]:
			col[i] = 1
			Dict_1[arr[i]] += 1
		else:
			col[i] = 0
			Dict_0[arr[i]] += 1
	print(*col)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = [0] * n
	col = 0
	for i in range(n):
		if k % 2 == 0 and arr[i] == k // 2:
			ans[i] = col
			col ^= 1
		elif arr[i] <= (k - 1) // 2:
			ans[i] = 0
		elif arr[i] > (k - 1) // 2:
			ans[i] = 1
	print(*ans)


import sys
import math
import bisect
import heapq
from bisect import bisect_right
from sys import stdin, stdout

def get_ints_in_variables():
	return map(int, sys.stdin.readline().strip().split())

def get_int():
	return int(sys.stdin.readline())

def get_ints_in_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_list_of_list(n):
	return [list(map(int, sys.stdin.readline().strip().split())) for _ in range(n)]

def get_string():
	return sys.stdin.readline().strip()

def Solution(arr, n, t):
	f = 1
	for v in arr:
		if t % 2 == 0 and v == t // 2:
			r = f
			if f:
				f = 0
			else:
				f = 1
		elif 2 * v > t:
			r = 1
		else:
			r = 0
		print(r, end=' ')
	print()

def main():
	for _ in range(get_int()):
		(n, t) = get_ints_in_variables()
		arr = get_ints_in_list()
		Solution(arr, n, t)
main()


import sys

def main():
	T = int(input())
	for ti in range(T):
		(n, k) = map(int, input().split())
		A = [int(a) for a in input().split()]
		c = 0
		m = k / 2
		ans = []
		for a in A:
			if a < m:
				ans.append(1)
			elif a > m:
				ans.append(0)
			elif c == 0:
				ans.append(0)
				c = 1 - c
			else:
				ans.append(1)
				c = 1 - c
		print(' '.join(map(str, ans)))
main()


for dsds in range(int(input())):
	(n, t) = map(int, input().split())
	s = list(map(int, input().split()))
	f = dict()
	for elem in s:
		if elem not in f:
			f[elem] = 0
			f[t - elem] = 1
	q = [f[s[i]] for i in range(n)]
	a = 0
	for i in range(n):
		if s[i] * 2 == t:
			q[i] = a
			a = (a + 1) % 2
	print(str(q)[1:-1].replace(',', ''))


from collections import defaultdict

def solve(n, t):
	d1 = defaultdict(int)
	d2 = defaultdict(int)
	for i in l:
		if t - i in d1:
			if t - i in d2:
				if d1[t - i] > d2[t - i]:
					d2[i] += 1
				else:
					d1[i] += 1
			else:
				d2[i] += 1
		else:
			d1[i] += 1
	for i in l:
		if i in d1 and d1[i] > 0:
			print(1, end=' ')
			d1[i] -= 1
		else:
			print(0, end=' ')
			d2[i] -= 1
	print()
for _ in range(int(input())):
	(n, t) = map(int, input().split())
	l = list(map(int, input().split()))
	solve(n, t)


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def solve():
	(n, k) = li()
	a = li()
	ans = [0] * n
	d = Counter(a)
	for i in d:
		d[i] = 0
	c = defaultdict(int)
	for i in d:
		if k - i in d and k - i != i:
			d[k - i] = d[i] ^ 1
		elif k - i in d and k - i == i:
			c[i] = 0
	for i in range(n):
		if a[i] not in c:
			ans[i] = d[a[i]]
		else:
			ans[i] = c[a[i]]
			c[a[i]] ^= 1
	print(*ans)
for _ in range(I()):
	solve()


from collections import Counter
t = int(input())
for t0 in range(t):
	(n, magic) = map(int, input().split())
	l = list(map(int, input().split()))
	cnt = Counter(l)
	nbWhite = {}
	for c in cnt:
		if not c in nbWhite:
			if magic - c in cnt:
				if c == magic - c:
					nbWhite[c] = cnt[c] // 2
				else:
					nbWhite[c] = cnt[c]
					nbWhite[magic - c] = 0
			else:
				nbWhite[c] = cnt[c]
	ret = []
	for i in range(n):
		c = l[i]
		wc = nbWhite[c]
		if wc >= 1:
			ret += [0]
			nbWhite[c] -= 1
		else:
			ret += [1]
	print(*ret)


import sys, functools, collections, bisect, math, heapq
input = sys.stdin.readline
sys.setrecursionlimit(200000)
mod = 10 ** 9 + 7
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().strip().split())
	arr = list(map(int, input().strip().split()))
	res = ['0'] * n
	a = collections.Counter()
	b = collections.Counter()
	for i in range(n):
		x = k - arr[i]
		if a[x] < b[x]:
			res[i] = '1'
			a[arr[i]] += 1
		else:
			b[arr[i]] += 1
	print(' '.join(res))


t = int(input())
for __ in range(t):
	(n, T) = map(int, input().split())
	arr = list(map(int, input().split()))
	put_in_c = 0
	ans = []
	c = set()
	for a in arr:
		if T - a in c:
			if T == 2 * a:
				ans.append(0 if put_in_c else 1)
				put_in_c ^= 1
			else:
				ans.append(1)
		else:
			ans.append(0)
			c.add(a)
	print(' '.join(map(str, ans)))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	c = True
	for x in a:
		if k % 2 == 0 and x * 2 == k:
			print('0 ' if c == True else '1 ', end='')
			c = not c
		elif 2 * x < k:
			print('0 ', end='')
		else:
			print('1 ', end='')
	print()


t = int(input())
ans = []
for i in range(t):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	d = dict()
	ans_i = []
	for j in range(n):
		if a[j] in d:
			ans_i.append(str(d[a[j]]))
			d[T - a[j]] = 1 - d[a[j]]
		else:
			ans_i.append('0')
			d[T - a[j]] = 1
	ans.append(' '.join(ans_i))
for x in ans:
	print(x)


CASES = int(input())
for _ in range(CASES):
	(n, t) = map(int, input().split())
	s = list(map(int, input().split()))
	ans = []
	flag = True
	for i in range(n):
		if s[i] < t / 2:
			ans.append(1)
		elif s[i] > t / 2:
			ans.append(0)
		else:
			if flag:
				ans.append(0)
			else:
				ans.append(1)
			flag = not flag
	print(*ans)


for _ in range(int(input())):
	(n, t) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	d = [None] * n
	if t % 2 != 0:
		for i in range(len(a)):
			if a[i] <= t // 2:
				d[i] = 0
			else:
				d[i] = 1
	else:
		for i in range(len(a)):
			if a[i] < t // 2:
				d[i] = 0
			elif a[i] > t // 2:
				d[i] = 1
		f = a.count(t // 2)
		f = f // 2
		for i in range(len(a)):
			if a[i] == t // 2:
				if f > 0:
					f -= 1
					d[i] = 0
				else:
					d[i] = 1
	print(*d, sep=' ')


from datetime import datetime
import datetime
import random
for _ in range(int(input())):
	n: object
	(n, k) = [int(x) for x in input().split()]
	L = [int(x) for x in input().split()]
	ans = [0] * n
	g = {}
	for x in range(n):
		if k - L[x] in g:
			ans[x] = 1 - ans[g[k - L[x]]]
		g[L[x]] = x
	print(*ans)


from collections import defaultdict
for _ in range(int(input())):
	(n, t) = list(map(int, input().strip().split()))
	x = list(map(int, input().strip().split()))
	d = defaultdict(int)
	p = {}
	for i in x:
		d[i] += 1
	for i in x:
		if i == t / 2:
			continue
		if i in d and i not in p:
			p[i] = True
			p[t - i] = False
	v = 0
	if t % 2 == 0:
		v = d[t // 2] // 2
	A = []
	for i in x:
		if i == t / 2:
			if v > 0:
				A.append(1)
				v -= 1
			else:
				A.append(0)
		elif p[i]:
			A.append(1)
		else:
			A.append(0)
	print(*A)


from collections import Counter
import string
import math
import sys
sys.setrecursionlimit(10 ** 6)

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(number_of_variables):
	if number_of_variables == 1:
		return int(sys.stdin.readline())
	if number_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
for _ in range(vary(1)):
	(n, T) = vary(2)
	num = array_int()
	flag = 1
	for i in range(n):
		if num[i] > T / 2:
			num[i] = 0
		elif num[i] < T / 2:
			num[i] = 1
		else:
			num[i] = flag
			flag = 1 - flag
	print(*num)


t = int(input())
for i in range(0, t):
	(m, n) = map(int, input().split())
	arr = list(map(int, input().strip().split()))[:m]
	l1 = []
	for j in range(0, m):
		l1.append(0)
	y = n / 2
	ct = 0
	for j in range(0, m):
		if arr[j] > y:
			l1[j] = 1
		if arr[j] == y:
			if ct % 2 == 0:
				ct += 1
			else:
				ct += 1
				l1[j] = 1
	print(*l1, sep=' ')


def read_ints():
	return map(int, input().split())
(t_n,) = read_ints()
for i_t in range(t_n):
	(n, t_const) = read_ints()
	a_seq = list(read_ints())
	if t_const % 2 == 1:
		colors = [a % 2 for a in a_seq]
	else:
		for i in range(len(a_seq)):
			a_seq[i] -= t_const // 2
		t_const = 0
		colors = []
		next_zero_color = 0
		for a in a_seq:
			if a < 0:
				color = 0
			elif a > 0:
				color = 1
			else:
				color = next_zero_color
				next_zero_color = (next_zero_color + 1) % 2
			colors.append(color)
	print(*colors)


from collections import defaultdict
testcase = int(input())
while testcase != 0:
	(n, k) = map(int, input().split())
	list1 = list(map(int, input().split()))
	d = defaultdict(list)
	for i in range(len(list1)):
		d[list1[i]].append(i)
	part1 = []
	part2 = []
	flag = {}
	for i in d.keys():
		flag[i] = 0
	for ind in d.keys():
		if flag[ind] == 1:
			continue
		if ind == k - ind:
			size = len(d[ind]) // 2
			temp1 = d[ind][:size]
			temp2 = d[ind][size:]
			part1.extend(temp1)
			part2.extend(temp2)
		else:
			part1.extend(d[ind])
			if k - ind not in d.keys():
				pass
			else:
				part2.extend(d[k - ind])
				flag[k - ind] = 1
	res = [-1] * n
	for i in range(len(part1)):
		res[part1[i]] = 0
	for i in range(len(part2)):
		res[part2[i]] = 1
	print(*res)
	testcase -= 1


import os, sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
try:
	(sys.stdin, sys.stdout) = (open('in.txt', 'r'), open('out.txt', 'w'))
except:
	pass
ii1 = lambda : int(sys.stdin.readline().strip())
is1 = lambda : sys.stdin.readline().strip()
iia = lambda : list(map(int, sys.stdin.readline().strip().split()))
isa = lambda : sys.stdin.readline().strip().split()
mod = int(1000000000.0 + 7)
from collections import *
from math import *
from functools import lru_cache
from math import *
for _ in range(ii1()):
	(n, t) = iia()
	arr = iia()
	tcount = 0
	ans = []
	for i in arr:
		if i * 2 == t and tcount == 0:
			ans.append(1)
			tcount ^= 1
		elif i * 2 == t and tcount == 1:
			tcount ^= 1
			ans.append(0)
		elif i > t / 2:
			ans.append(0)
		elif i < t / 2:
			ans.append(1)
	print(*ans)


import sys
input = sys.stdin.readline

def solve():
	(n, T) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	d = {}
	c = {}
	for i in a:
		if T - i not in d:
			ans = 0
			d[i] = d.get(i, 0) + 1
		elif T - i not in c:
			ans = 1
			c[i] = c.get(i, 0) + 1
		elif d[i] < c[i]:
			ans = 0
			d[i] += 1
		else:
			ans = 1
			c[i] += 1
		print(ans, end=' ')
	print()
t = int(input())
for _ in range(t):
	solve()


cases = int(input())
for i in range(cases):
	linea = input().strip().split(' ')
	(n, t) = (int(linea[0]), int(linea[1]))
	linea = input().strip().split(' ')
	a = list(map(int, linea))
	c = {}
	d = {}
	salida = ''
	for x in a:
		if c or d:
			salida += ' '
		if t - x not in c:
			o1 = 0
		else:
			o1 = c[t - x]
		if t - x not in d:
			o2 = 0
		else:
			o2 = d[t - x]
		if o1 <= o2:
			salida += '0'
			if x in c:
				c[x] += 1
			else:
				c[x] = 1
		else:
			salida += '1'
			if x in d:
				d[x] += 1
			else:
				d[x] = 1
	print(salida)


import collections
from collections import defaultdict
import math
from collections import Counter
for _ in range(int(input())):
	(n, T) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	d = {}
	seen = defaultdict(lambda : False)
	b = set(a)
	for x in b:
		if not seen[x]:
			seen[x] = True
			seen[T - x] = True
			d[x] = 1
			d[T - x] = 0
	ans = [d[x] for x in a]
	if T % 2 == 1:
		print(*ans)
	else:
		var = T // 2
		p = 1
		for i in range(n):
			if a[i] == var:
				ans[i] = p
				p = 1 - p
		print(*ans)


import sys
t = int(sys.stdin.readline().strip())
for _ in range(t):
	(n, k) = list(map(int, sys.stdin.readline().strip().split()))
	a = list(map(int, sys.stdin.readline().strip().split()))
	if k % 2 == 1:
		for i in range(n):
			if a[i] < k / 2:
				a[i] = 0
			else:
				a[i] = 1
	else:
		count = 1
		for i in range(n):
			if a[i] < k / 2:
				a[i] = 0
			elif a[i] > k / 2:
				a[i] = 1
			else:
				a[i] = count
				if count == 0:
					count = 1
				else:
					count = 0
	for i in range(n - 1):
		print(a[i], end=' ')
	print(a[-1])


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = [-1 for i in range(n)]
	w = set()
	l = set()
	sp = -1
	if k % 2 == 0:
		sp = k // 2
	pre = 0
	for i in range(n):
		if b[i] == -1 and a[i] != sp:
			d = k - a[i]
			if d not in w:
				b[i] = 0
				w.add(a[i])
			elif d not in l:
				b[i] = 1
				l.add(a[i])
		elif a[i] == sp:
			b[i] = pre
			if pre == 0:
				pre = 1
			else:
				pre = 0
	print(*b)


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())
for t in range(int(input())):
	(n, k) = get_ints()
	arr = list(get_ints())
	set1 = []
	set2 = []
	set1_counter = dict()
	set2_counter = dict()
	ans = []
	for i in range(n):
		ele = arr[i]
		diff = k - ele
		if diff in set1_counter:
			if diff in set2_counter:
				c1 = set1_counter[diff]
				c2 = set2_counter[diff]
				if c1 > c2:
					set2_counter[diff] += 1
					ans.append(0)
				else:
					set1_counter[diff] += 1
					ans.append(1)
			else:
				set2_counter[ele] = 1
				ans.append(0)
		else:
			set1_counter[ele] = 1
			ans.append(1)
	print(*ans)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a
from collections import defaultdict

def solve():
	(n, k) = sep()
	ar = lis()
	d = defaultdict(list)
	for i in range(n):
		d[ar[i]].append(i)
	ans = [-1] * n
	for i in range(n - 1, -1, -1):
		if ans[i] != -1:
			continue
		while d[ar[i]]:
			ind = d[ar[i]].pop()
			ans[ind] = 0
			if d[k - ar[i]]:
				ind2 = d[k - ar[i]].pop()
				ans[ind2] = 1
		while d[k - ar[i]]:
			ind2 = d[k - ar[i]].pop()
			ans[ind2] = 1
	print(*ans)
testcase(int(inp()))


t = int(input())
for _ in range(t):
	(n, T) = map(int, input().split())
	arr = list(map(int, input().split()))
	ans = []
	Tby2zero = Tby2one = 0
	for i in range(n):
		if 2 * arr[i] < T:
			ans.append(0)
		elif 2 * arr[i] > T:
			ans.append(1)
		elif Tby2zero <= Tby2one:
			ans.append(0)
			Tby2zero += 1
		else:
			ans.append(1)
			Tby2one += 1
	print(*ans, sep=' ')


t = int(input())
for i in range(t):
	(n, T) = map(int, input().split())
	arr = list(map(int, input().split()))
	first = True
	for j in range(n):
		if arr[j] < T / 2:
			arr[j] = 1
		elif arr[j] > T / 2:
			arr[j] = 0
		elif first:
			arr[j] = 1
			first = False
		else:
			arr[j] = 0
			first = True
	print(*arr)


n = int(input())
for i in range(n):
	(n, k) = [int(x) for x in input().split()]
	l = [int(x) for x in input().split()]
	h = {}
	c = []
	d = []
	a = []
	for x in l:
		if k - x in h:
			if x == k - x:
				if h[k - x] % 2 == 0:
					c.append(x)
					h[x] += 1
					a.append(1)
				else:
					d.append(x)
					a.append(0)
					h[x] += 1
			else:
				d.append(x)
				a.append(0)
		else:
			c.append(x)
			a.append(1)
			h[x] = 1
	for x in a:
		print(x, end=' ')
	print()


def TwoArray(n, arr, t):
	cnt = 0
	if t % 2 == 0:
		mid = t // 2
		for i in range(n):
			if arr[i] < mid:
				print(0, end=' ')
			elif arr[i] > mid:
				print(1, end=' ')
			else:
				if cnt % 2 == 0:
					print(0, end=' ')
				else:
					print(1, end=' ')
				cnt += 1
	else:
		for i in range(n):
			if arr[i] % 2 == 0:
				print(0, end=' ')
			else:
				print(1, end=' ')
t = int(input())
for _ in range(t):
	l = [int(i) for i in input().split()]
	(n, t) = (l[0], l[1])
	arr = [int(i) for i in input().split()]
	TwoArray(n, arr, t)
	print()


import math
import re
import itertools
import copy
import time
import sys
import functools

def input_linear(lamb=lambda x: int(x), seperator=' '):
	return map(lamb, input().split(seperator))

def input_array(lamb=lambda x: int(x), seperator=' '):
	return list(map(lamb, input().split(seperator)))

def input_matrix(rows, lamb=lambda x: int(x), seperator=' '):
	tmp_matrix = []
	for i in range(rows):
		tmp_matrix.append(input_array(lamb, seperator))
	return tmp_matrix

def input_graph_al_pair(vertices, lines, lamb=lambda x: int(x), seperator=' ', directional=False, remove_dup=False):
	temp_matrix = [x[:] for x in [[]] * vertices]
	if not directional:
		if not remove_dup:
			for i in range(lines):
				(ina, inb) = input_linear(lamb, seperator)
				temp_matrix[ina].append(inb)
				temp_matrix[inb].append(ina)
		else:
			for i in range(lines):
				(ina, inb) = input_linear(lamb, seperator)
				if inb not in temp_matrix[ina]:
					temp_matrix[ina].append(inb)
				if ina not in temp_matrix[inb]:
					temp_matrix[inb].append(ina)
		return temp_matrix
	else:
		if not remove_dup:
			for i in range(lines):
				(ina, inb) = input_linear(lamb, seperator)
				temp_matrix[ina].append(inb)
		else:
			for i in range(lines):
				(ina, inb) = input_linear(lamb, seperator)
				if inb not in temp_matrix[ina]:
					temp_matrix[ina].append(inb)
		return temp_matrix

def prettyp(a, typ='trash'):
	h = math.ceil(math.log(len(a), 2))
	for i in range(h):
		print(''.join(['  '] * (h - i)) + '  '.join(map(str, a[(1 << i) - 1:(1 << i + 1) - 1])))

def build_segment_t(a, lamb=lambda x, y: x + y):
	arr = [0] * len(a) + a.copy()
	for i in range(len(a) - 1, 0, -1):
		arr[i] = lamb(arr[i << 1], arr[i << 1 | 1])
	return arr

def mod_seg(a, pos, val):
	pos += len(a)
	a[pos] = val
	while pos > 1:
		a[pos >> 1] = a[pos] + a[pos ^ 1]
		pos >>= 1
for _ in range(int(input())):
	(n, k) = input_linear()
	a = input_array()
	if k % 2 == 0:
		fl = True
		for i in range(n):
			if a[i] > k / 2:
				print(1, end=' ')
			elif a[i] < k / 2:
				print(0, end=' ')
			elif a[i] == k / 2:
				print(int(fl), end=' ')
				fl = not fl
	else:
		for i in range(n):
			if a[i] > k / 2:
				print(1, end=' ')
			elif a[i] < k / 2:
				print(0, end=' ')
	print('')


import math
from sys import stdin, stdout
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')

def qpow(a, b, m):
	ans = 1
	while b:
		if b & 1:
			ans *= a
			ans %= m
		a *= a
		a %= m
		b >>= 1
	return ans
t = ip()
for _ in range(t):
	(n, T) = inp()
	a = list(inp())
	ans = []
	if T & 1:
		for i in range(n):
			if a[i] <= T // 2:
				ans.append(0)
			else:
				ans.append(1)
	else:
		flag = 0
		for i in range(n):
			if a[i] < T // 2:
				ans.append(0)
			elif a[i] == T // 2:
				ans.append(flag)
				flag = 1 - flag
			else:
				ans.append(1)
	print(*ans)


import sys
import bisect

def solution():
	get_input = sys.stdin.readline
	t = int(get_input().strip())
	for i in range(t):
		(n, large_t) = list(map(int, get_input().strip().split()))
		board = list(map(int, get_input().strip().split()))
		sorted_board = sorted(board)
		idx = sorted(range(n), key=lambda k: board[k])
		standard = large_t / 2
		a = bisect.bisect_left(sorted_board, standard)
		b = bisect.bisect_right(sorted_board, standard, lo=a)
		mid = (a + b) // 2
		result = [1] * n
		for j in range(mid, n):
			result[j] = 0
		sorted_result = [x for (_, x) in sorted(zip(idx, result))]
		for j in range(n):
			print(sorted_result[j], end=' ')
		print()
solution()


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	visit = [0] * n
	m = t / 2
	k10 = 0
	k11 = 0
	v = []
	for i in range(n):
		if a[i] > m:
			v.append(1)
		elif a[i] == m:
			if k10 > k11:
				v.append(1)
				k11 += 1
			else:
				v.append(0)
				k10 += 1
		else:
			v.append(0)
	for i in range(n):
		print(v[i], end=' ')
	print()


import sys
import math

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_ls():
	return list(map(int, sys.stdin.readline().strip().split()))

def main():
	for _ in range(int(input())):
		(n, t) = get_ints()
		ls = get_ls()
		cnt = 0
		for i in range(n):
			if ls[i] < t / 2:
				ls[i] = 0
			elif ls[i] > t / 2:
				ls[i] = 1
			else:
				ls[i] = cnt % 2
				cnt += 1
		print(*ls)
main()


t = int(input())
for tt in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	group = {}
	cnt = 0
	for ai in a:
		if ai == k / 2:
			cnt += 1
		else:
			group[ai] = 0
			group[k - ai] = 1
	ans = []
	cnt //= 2
	cur = 0
	for ai in a:
		if ai in group:
			ans.append(group[ai])
		elif cur < cnt:
			ans.append(0)
			cur += 1
		else:
			ans.append(1)
	print(' '.join(map(str, ans)))


def func(n, k, a):
	c = [0] * n
	m = k / 2.0
	flag = False
	for i in range(n):
		if a[i] > m:
			c[i] = 1
		elif a[i] == m:
			c[i] = int(flag)
			flag = not flag
	return c
m = input()
m = int(m)
for i in range(m):
	(n, t) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	c = func(n, t, a)
	for j in c:
		print(j, end=' ')
	print()


import sys
k = int(sys.stdin.readline().strip())
for i in range(k):
	(n, t) = map(int, sys.stdin.readline().split())
	arr = list(map(int, sys.stdin.readline().split()))
	ans = [0 for h in range(n)]
	if t % 2 == 1:
		for j in range(n):
			if arr[j] % 2 == 1:
				print(0, end=' ')
			else:
				print(1, end=' ')
		print(' ')
	else:
		s = set()
		d = arr.count(t / 2) / 2
		for j in range(n):
			if arr[j] == t / 2 and d > 0:
				ans[j] = 1
				d -= 1
		for l in range(n):
			if arr[l] != t / 2:
				if t - arr[l] not in s:
					s.add(arr[l])
					ans[l] = 1
		for j in ans:
			print(j, end=' ')
		print(' ')


for _ in range(int(input())):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	b = [False for _ in range(n)]
	(s1, s2) = (set(), set())
	p = T // 2
	pk = 0
	f = T % 2 == 0
	for i in range(n):
		if f and a[i] == p:
			b[i] = bool(pk % 2)
			pk += 1
		elif a[i] in s1:
			b[i] = True
		elif not a[i] in s2:
			s1.add(a[i])
			b[i] = True
			s2.add(T - a[i])
	for i in b:
		print(0 if i else 1, end=' ')
	print()


from math import *
for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	got = 0
	if t % 2 == 0:
		for i in a:
			if i < ceil(t / 2):
				print(1, end=' ')
			elif i > ceil(t / 2):
				print(0, end=' ')
			elif got % 2 == 0:
				print(0, end=' ')
				got += 1
			else:
				print(1, end=' ')
				got += 1
	else:
		for i in a:
			if i < ceil(t / 2):
				print(1, end=' ')
			elif i > ceil(t / 2):
				print(0, end=' ')
			else:
				print(0, end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, T) = map(int, input().split())
	A = list(map(int, input().split()))
	d = {}
	for (i, a) in enumerate(A):
		if a in d:
			d[a].append(i)
		else:
			d[a] = [i]
	p = [-1] * n
	used = set()
	for (k, l) in d.items():
		m = len(l)
		if k in used:
			continue
		if k * 2 == T:
			for i in range(m // 2):
				idx = l[i]
				p[idx] = 0
			for i in range(m // 2, m):
				idx = l[i]
				p[idx] = 1
			used.add(k)
		elif T - k in d:
			for idx in l:
				p[idx] = 0
			for idx in d[T - k]:
				p[idx] = 1
			used.add(k)
			used.add(T - k)
		else:
			for idx in l:
				p[idx] = 0
			used.add(k)
	print(*p)


t = int(input())
while t:
	t -= 1
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	arr = [int(x) for x in input().split(' ')]
	ans = []
	temp = True
	for i in arr:
		if i < k / 2:
			ans.append(0)
		elif i > k / 2:
			ans.append(1)
		else:
			ans.append(int(not temp))
			temp = not temp
	print(*ans)


import sys
read = lambda : sys.stdin.readline().strip()
readi = lambda : map(int, read().split())
from collections import defaultdict
for _ in range(int(read())):
	(n, t) = readi()
	nums = list(readi())
	bkt1 = defaultdict(int)
	bkt2 = defaultdict(int)
	for num in nums:
		if num > t:
			print(0, end=' ')
			continue
		f1 = bkt1[t - num]
		f2 = bkt2[t - num]
		if f1 <= f2:
			bkt1[num] += 1
			print(0, end=' ')
		else:
			bkt2[num] += 1
			print(1, end=' ')
	print()


t = int(input())
for i in range(t):
	(n, T) = map(int, input().split())
	l = list(map(int, input().split()))
	l2 = [0] * n
	d = {}
	for j in range(n):
		if l[j] not in d:
			d[l[j]] = [j]
		else:
			d[l[j]].append(j)
	l1 = list(d)
	l1.sort()
	d1 = {}
	for j in l1:
		if not (j not in d1 and T - j not in d1):
			continue
		d1[j] = 1
		d1[T - j] = 1
		if T - j in d:
			if T - j == j:
				b = 1
				for k in d[T - j]:
					l2[k] = b
					b = (b + 1) % 2
			else:
				for k in d[T - j]:
					l2[k] = 1
	print(*l2)


from sys import stdin, stdout, setrecursionlimit

class Tail_Recursion_Optimization:

	def __init__(self, RECURSION_LIMIT, STACK_SIZE):
		setrecursionlimit(RECURSION_LIMIT)
		threading.stack_size(STACK_SIZE)
		return None

class SOLVE:

	def solve(self):
		R = stdin.readline
		W = stdout.write
		ans = []
		for i in range(int(R())):
			(n, t) = [int(x) for x in R().split()]
			a = [int(x) for x in R().split()]
			color = [None for j in range(n)]
			for j in range(n):
				if a[j] < t // 2:
					color[j] = '0'
				elif a[j] > t // 2:
					color[j] = '1'
			flg = 0
			odd = t % 2
			for j in range(n):
				if a[j] == t // 2:
					if odd:
						color[j] = '0'
					else:
						color[j] = str(flg)
						flg ^= 1
			ans.append(' '.join(color))
		W('\n'.join(ans))
		return 0

def main():
	s = SOLVE()
	s.solve()
main()


rn = lambda : int(input())
rl = lambda : list(map(int, input().split()))
rns = lambda : map(int, input().split())
rs = lambda : input()
yn = lambda x: print('Yes') if x else print('No')
for _ in range(rn()):
	(n, t) = rns()
	l = rl()
	for i in range(n):
		l[i] = [l[i], i]
	l.sort()
	ans = n * [0]
	ans[l[0][1]] = 1
	i = 1
	while i < n and l[i - 1][0] < t - l[i][0] and (l[i][0] != t / 2):
		ans[l[i][1]] = 1
		i += 1
	c = 0
	j = float('inf')
	for i in range(n):
		if l[i][0] == t / 2:
			j = min(j, i)
			c += 1
	if c != 0:
		for k in range(int(j), int(j) + c // 2):
			ans[l[k][1]] = 1
	print(' '.join(list(map(str, ans))))


from functools import reduce
import os
import sys
from collections import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
inf = 1e+18
div = 998244353
for _ in range(inn()):
	(n, t) = value()
	a = arr()
	d = defaultdict(int)
	sm = 0
	for i in range(n):
		if a[i] not in d and t - a[i] not in d:
			d[a[i]] = 0
			d[t - a[i]] = 1
	ans = []
	c = 0
	for i in range(n):
		if t % 2 == 0 and a[i] == t // 2:
			ans += [c]
			c ^= 1
		elif a[i] in d:
			ans += [d[a[i]]]
		else:
			ans += [1]
	print(*ans)


n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	v = list(map(int, input().split()))
	if y % 2 != 0:
		t = (y - 1) / 2
		for j in range(x):
			if v[j] <= t:
				print('0', end=' ')
			else:
				print('1', end=' ')
		print('\n')
	else:
		y /= 2
		r = v.count(y)
		w = r / 2
		w = int(w)
		r = r - w
		s = max(r, w)
		t = min(r, w)
		q = 0
		for j in range(x):
			if v[j] < y:
				print('0', end=' ')
			elif v[j] > y:
				print('1', end=' ')
			elif q == s:
				print('0', end=' ')
			else:
				print('1', end=' ')
				q += 1
		print('\n')


t = int(input())
for _ in range(t):
	s = input().split()
	n = int(s[0])
	t = int(s[1])
	a = [int(i) for i in input().split()]
	m = t / 2
	check = True
	for i in range(n):
		if a[i] < m:
			print(0, end=' ')
		elif a[i] > m:
			print(1, end=' ')
		elif a[i] == m and check:
			print(0, end=' ')
			check = False
		else:
			print(1, end=' ')
			check = True
	print(end='')


import sys
import math as m

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l
mod = int(1000000000.0) + 7

def sinp():
	return sys.stdin.readline().strip()

def iinp():
	return int(input())

def ninp():
	return map(int, sys.stdin.readline().strip().split())

def linp():
	return list(map(int, sys.stdin.readline().strip().split()))

def p(a):
	print(a)

def p2(a, b):
	print(a, b)
for _ in range(iinp()):
	(n, t) = ninp()
	a = linp()
	x = 0
	l = []
	f = 0
	for i in a:
		if t - i == i:
			x += 1
	if x % 2 == 0:
		y = x // 2
		z = x // 2
	else:
		y = x // 2
		z = x // 2 + 1
	for i in a:
		if t - i > i:
			l.append(0)
		elif t - i < i:
			l.append(1)
		elif t - i == i and f == 0:
			if y > 0:
				l.append(0)
				y = y - 1
			else:
				l.append(1)
	print(*l)


import math

def function(n, t, nums):
	res = []
	def1 = 1
	for i in range(n):
		if nums[i] < t / 2:
			res.append(1)
		if nums[i] > t / 2:
			res.append(0)
		if nums[i] == t / 2:
			if def1 % 2 != 0:
				res.append(1)
			if def1 % 2 == 0:
				res.append(0)
			def1 += 1
	print(*res)
t = int(input())
for k1 in range(t):
	(n, t) = map(int, input().rstrip().split())
	nums = list(map(int, input().rstrip().split()))
	function(n, t, nums)


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	c = 0
	for i in a:
		if i == t // 2 and t % 2 == 0:
			c += 1
	k = c // 2
	cn = 1
	for i in a:
		if c > 0 and i == t // 2:
			if cn <= k:
				print(0, end=' ')
				cn += 1
			else:
				print(1, end=' ')
		elif i <= t // 2:
			print(0, end=' ')
		else:
			print(1, end=' ')
	print('')


for _ in range(int(input())):
	(n, t) = map(int, input().split(' '))
	arr = [int(num) for num in input().split(' ')]
	ans = []
	prev = 0
	for i in range(n):
		if arr[i] < t / 2:
			ans.append(1)
		elif arr[i] > t / 2:
			ans.append(0)
		elif prev == 1:
			ans.append(0)
			prev = 0
		else:
			ans.append(1)
			prev = 1
	for item in ans:
		print(item, end=' ')
	print('')


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	x = list(map(int, input().split()))
	d = {}
	for i in range(n):
		if d.get(x[i], None) != None:
			d[x[i]] += [i]
		else:
			d[x[i]] = [i]
	ans = [-1] * n
	for i in d:
		if t - i == i:
			for k in range(len(d[i]) // 2):
				ans[d[i][k]] = 0
			for k in range(len(d[i]) // 2, len(d[i])):
				ans[d[i][k]] = 1
		elif t - i in d:
			for idx in d[i]:
				ans[idx] = 0
			for idx in d[t - i]:
				ans[idx] = 1
		else:
			for idx in d[i]:
				ans[idx] = 0
	print(*ans)


def sol(a, T):
	re = [0] * len(a)
	c = 0
	if T % 2 == 0:
		for x in a:
			if x == T // 2:
				c += 1
	sc = 0
	for i in range(len(a)):
		if a[i] == T // 2 and T % 2 == 0:
			sc += 1
			if sc > c // 2:
				re[i] = 1
		elif a[i] > T // 2:
			re[i] = 1
	return re
tc = int(input())
for _ in range(tc):
	IN = input().split(' ')
	n = int(IN[0])
	T = int(IN[1])
	a = list(map(lambda x: int(x), input().split(' ')))
	re = sol(a, T)
	print(*re, sep=' ')


import sys
t = int(sys.stdin.readline().strip())
for idx_t in range(t):
	(n, target) = sys.stdin.readline().strip().split(' ')
	target = int(target)
	a_vec = sys.stdin.readline().strip().split(' ')
	cp_dict = dict()
	res_str = ''
	for a_val in a_vec:
		a_val = int(a_val)
		if a_val not in cp_dict:
			cp_dict[target - a_val] = a_val
			res_str = res_str + str('0') + ' '
		else:
			res_str = res_str + str('1') + ' '
			if a_val == cp_dict[a_val]:
				del cp_dict[a_val]
	print(res_str.strip(' '))


import bisect
import collections
import copy
import functools
import heapq
import itertools
import math
import random
import re
import sys
import time
import string
from typing import List
sys.setrecursionlimit(99999)
t = int(input())
for _ in range(t):
	(n, T) = map(int, input().split())
	arr = list(map(int, input().split()))
	s = set()
	c0 = 0
	ans = [0] * n
	for (i, c) in enumerate(arr):
		if c + c == T:
			ans[i] = c0
			c0 = 1 - c0
		elif c in s:
			ans[i] = 1
		else:
			s.add(T - c)
	print(*ans)


import math

def f(el):
	return el[0]

def binS(arrIn, el):
	l = 0
	arrIn = [[-math.inf]] + arrIn + [[math.inf]]
	r = len(arrIn) - 1
	while r - l != 1:
		mid = (l + r) // 2
		if arrIn[mid][0] > el:
			r = mid
		elif arrIn[mid][0] <= el:
			l = mid
	return l
import math

def binSL(arrIn, el):
	l = 0
	arrIn = [[-math.inf]] + arrIn + [[math.inf]]
	r = len(arrIn) - 1
	while r - l != 1:
		mid = (l + r) // 2
		if arrIn[mid][0] >= el:
			r = mid
		elif arrIn[mid][0] < el:
			l = mid
	return r
for _ in range(int(input())):
	(n, t) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	for i in range(n):
		arr[i] = [arr[i], i]
	arr.sort(key=f)
	out = [0] * n
	leftInd = binS(arr, t / 2) - 1
	rightInd = binSL(arr, t / 2) - 1
	for i in range(n):
		if i <= (leftInd + rightInd) / 2:
			out[arr[i][1]] = 1
	print(*out)


from collections import defaultdict
t = int(input())
for _ in range(t):
	(n, T) = map(int, input().split())
	a = [int(i) for i in input().split()]
	ans = [0] * n
	seen = set()
	idxes = defaultdict(list)
	for (i, num) in enumerate(a):
		idxes[num].append(i)
	for (i, num) in enumerate(a):
		if num in seen:
			continue
		sub = T - num
		if num == sub:
			ids = idxes[num]
			for j in range(1, len(ids), 2):
				if ans[ids[j]] == 1:
					break
				ans[ids[j]] = 1
		elif sub in idxes:
			ids = idxes[sub]
			for j in range(len(ids)):
				if ans[ids[j]] == 1:
					break
				ans[ids[j]] = 1
		seen.add(num)
		seen.add(sub)
	print(*ans)


for tt in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	ans = []
	x = []
	t = 0
	z = []
	for i in range(n):
		if l[i] < k / 2:
			ans.append('0')
		elif l[i] > k / 2:
			ans.append('1')
		elif l[i] == k / 2:
			if t == 0:
				ans.append('0')
				t = 1
			else:
				ans.append('1')
				t = 0
	print(*ans)


import sys
for test in range(int(input())):
	(n, T) = map(int, sys.stdin.readline().split())
	arr = [int(x) for x in sys.stdin.readline().split()]
	count = 0
	for x in range(n):
		if arr[x] < T / 2:
			arr[x] = 1
		elif arr[x] == T / 2:
			if count % 2 == 0:
				arr[x] = 1
				count += 1
			else:
				arr[x] = 0
				count += 1
		else:
			arr[x] = 0
	print(*arr)


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from itertools import accumulate

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	for _ in range(Int()):
		(n, t) = Mint()
		a = List()
		ans = []
		f = 0
		for i in range(n):
			if 2 * a[i] < t:
				ans.append(1)
			elif 2 * a[i] == t:
				if f == 0:
					ans.append(0)
					f = 1
				else:
					ans.append(1)
					f = 0
			else:
				ans.append(0)
		print(*ans)
solution()


for _ in range(int(input())):
	(n, T) = input().split()
	n = int(n)
	T = int(T)
	a = [(int(x), i) for (i, x) in enumerate(input().split())]
	a = sorted(a)
	hi = n - 1
	lo = 0
	col = [None] * n
	col[0] = 0
	lc = dict()
	while hi >= lo:
		if a[hi][0] + a[lo][0] > T:
			if col[a[hi][1]]:
				col[a[lo][1]] = col[a[hi][1]]
			elif col[a[lo][1]]:
				col[a[hi][1]] = col[a[lo][1]]
			else:
				col[a[hi][1]] = col[a[lo][1]] = 0
			hi -= 1
		elif a[hi][0] + a[lo][0] < T:
			if col[a[hi][1]]:
				col[a[lo][1]] = col[a[hi][1]]
			elif col[a[lo][1]]:
				col[a[hi][1]] = col[a[lo][1]]
			else:
				col[a[hi][1]] = col[a[lo][1]] = 0
			lo += 1
		else:
			if col[a[hi][1]]:
				col[a[lo][1]] = 1 - col[a[hi][1]]
			elif col[a[lo][1]]:
				col[a[hi][1]] = 1 - col[a[lo][1]]
			else:
				col[a[hi][1]] = 0
				col[a[lo][1]] = 1
			if a[hi][0] == a[hi - 1][0] and a[lo][0] == a[lo + 1][0]:
				hi -= 1
				lo += 1
			elif a[hi][0] == a[hi - 1][0]:
				hi -= 1
			elif a[lo][0] == a[lo + 1][0]:
				lo += 1
			else:
				hi -= 1
				lo += 1
	print(' '.join([str(x) for x in col]))


t = int(input())
for testix in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	if k % 2:
		for m in l:
			if m > k // 2:
				print(1, end=' ')
			else:
				print(0, end=' ')
	else:
		out = 0
		for m in l:
			if m > k // 2:
				print(1, end=' ')
			elif m < k // 2:
				print(0, end=' ')
			else:
				print(out, end=' ')
				out = (out + 1) % 2
	print()


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	lst = []
	for i in range(n):
		temp = [default] * m
		lst.append(temp)
	return lst

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

def solve(n, k, lst):
	count = lst.count(k / 2)
	lst1 = []
	if count > 1:
		for i in lst:
			if i != k / 2:
				lst1.append(i)
	else:
		for i in lst:
			lst1.append(i)
	lst1 = sorted(lst1)
	ind = 0
	for i in range(len(lst1) - 1):
		if lst1[i] + lst1[i + 1] >= k:
			ind = lst1[i]
			break
	if count > 1:
		ind = k / 2
	cnt = count // 2
	a = 1
	for i in lst:
		if i < ind or (i == ind and count <= 1):
			print(0, end=' ')
		elif i == k / 2 and count > 1:
			if a <= cnt:
				print(0, end=' ')
			else:
				print(1, end=' ')
			a += 1
		else:
			print(1, end=' ')
	print()
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	lst = list(map(int, input().split()))
	solve(n, k, lst)


from bisect import bisect_left, bisect_right
import os
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import deque, defaultdict
import math
import heapq
import re

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
LOW = 'abcdefghijklmnopqrstuvwxyz'
UP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def main():
	for _ in range(iin()):
		(n, t) = ain()
		a = ain()
		l = [-1] * n
		c = 0
		for i in range(n):
			if a[i] < t / 2:
				l[i] = 0
			elif a[i] > t / 2:
				l[i] = 1
			else:
				c += 1
		x = c // 2
		y = c - x
		for i in range(n):
			if a[i] == t / 2:
				if x > 0:
					l[i] = 0
					x -= 1
				else:
					l[i] = 1
					y -= 1
		print(*l)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
import os
from math import sqrt, log, log2, log10, gcd, floor, pow, sin, cos, tan, pi, inf, factorial
from copy import copy, deepcopy
import bisect
from sys import exit, stdin, stdout
from collections import Counter, defaultdict, deque
from itertools import permutations
import heapq
mod = 1000000007
iinp = lambda : int(sys.stdin.readline())
inp = lambda : sys.stdin.readline().strip()
strl = lambda : list(inp().strip().split(' '))
intl = lambda : list(map(int, inp().split(' ')))
mint = lambda : map(int, inp().split())
flol = lambda : list(map(float, inp().split(' ')))
flush = lambda : stdout.flush()

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	p = int(sqrt(n))
	for i in range(5, p + 1, 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def solve():
	(n, t) = mint()
	arr = intl()
	a = {}
	b = {}
	ans = []
	for i in arr:
		if t - i in a.keys() and t - i not in b.keys():
			ans.append(1)
			b[i] = 1
		elif t - i in a.keys() and t - i in b.keys():
			if a[t - i] < b[t - i]:
				ans.append(0)
				a[i] += 1
			else:
				ans.append(1)
				b[i] += 1
		else:
			ans.append(0)
			a[i] = 1
	print(*ans)
for _ in range(iinp()):
	solve()


mod = 10 ** 9 + 7
for _ in range(int(input())):
	(n, T) = map(int, input().split())
	arr = list(map(int, input().split()))
	mp = dict()
	for i in range(n):
		mp[arr[i]] = mp.get(arr[i], 0) + 1
	for i in mp:
		if mp[i] <= 0:
			continue
		if T - i == i:
			mp[i] = -2
		else:
			mp[i] = 0
			if T - i in mp:
				mp[T - i] = -1
	for i in range(n):
		if mp[arr[i]] == 0:
			arr[i] = 0
		elif mp[arr[i]] == -1:
			arr[i] = 1
		elif mp[arr[i]] == -2:
			mp[arr[i]] = -3
			arr[i] = 0
		else:
			mp[arr[i]] = -2
			arr[i] = 1
	print(*arr)


import sys
import math
input = sys.stdin.readline
cases = int(input())
for case in range(cases):
	(n, target) = map(int, input().split())
	a = [int(x) for x in input().split()]
	ans = [None] * n
	c = set()
	d = set()
	left = set()
	for i in range(len(a)):
		k = target - a[i]
		if k in left:
			if k in c:
				d.add(a[i])
				continue
		left.add(a[i])
		c.add(a[i])
	flag = True
	for i in range(n):
		if a[i] in c and a[i] in d:
			if flag:
				ans[i] = 1
				flag = False
			else:
				ans[i] = 0
				flag = True
		elif a[i] in c:
			ans[i] = 0
		else:
			ans[i] = 1
	print(*ans)


from math import *
import threading
import sys

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = -1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def graph(n, m):
	adj = dict()
	for i in range(1, n + 1):
		adj.setdefault(i, 0)
	for i in range(m):
		(a, b) = map(int, input().split())
		adj[a] += 1
		adj[b] += 1
	return adj

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	li = []
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, len(prime)):
		if prime[p]:
			li.append(p)
	return li
INF = 1000000000.0
primes = SieveOfEratosthenes(1300000)
for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	half = t / 2
	ans = [0] * n
	for i in range(n):
		if a[i] < half:
			ans[i] = 1
		elif a[i] > half:
			ans[i] = 0
	x = a.count(half)
	x //= 2
	for i in range(n):
		if a[i] == half:
			if x:
				ans[i] = 1
				x -= 1
	print(*ans)


import sys
input = sys.stdin.readline
t = int(input())
for x in range(t):
	(n, T) = map(int, input().split(' '))
	A = list(map(int, input().split(' ')))
	counts = {}
	for (index, a) in enumerate(A):
		if a not in counts:
			counts[a] = [index]
		else:
			counts[a].append(index)
	colors = [None for i in range(n)]

	def set_color(number, color, start=None, finish=None):
		indices = counts.get(number, [])
		if start is not None:
			indices = indices[start:]
		elif finish is not None:
			indices = indices[:finish]
		for index in indices:
			colors[index] = color
	processed = set()
	for i in counts:
		if i in processed:
			continue
		rest = T - i
		if i != rest:
			set_color(i, 0)
			set_color(rest, 1)
		else:
			cnt = len(counts.get(i, []))
			set_color(i, 0, finish=cnt // 2)
			set_color(i, 1, start=cnt // 2)
		processed.add(i)
		processed.add(rest)
	print(' '.join(map(str, colors)))


R = lambda : map(int, input().split())
(t,) = R()
f = 0
exec(t * 'n,T=R()\nfor x in R():print(+(2*x+f>T));f^=2*x==T\n')


def solve(n, t, ar):
	color = [0] * n
	flag = True
	for i in range(n):
		if t % 2 == 0 and ar[i] == t // 2:
			if flag:
				color[i] = 0
				flag = False
			else:
				color[i] = 1
				flag = True
		elif ar[i] * 2 < t:
			color[i] = 0
		else:
			color[i] = 1
	print(' '.join(map(str, color)))
t = int(input())
for _ in range(t):
	(n, t) = map(int, input().split())
	ar = list(map(int, input().split()))
	solve(n, t, ar)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	num1 = []
	f = 0
	for i in l:
		if i == k // 2:
			if k % 2 == 0:
				if f == 0:
					f = 1
					num1.append(1)
				else:
					num1.append(0)
					f = 0
			else:
				num1.append(0)
		elif i > k // 2:
			num1.append(1)
		else:
			num1.append(0)
	print(*num1)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	g = 0
	for i in l:
		if i < k / 2:
			print(0, end=' ')
		elif i > k / 2:
			print(1, end=' ')
		else:
			print(g, end=' ')
			g ^= 1
	print()


from sys import stdin, stdout
from collections import deque
import bisect
R = lambda : stdin.readline().strip()
RL = lambda f=None: list(map(f, R().split(' '))) if f else list(R().split(' '))
output = lambda x: stdout.write(str(x) + '\n')
output_list = lambda x: output(' '.join(map(str, x)))
T = int(input())
for _ in range(T):
	(n, k) = RL(int)
	l = RL(int)
	ans = [0] * n
	if k % 2:
		for i in range(n):
			if l[i] <= k // 2:
				ans[i] = 0
			else:
				ans[i] = 1
	else:
		f = 0
		for i in range(n):
			if l[i] < k // 2:
				ans[i] = 0
			elif l[i] > k // 2:
				ans[i] = 1
			else:
				ans[i] = f
				f = 1 - f
	print(*ans)


t = int(input())
for i in range(t):
	(n, T) = list(map(int, input().split()))
	lst = list(map(int, input().split()))
	blst = [0] * n
	set1 = set(lst)
	setb = set()
	setw = set()
	median = -1
	if T % 2 == 0:
		median = T / 2
		if median in set1:
			set1.discard(median)
			c = lst.count(median)
	for i in range(n):
		if T - lst[i] in set1 and lst[i] not in setw:
			setb.add(lst[i])
			setw.add(T - lst[i])
	v = 1
	for i in range(n):
		if lst[i] in setw:
			blst[i] = 1
		if lst[i] == median and v <= c / 2:
			blst[i] = 1
			v = v + 1
	for i in blst:
		print(i, end=' ')
	print('\n')


import math
_ = int(input())
for t in range(_):
	(n, p) = map(int, input().split())
	a = list(map(int, input().split()))
	c = [-1] * n
	flag = 0
	for i in range(len(a)):
		if p % 2 == 0:
			if a[i] < math.ceil(p / 2):
				c[i] = 0
			elif a[i] == p // 2:
				if flag == 0:
					c[i] = 0
					flag = 1
				else:
					c[i] = 1
					flag = 0
			else:
				c[i] = 1
		elif a[i] < math.ceil(p / 2):
			c[i] = 0
		else:
			c[i] = 1
	print(*c)


T = int(input())
for _ in range(T):
	(n, t) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	c = {}
	for x in a:
		if x not in c:
			c[x] = 0
		c[x] += 1
	setb = set()
	nh = 0
	ans = []
	for (i, x) in enumerate(a):
		if x in setb:
			ans.append(1)
			continue
		elif x == t // 2 and t % 2 == 0:
			if nh < c[x] // 2:
				ans.append(0)
				nh += 1
			else:
				ans.append(1)
		elif t - x in c:
			ans.append(0)
			setb.add(t - x)
		else:
			ans.append(0)
	print(' '.join(map(str, ans)))


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil, pi, sin, cos, acos, atan
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = ip()
for _ in range(t):
	(n, k) = inp()
	arr = list(inp())
	val = k // 2
	ans = [None] * n
	xor = 0
	if k % 2 == 0:
		for i in range(n):
			if arr[i] < val:
				ans[i] = 0
			elif arr[i] == val:
				ans[i] = xor
				xor ^= 1
			else:
				ans[i] = 1
	else:
		for i in range(n):
			if arr[i] <= val:
				ans[i] = 0
			else:
				ans[i] = 1
	print(*ans)


from sys import stdin, stdout
input = stdin.buffer.readline
for _ in range(int(input())):
	(n, t) = map(int, input().split())
	(*a,) = map(int, input().split())
	b = [-1] * n
	c = 0
	for i in range(n):
		if a[i] * 2 < t:
			b[i] = 0
		elif a[i] * 2 > t:
			b[i] = 1
		else:
			c += 1
	for i in range(n):
		if b[i] == -1:
			if c > 0:
				c -= 2
				b[i] = 0
			else:
				b[i] = 1
	print(*b)


R = lambda : map(int, input().split())
(t,) = R()
for _ in [0] * t:
	(n, T) = R()
	d = {}
	r = [0] * n
	i = 0
	for x in R():
		l = d.setdefault(x, [])
		l += (i,)
		i += 1
	for x in d:
		d[x][len(d[x]) // 2:] = []
		for i in d.get(T - x, []):
			r[i] = 1
		d[x] = []
	print(*r)


R = lambda : map(int, input().split())
(t,) = R()
for _ in [0] * t:
	(n, T) = R()
	d = {}
	i = 0
	for x in R():
		l = d.setdefault(x, [])
		l += (i,)
		i += 1
	a = sorted(d)
	i = 0
	j = len(a) - 1
	r = [0] * n
	while i <= j:
		l = d[a[j]]
		s = a[i] + a[j]
		for k in l[:len(l) * (s == T) >> (i == j)]:
			r[k] = 1
		i += s <= T
		j -= s >= T
	print(*r)


from collections import Counter, defaultdict
from sys import stdin, stdout
input = stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
for _ in range(I()):
	(n, k) = M()
	a = LI()
	b = defaultdict(int)
	c = defaultdict(int)
	d = []
	for i in range(n):
		ch = a[i]
		if ch <= k:
			p = k - ch
			if b[p] > c[p]:
				d += [1]
				c[ch] += 1
			else:
				d += [0]
				b[ch] += 1
		else:
			d += [0]
	print(*d)


from collections import defaultdict
t = int(input())
for _ in range(t):
	(n, T) = [int(x) for x in input().split()]
	l = [int(x) for x in input().split()]
	left = []
	right = []
	dic = defaultdict(list)
	for i in range(n):
		dic[l[i]].append(i)
	ans = 0
	ans = [0] * n
	for i in range(n):
		if dic[T - l[i]] == []:
			continue
		if 2 * l[i] == T:
			for j in range(len(dic[T - l[i]]) // 2):
				ans[dic[T - l[i]][j]] = 1
			dic[T - l[i]] = []
			dic[l[i]] = []
			continue
		for j in dic[T - l[i]]:
			ans[j] = 1
		dic[T - l[i]] = []
		dic[l[i]] = []
	print(*ans)


import math, sys
from collections import defaultdict, Counter, deque
from functools import reduce
INF = float('inf')
MOD = int(1000000000.0) + 7

def solve():
	(n, k) = vars()
	arr = array()
	t = 1
	ans = [0 for i in range(n)]
	for i in range(n):
		if arr[i] > k / 2:
			ans[i] = 1
		elif arr[i] == k / 2:
			ans[i] = t
			t = int(not t)
	print(*ans)

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def input():
	return sys.stdin.readline().rstrip('\n').strip()

def print(*args, sep=' ', end='\n'):
	first = True
	for arg in args:
		if not first:
			sys.stdout.write(str(sep))
		sys.stdout.write(str(arg))
		first = False
	sys.stdout.write(end)

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))
main()


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 998244353
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')

def solve():
	for _ in range(ii()):
		(n, T) = mi()
		a = li()
		m1 = set()
		m2 = set()
		ans = [0] * n
		(c1, c2) = (0, 0)
		for i in range(n):
			if a[i] > T:
				m1.add(a[i])
				ans[i] = 1
				continue
			x1 = T - a[i]
			if x1 not in m1:
				m1.add(a[i])
				ans[i] = 1
				continue
			if x1 in m2:
				if c1 < c2:
					m1.add(a[i])
					ans[i] = 1
					c1 += 1
				else:
					m2.add(a[i])
					c2 += 1
				continue
			m2.add(a[i])
		print(*ans)
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
solve()


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	(n, T) = map(int, stdin.readline().strip().split())
	a = list(map(int, stdin.readline().strip().split()))
	(X, Z, Y) = ([], [], [])
	results = [-1] * n
	even = 0
	for i in range(n):
		if a[i] < T / 2:
			results[i] = 0
		elif a[i] > T / 2:
			results[i] = 1
		else:
			if even:
				results[i] = 0
			else:
				results[i] = 1
			even = (even + 1) % 2
	print(' '.join(map(str, results)))


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	p = [0 for i in range(n)]
	i = 0
	j = n - 1
	k = t // 2
	o = []
	for i in range(n):
		if a[i] > k:
			p[i] = 1
		if a[i] == k and t % 2 == 0:
			o.append(i)
	if t % 2 == 0:
		for i in range(len(o) // 2):
			p[o[i]] = 1
	for i in range(n):
		print(p[i], end=' ')
	print(' ')


from collections import defaultdict
t = int(input())
for z in range(t):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = [-1] * n
	dict_A = defaultdict(lambda : False)
	count_A = defaultdict(int)
	count_B = defaultdict(int)
	dict_B = defaultdict(lambda : False)
	for i in range(n):
		if a[i] > t:
			ans[i] = 0
		elif not dict_A[t - a[i]]:
			dict_A[a[i]] = True
			count_A[a[i]] += 1
			ans[i] = 0
		elif dict_A[t - a[i]] and 2 * a[i] != t:
			dict_B[a[i]] = True
			count_B[a[i]] += 1
			ans[i] = 1
		elif dict_A[t - a[i]] and 2 * a[i] == t:
			if count_A[a[i]] <= count_B[a[i]]:
				count_A[a[i]] += 1
				ans[i] = 0
			else:
				count_B[a[i]] += 1
				ans[i] = 1
	print(*ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	ans = 0
	c = 1
	for i in range(n):
		if 2 * arr[i] == k:
			c = c + 1
			ans = c % 2
		elif 2 * arr[i] < k:
			ans = 0
		else:
			ans = 1
		print(str(ans), end=' ')
	print('\n')


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	arr = list(map(int, input().split()))
	s = set()
	res = []
	if t % 2 != 0:
		for x in arr:
			if t - x in s:
				res.append(1)
			else:
				res.append(0)
				s.add(x)
		rrr = [print(x, end=' ') for x in res]
	else:
		cnt = arr.count(t // 2)
		onecnt = cnt // 2
		for x in arr:
			if x == t // 2 and onecnt > 0:
				res.append(1)
				onecnt -= 1
				continue
			elif x == t // 2 and onecnt == 0:
				res.append(0)
				continue
			if t - x in s:
				res.append(1)
			else:
				res.append(0)
				s.add(x)
		rrr = [print(x, end=' ') for x in res]


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	ii = 0
	for g in arr:
		if g == k / 2:
			if ii == 0:
				print(1, end=' ')
				ii = 1
			else:
				print(0, end=' ')
				ii = 0
		elif g > k / 2:
			print(1, end=' ')
		else:
			print(0, end=' ')
	print()


from sys import stdin
input = stdin.readline

def solve():
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	res = [0] * n
	c = 0
	s = {T // 2}
	for (i, v) in enumerate(a):
		if T - v in s:
			res[i] = 1
		else:
			s.add(v)
	if T & 1 == 0:
		index = [i for i in range(n) if a[i] == T // 2]
		for i in range(len(index) // 2):
			res[index[i]] = 0
	print(' '.join(map(str, res)))
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for i in range(t):
	(n, T) = map(int, input().split())
	b = list(map(int, input().split()))
	a = dict()
	colors = [0] * len(b)
	black = dict()
	white = dict()
	id = -1
	for i in b:
		id += 1
		if i not in a:
			a[i] = list()
		a[i].append(id)
	id = -1
	for i in b:
		id += 1
		t = T - i
		if t not in white:
			white[i] = 0
			white[t] = 0
		if t not in black:
			black[i] = 0
			black[t] = 0
		if white[t] < black[t]:
			white[i] += 1
		else:
			black[i] += 1
			colors[id] = 1
	print(*colors)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	sb_a = set()
	res = [0] * n
	sb_flag = 0
	for (i, a) in enumerate(A):
		if a == k / 2:
			if sb_flag == 0:
				sb_a.add(a)
			res[i] = sb_flag
			sb_flag = 1 - sb_flag
			continue
		if k - a in sb_a:
			res[i] = 1
		else:
			sb_a.add(a)
	print(*res)


t = int(input(''))
for _ in range(t):
	[n, k] = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	v = []
	dic = {}
	d1 = []
	d2 = []
	bal = {}
	for i in range(n):
		try:
			dic[arr[i]] += 1
		except:
			dic[arr[i]] = 1
		v.append([arr[i], i])
	v.sort()
	for i in range(n):
		a = v[i][0]
		b = v[i][1]
		df = abs(k - a)
		try:
			x = bal[a]
		except:
			x = 0
		try:
			y = bal[df]
		except:
			y = 0
		if y == 0 or y == 2:
			d1.append([a, b])
			bal[a] = 1
		elif y == 1:
			d2.append([a, b])
			bal[a] = 2
	for i in range(len(d1)):
		c = d1[i][1]
		arr[c] = 1
	for i in range(len(d2)):
		c = d2[i][1]
		arr[c] = 0
	print(*arr)


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = [int(x) for x in input().split()]
	cnt = 0
	ans = [0 for i in range(n)]
	for i in range(n):
		if a[i] * 2 < t:
			ans[i] = 0
		elif a[i] * 2 > t:
			ans[i] = 1
		else:
			cnt += 1
	need = cnt // 2
	for i in range(n):
		if a[i] * 2 == t and need > 0:
			need -= 1
			ans[i] = 1
	print(*ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	dict = {}
	for i in range(n):
		if arr[i] in dict:
			dict[arr[i]].append(i)
		else:
			dict[arr[i]] = [i]
	out = [-1 for x in range(n)]
	for i in range(n):
		if out[i] == -1:
			if k - arr[i] in dict and k - arr[i] == arr[i]:
				l = dict[arr[i]]
				for j in range(len(l) // 2):
					out[l[j]] = 0
				for j in range(len(l) // 2, len(l)):
					out[l[j]] = 1
				continue
			out[i] = 0
			if k - arr[i] in dict:
				for j in dict[k - arr[i]]:
					out[j] = 1
	print(*out)


from fractions import Fraction
import bisect
import os
import io
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
from queue import Queue

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
t = 1
t = iinput()
for _ in range(t):
	(n, t) = rinput()
	a = rlinput()
	d = defaultdict(int)
	for i in a:
		want = t - i
		if want in d:
			d[want] = 1
		elif i not in d:
			d[i] = 0
	ans = [0] * n
	for i in range(n):
		ans[i] = d[a[i]]
	if t % 2:
		print(*ans)
	else:
		count = a.count(t // 2)
		temp = 0
		for i in range(n):
			if a[i] == t // 2:
				if temp == count // 2:
					break
				ans[i] = 0
				temp += 1
		print(*ans)


from collections import defaultdict

def binary_search(x):
	low = 0
	high = len(arr) - 1
	mid = 0
	while low <= high:
		mid = (high + low) // 2
		if arr[mid] < x:
			low = mid + 1
		elif arr[mid] > x:
			high = mid - 1
		else:
			return mid
	return -1
l = []
for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	d = {}
	for i in range(n):
		d[a[i]] = -1
	arr = a.copy()
	arr.sort()
	c = ['0'] * n
	count = 0
	for i in range(n):
		if t - a[i] != a[i]:
			try:
				if d[a[i]] == -1:
					s = binary_search(t - a[i])
					if s != -1:
						d[a[i]] = '0'
						d[t - a[i]] = '1'
					else:
						d[a[i]] = '0'
			except:
				None
		else:
			count = count + 1
	if t % 2 == 0:
		count = count // 2
		for i in range(n):
			if t - a[i] == a[i] and count > 0:
				c[i] = '1'
				count = count - 1
			elif t - a[i] == a[i]:
				c[i] = '0'
			else:
				c[i] = d[a[i]]
	else:
		for i in range(n):
			c[i] = d[a[i]]
	l.append(' '.join(c))
for i in l:
	print(i)


import sys
input = sys.stdin.readline

def prog():
	for _ in range(int(input())):
		(n, t) = map(int, input().split())
		a = list(map(int, input().split()))
		output = [0] * n
		bad = 0
		bound = t // 2
		even = t % 2 == 0
		if even:
			for i in a:
				if i == t // 2:
					bad += 1
		placed = 0
		for i in range(n):
			if a[i] <= bound:
				if a[i] == bound:
					if even:
						if a[i] == bound and placed < bad // 2:
							placed += 1
							output[i] = 1
					else:
						output[i] = 1
				else:
					output[i] = 1
		print(*output)
prog()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = [int(x) for x in input().split()]
	c = -1
	t = -1
	if k % 2 == 0:
		c = l.count(k // 2)
		t = k // 2
	for i in l:
		if i == t:
			if c % 2 == 0:
				print(0, end=' ')
			else:
				print(1, end=' ')
			c -= 1
		elif i <= k // 2:
			print(0, end=' ')
		else:
			print(1, end=' ')
	print()


import math
from collections import *
import sys
from functools import reduce
import time
from itertools import groupby

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
DIRECTIONS = [(+0, +1), (+0, -1), (+1, +0), (+1, -1)]
NEIGHBOURS = [(-1, -1), (-1, +0), (-1, +1), (+0, -1), (+1, +1), (+1, +0), (+1, -1), (+0, +1)]
for _test_ in range(int(input())):
	(n, k) = get_ints()
	arr = get_list()
	d = defaultdict(list)
	ans = [0 for x in range(n)]
	for i in range(n):
		d[arr[i]].append(i)
	for (ke, va) in sorted(d.items()):
		if ke >= (k + 1) // 2:
			break
		if k - ke in d:
			sz1 = len(va)
			sz2 = len(d[k - ke])
			if sz1 < sz2:
				for j in range(sz1):
					ans[va[j]] = 1
			else:
				reffe = d[k - ke]
				for j in range(sz2):
					ans[reffe[j]] = 1
	if not k & 1:
		if k // 2 in d:
			sz = len(d[k // 2])
			for j in range(sz // 2):
				ans[d[k // 2][j]] = 1
	print(*ans)


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')

def ceil(x, y=1):
	return int(-(-x // y))
import math
from collections import defaultdict
for _ in range(ri()):
	(n, k) = ria()
	l = ria()
	ans = []
	flag = 0
	for i in l:
		if k & 1 == 0 and i == k // 2:
			if flag & 1:
				ans.append(1)
			else:
				ans.append(0)
			flag += 1
		elif 2 * i < k:
			ans.append(0)
		else:
			ans.append(1)
	wia(ans)


import os
import heapq
import sys, threading
import math
import operator
from collections import defaultdict, deque
from io import BytesIO, IOBase
sys.setrecursionlimit(10 ** 5)

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		(n, T) = inpt()
		ar = inpt()
		(c, d) = (set(), set())
		for i in ar:
			if i not in c and i not in d:
				if i == abs(i - T):
					continue
				c.add(i)
				d.add(abs(i - T))
		x = 0
		for i in range(n):
			if ar[i] in c:
				ar[i] = 1
			elif ar[i] in d:
				ar[i] = 0
			else:
				ar[i] = x
				x ^= 1
		print(*ar)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def main(n, t, a):
	res = []
	m = t / 2
	g = a.count(m)
	cnt = 0
	for el in a:
		if el < m:
			res.append(0)
		elif el == m:
			if cnt < g / 2:
				res.append(0)
			else:
				res.append(1)
			cnt += 1
		else:
			res.append(1)
	return res
for i in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	print(*main(n, t, a))


from collections import defaultdict as dd
t = int(input())
for _ in range(t):
	(n, tt) = map(int, input().split())
	a = list(map(int, input().split()))
	paints = [0 for i in range(n)]
	c = dd(lambda : 0)
	d = dd(lambda : 0)
	fc = fd = 0
	i = 0
	for ele in a:
		if not c[tt - ele]:
			c[ele] = 1
		elif not d[tt - ele]:
			d[ele] = 1
			paints[i] = 1
		elif fc == min(fc, fd):
			fc += 1
			c[ele] = 1
		else:
			d[ele] = 1
			fd += 1
			paints[i] = 1
		i += 1
	print(' '.join([str(x) for x in paints]))


for ttt in range(int(input())):
	(n, t) = map(int, input().split())
	arr = list(map(int, input().split()))
	if t % 2:
		for item in arr:
			if item <= t // 2:
				print(1, end=' ')
			else:
				print(0, end=' ')
	else:
		f = 0
		for i in range(n):
			if arr[i] < t // 2:
				print(1, end=' ')
			elif arr[i] > t // 2:
				print(0, end=' ')
			elif f == 0:
				print(1, end=' ')
				f = 1
			else:
				print(0, end=' ')
				f = 0
	print()


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(*li,) = map(int, input().split())
	set1 = set()
	set2 = set()
	li1 = []
	p = 1
	for i in li:
		if i not in set1 and i not in set2:
			if i == 0:
				set2.add(i)
			elif i >= y:
				set1.add(i)
			elif y - i not in set1:
				set1.add(i)
			else:
				set2.add(i)
	for i in li:
		if i == y / 2:
			li1.append(p)
			p ^= 1
		elif i in set1:
			li1.append(1)
		else:
			li1.append(0)
	print(*li1)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = [0] * n
	cur = 0
	for i in range(n):
		if a[i] > k // 2:
			ans[i] = 1
		elif k % 2 == 0 and a[i] == k // 2:
			ans[i] = cur % 2
			cur += 1
		else:
			ans[i] = 0
	print(*ans)


for _ in range(int(input())):
	(n, T) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	from collections import defaultdict
	b = defaultdict(int)
	c = defaultdict(int)
	v = []
	for i in range(n):
		g = a[i]
		if g == T - g:
			if b[g] > c[g]:
				c[g] += 1
				v += ['0']
			else:
				b[g] += 1
				v += ['1']
		elif T - g not in b:
			b[g] += 1
			v += ['1']
		else:
			c[g] += 1
			v += ['0']
	print(' '.join(v))


import os
from sys import stdin, stdout

class Input:

	def __init__(self):
		self.lines = stdin.readlines()
		self.idx = 0

	def line(self):
		try:
			return self.lines[self.idx].strip()
		finally:
			self.idx += 1

	def array(self, sep=' ', cast=int):
		return list(map(cast, self.line().split(sep=sep)))

	def known_tests(self):
		(num_of_cases,) = self.array()
		for case in range(num_of_cases):
			yield self

	def unknown_tests(self):
		while self.idx < len(self.lines):
			yield self

def problem_solver():

	def solver(inpt):
		(n, T) = inpt.array()
		a = inpt.array()
		b = []
		c = 0
		for x in a:
			if x * 2 > T:
				b.append(1)
			elif x * 2 == T:
				b.append(c & 1)
				c += 1
			else:
				b.append(0)
		print(*b)
	return solver
try:
	solver = problem_solver()
	for tc in Input().known_tests():
		solver(tc)
except Exception as e:
	import traceback
	traceback.print_exc(file=stdout)


import math
from collections import deque
from collections import defaultdict
t = int(input())
while t > 0:
	t -= 1
	(n, T) = map(int, input().strip().split(' '))
	arr = list(map(int, input().strip().split(' ')))
	dp = defaultdict(list)
	ans = [-1] * n
	for i in range(n):
		dp[arr[i]].append(i)
	for ele in dp:
		if ans[dp[ele][0]] != -1:
			continue
		dff = T - ele
		if dp.get(dff) is not None:
			if dff == ele:
				p1 = len(dp[ele]) // 2
				p2 = len(dp[ele]) - p1
				for i in range(p1):
					ans[dp[ele][i]] = 1
				for i in range(p1, p2):
					ans[dp[ele][i]] = 0
			else:
				for i in dp[ele]:
					ans[i] = 1
				for i in dp[dff]:
					ans[i] = 0
		else:
			for i in dp[ele]:
				ans[i] = 0
	for i in ans:
		if i == -1:
			print(0, end=' ')
			continue
		print(i, end=' ')
	print()


import functools
import heapq
import os
import random
import sys
from collections import deque
import io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(TC):
	(N, T) = map(int, input().split())
	A = list(map(int, input().split()))
	R = [-1 for _ in A]
	V = {}
	for (i, a) in enumerate(A):
		V.setdefault(a, []).append(i)
	for (k, v) in V.items():
		if 2 * k == T:
			for i in range(len(v) // 2):
				R[v[i]] = 0
			for i in range(len(v) // 2, len(v)):
				R[v[i]] = 1
		else:
			for vi in v:
				R[vi] = 0
			for vi in V.get(T - k, []):
				R[vi] = 1
	for r in R:
		print(r, end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	d = k / 2
	m = a.count(d)
	c = 0
	b = []
	for i in a:
		if i < d:
			b.append('0')
		elif i > d:
			b.append('1')
		else:
			if m % 2 == 0:
				if c % 2 == 0:
					b.append('0')
				else:
					b.append('1')
			elif c < m // 2:
				b.append('0')
			else:
				b.append('1')
			c += 1
	print(' '.join(b))


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = [None] * n
	cnt = 0
	for i in a:
		if i == t // 2:
			cnt += 1
	if t & 1:
		for i in range(n):
			if a[i] <= t // 2:
				ans[i] = 0
			else:
				ans[i] = 1
	else:
		c1 = cnt // 2
		c2 = cnt - c1
		for i in range(n):
			if a[i] < t // 2:
				ans[i] = 0
			elif a[i] == t // 2 and c1:
				ans[i] = 0
				c1 -= 1
			elif a[i] == t // 2 and c2:
				ans[i] = 1
				c2 -= 1
			else:
				ans[i] = 1
	print(*ans)


for x in range(int(input())):
	(n, t) = list(map(int, input().split()))
	m = list(map(int, input().split()))
	d = {}
	s = set(m)
	a = [-1] * n
	if t // 2 in s and t % 2 == 0:
		l = m.count(t // 2)
		z = l // 2
		if l >= 2:
			d[t // 2] = 0
			for i in range(n):
				if m[i] == t // 2 and z > 0:
					z -= 1
					a[i] = 1
	for i in range(n):
		if m[i] not in d:
			if t - m[i] in s:
				d[t - m[i]] = 0
				d[m[i]] = 1
			else:
				a[i] = 0
	for i in range(n):
		if a[i] == -1:
			a[i] = d[m[i]]
	print(*a)


def checker(n, T, arr):
	(res, j) = ([], 0)
	for i in arr:
		if i < T / 2:
			res.append('0')
		elif i > T / 2:
			res.append('1')
		elif j % 2 == 0:
			res.append('0')
			j += 1
		else:
			res.append('1')
			j += 1
	return res
for _ in range(int(input())):
	(m, t) = [int(i) for i in input().split()]
	lst = [int(i) for i in input().split()]
	print(' '.join(checker(m, t, lst)))


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]
from collections import defaultdict
for _ in range(II()):
	(n, t) = MI()
	aa = LI()
	cnt = [defaultdict(int), defaultdict(int)]
	ans = []
	for a in aa:
		if cnt[0][t - a] > cnt[1][t - a]:
			ans.append(1)
			cnt[1][a] += 1
		else:
			ans.append(0)
			cnt[0][a] += 1
	print(*ans)


t = int(input())
from collections import Counter
for _ in range(t):
	inp = list(map(int, input().split()))
	tot = inp[1]
	inp = list(map(int, input().split()))
	c = Counter(inp)
	d = Counter([])
	for item in c.keys():
		if d[item] != 0:
			continue
		else:
			if 2 * item == tot:
				d[item] = 3
				continue
			d[item] = 1
			d[tot - item] = 2
	k = 0
	for item in inp:
		if d[item] != 3:
			print(d[item] % 2, end=' ')
		else:
			k += 1
			if k <= c[tot // 2] // 2:
				print(0, end=' ')
			else:
				print(1, end=' ')
	print(' ')


import sys

def input():
	return sys.stdin.readline()[:-1]

def getInt():
	return int(input())

def getIntIter():
	return map(int, input().split())

def getIntList():
	return list(getIntIter())

def flush():
	sys.stdout.flush()
for _ in range(getInt()):
	(n, t) = getIntIter()
	nums = input()
	i = -1
	if t % 2 == 1:
		for x in range(n - 1):
			nextI = nums.index(' ', i + 1)
			num = int(nums[i + 1:nextI])
			i = nextI
			if num % 2 == 0:
				print(0, end=' ')
			else:
				print(1, end=' ')
		num = int(nums[i + 1:])
		if num % 2 == 0:
			print(0, end=' ')
		else:
			print(1, end=' ')
		print()
	else:
		flag = False
		for x in range(n - 1):
			nextI = nums.index(' ', i + 1)
			num = int(nums[i + 1:nextI])
			i = nextI
			if num == t // 2:
				print(str(int(flag)), end=' ')
				flag = not flag
			elif num < t // 2:
				print(0, end=' ')
			else:
				print(1, end=' ')
		num = int(nums[i + 1:])
		if num == t // 2:
			print(str(int(flag)), end=' ')
			flag = not flag
		elif num < t // 2:
			print(0, end=' ')
		else:
			print(1, end=' ')
		print()


from collections import defaultdict
for _ in range(int(input())):
	(n, t) = map(int, input().split())
	arr = list(map(int, input().split()))
	res = [0] * n
	rec = defaultdict(int)
	rec1 = defaultdict(int)
	for i in range(n):
		now = t - arr[i]
		(n1, n2) = (rec[now], rec1[now])
		if n1 < n2:
			rec[arr[i]] += 1
		else:
			res[i] = 1
			rec1[arr[i]] += 1
	print(*res)


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	a1 = [0] * n
	(x, y, z) = ([], [], [])
	f = True
	for i in range(n):
		if a[i] > t / 2:
			a1[i] = 1
		elif a[i] == t / 2:
			a1[i] = int(f)
			f = not f
	print(' '.join(map(str, a1)))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		(n, m) = LI()
		a = LI()
		k = m / 2
		ki = 0
		s = set()
		r = []
		for c in a:
			if c == k:
				r.append(ki)
				ki ^= 1
			elif m - c in s:
				r.append(1)
			else:
				r.append(0)
				s.add(c)
		rr.append(JA(r, ' '))
	return JA(rr, '\n')
print(main())


from sys import stdin
tt = int(stdin.readline())
for loop in range(tt):
	(n, T) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	cnt = 0
	p = [None] * n
	for i in range(n):
		if a[i] * 2 < T:
			p[i] = 0
		elif a[i] * 2 > T:
			p[i] = 1
		else:
			p[i] = cnt
			cnt ^= 1
	print(*p)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	a1 = [0] * x
	p = 0
	for i in range(x):
		if a[i] < y / 2:
			a1[i] = 1
		elif a[i] == y / 2:
			p += 1
			if p % 2 == 0:
				a1[i] = 1
			else:
				a1[i] = 0
		else:
			a1[i] = 0
	for i in a1:
		print(i, end=' ')
	print()


from collections import defaultdict
T = int(input())
for t in range(T):
	(n, T) = [int(_) for _ in input().split()]
	A = [int(_) for _ in input().split()]
	pen_in_c = defaultdict(int)
	pen_in_d = defaultdict(int)
	answer = []
	for el in A:
		if pen_in_d[el] < pen_in_c[el]:
			answer.append(1)
			pen_in_d[T - el] += 1
		else:
			answer.append(0)
			pen_in_c[T - el] += 1
	print(' '.join(map(str, answer)))


import sys

def input():
	return sys.stdin.readline().rstrip()
t = int(input())
for i in range(t):
	[n, T] = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	val_with_index = []
	for i in range(0, n):
		val_with_index.append((arr[i], i))
	val_with_index.sort()
	ans = [-1] * n
	prv_pos = []
	for i in range(0, n):
		if i + 1 < n and val_with_index[i][0] == val_with_index[i + 1][0]:
			prv_pos.append(val_with_index[i][1])
		else:
			val = val_with_index[i][0]
			prv_pos.append(val_with_index[i][1])
			positions = prv_pos
			prv_pos = []
			complement_val = T - val
			if complement_val == val:
				for j in range(0, len(positions), 2):
					ans[positions[j]] = 0
					if j + 1 < len(positions):
						ans[positions[j + 1]] = 1
			else:
				if val < complement_val:
					temp_ans = 0
				else:
					temp_ans = 1
				for j in range(0, len(positions)):
					ans[positions[j]] = temp_ans
	print(' '.join(map(str, ans)))


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, T, A):
	smaller = []
	eq = []
	bigger = []
	for (i, x) in enumerate(A):
		if x < T // 2:
			smaller.append(i)
		elif x == T // 2:
			eq.append(i)
		else:
			bigger.append(i)
	bigger = set(bigger)
	if T % 2 == 0:
		bigger.update(eq[:len(eq) // 2])
	ans = [1 if i in bigger else 0 for i in range(N)]
	return ' '.join(map(str, ans))
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N, T) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	ans = solve(N, T, A)
	print(ans)


import os
import heapq
import sys, threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10 ** 5)
from io import BytesIO, IOBase

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def power(x, p, m):
	res = 1
	while p:
		if p & 1:
			res = res * x % m
		x = x * x % m
		p >>= 1
	return res

def inar():
	return [int(k) for k in input().split()]

def lcm(num1, num2):
	return num1 * num2 // gcd(num1, num2)

def main():
	t = int(input())
	for _ in range(t):
		(n, T) = inar()
		arr = inar()
		lis1 = set()
		lis2 = set()
		dic = defaultdict(int)
		for i in range(n):
			dic[arr[i]] += 1
		check = set()
		for (key, item) in dic.items():
			if T - key in dic and T - key != key and (key not in check):
				lis1.add(key)
				lis2.add(T - key)
				check.add(T - key)
			elif T - key not in dic:
				lis1.add(key)
		res = [-1] * n
		for i in range(n):
			if arr[i] in lis1:
				res[i] = 0
			if arr[i] in lis2:
				res[i] = 1
		if T % 2 == 0:
			take = T // 2
			if take in dic:
				total = dic[take]
				one = total // 2
				two = total - one
				for i in range(n):
					if arr[i] == take:
						if one > 0:
							res[i] = 0
							one -= 1
							continue
						if two > 0:
							res[i] = 1
							two -= 1
						else:
							break
		print(*res)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
N = 10005
factorialNumInverse = [None] * (N + 1)
naturalNumInverse = factorialNumInverse.copy()
fact = factorialNumInverse.copy()

def InverseofNumber(p):
	naturalNumInverse[0] = naturalNumInverse[1] = 1
	for i in range(2, N + 1, 1):
		naturalNumInverse[i] = naturalNumInverse[p % i] * (p - int(p / i)) % p

def InverseofFactorial(p):
	factorialNumInverse[0] = factorialNumInverse[1] = 1
	for i in range(2, N + 1, 1):
		factorialNumInverse[i] = naturalNumInverse[i] * factorialNumInverse[i - 1] % p

def factorial(p):
	fact[0] = 1
	for i in range(1, N + 1):
		fact[i] = fact[i - 1] * i % p

def Binomial(N, R, p):
	ans = fact[N] * factorialNumInverse[R] % p * factorialNumInverse[N - R] % p
	return ans

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		(N, n) = ria()
		a = ria()
		g1 = {}
		g0 = {}
		t = 0
		if n % 2 != 0:
			for i in a:
				if i <= n // 2:
					if i in g0:
						g0[i] += 1
					else:
						g0[i] = 1
				if i > n // 2:
					if i in g1:
						g1[i] += 1
					else:
						g1[i] = 1
		else:
			for i in a:
				if i < n // 2:
					if i in g0:
						g0[i] += 1
					else:
						g0[i] = 1
				if i > n // 2:
					if i in g1:
						g1[i] += 1
					else:
						g1[i] = 1
				if i == n // 2:
					if t == 0:
						if i in g0:
							g0[i] += 1
						else:
							g0[i] = 1
						t = 1
					else:
						if i in g1:
							g1[i] += 1
						else:
							g1[i] = 1
						t = 0
		ans = []
		for i in a:
			if i in g1 and g1[i] > 0:
				ans.append(1)
				g1[i] -= 1
			elif i in g0 and g0[i] > 0:
				ans.append(0)
				g0[i] -= 1
		print(*ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
for _ in range(int(stdin.readline())):
	(n, t) = list(map(int, stdin.readline().rstrip().split()))
	a = list(map(int, stdin.readline().rstrip().split()))
	d = {}
	for i in a:
		if i not in d:
			d[i] = 0
		d[i] += 1
	if t % 2 == 0:
		bb = t // 2
	else:
		bb = -1
	c = {}
	for i in a:
		if i not in c and i != bb:
			c[i] = 0
			c[t - i] = 1
	cnt = 0
	for i in a:
		if i != bb:
			print(c[i], end=' ')
		else:
			if cnt < d[bb] // 2:
				print(0, end=' ')
			else:
				print(1, end=' ')
			cnt += 1
	print()


import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

def solve(arr, k):
	console('----- solving ------')
	if k % 2 == 1:
		return [1 if a % 2 else 0 for a in arr]
	res = []
	cnt = 0
	for a in arr:
		if a == k // 2:
			cnt += 1
			if cnt % 2:
				res.append(0)
			else:
				res.append(1)
		elif a < k // 2:
			res.append(0)
		else:
			res.append(1)
	return res

def console(*args):
	print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)
	return
for case_num in range(int(input())):
	(_, k) = list(map(int, input().split()))
	lst = list(map(int, input().split()))
	res = solve(lst, k)
	res = ' '.join((str(x) for x in res))
	print(res)


from collections import defaultdict, Counter

def main():
	for case in range(int(input())):
		(n, t) = [int(x) for x in input().split()]
		arr = [int(x) for x in input().split()]
		ct = defaultdict(lambda : set())
		for i in range(n):
			ct[arr[i]].add(i)
		c = []
		d = []
		for x in arr:
			if len(ct[x]) == 0:
				continue
			i = ct[x].pop()
			y = t - x
			if len(ct[y]) == 0:
				if x <= t // 2:
					c.append(i)
				else:
					d.append(i)
			else:
				j = ct[y].pop()
				if x <= y:
					c.append(i)
					d.append(j)
				else:
					c.append(j)
					d.append(i)
		arr2 = [-1] * n
		for j in c:
			arr2[j] = 0
		for j in d:
			arr2[j] = 1
		print(*arr2)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from sys import stdin, stdout
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007
INF = float('inf')

def solve():
	(n, k) = mp()
	l = li()
	ans = [1 for i in range(n)]
	a = []
	d = {}
	dd = {}
	b = []
	for i in range(n):
		p = k - l[i]
		if p not in d:
			ans[i] = 1
			d[l[i]] = 1
		elif p not in dd:
			dd[l[i]] = 1
			ans[i] = 0
		else:
			(c, cc) = (d[l[i]], dd[l[i]])
			if c <= cc:
				d[l[i]] += 1
				ans[i] = 1
			else:
				dd[l[i]] += 1
				ans[i] = 0
	print(*ans)
for _ in range(inp()):
	solve()


testCases = int(input())
while testCases > 0:
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	arr = input().split()
	color = list()
	for i in range(n):
		arr[i] = int(arr[i])
		color.append(1)
	temp = dict()
	for i in range(n):
		if k - arr[i] in temp:
			color[i] = int(not temp[k - arr[i]])
			temp[arr[i]] = not temp[k - arr[i]]
		else:
			temp[arr[i]] = True
	for i in range(n):
		print(color[i], end=' ')
	print()
	testCases -= 1


T = int(input())
for t in range(T):
	(n, tee) = map(int, input().split())
	A = list(map(int, input().split()))
	res = []
	if tee % 2 != 0:
		for i in range(n):
			if A[i] < tee / 2:
				res.append(0)
			else:
				res.append(1)
	else:
		temp = A.count(tee // 2) // 2
		for i in range(n):
			if A[i] < tee / 2:
				res.append(0)
			elif A[i] > tee / 2:
				res.append(1)
			elif temp != 0:
				res.append(0)
				temp -= 1
			else:
				res.append(1)
	for x in res:
		print(x, end=' ')
	print()


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	res = [0] * n
	b = []
	for i in range(n):
		b.append((a[i], i))
	b.sort()
	p = t % 2 == 0
	m = t // 2 - 1 * p
	m1 = m + 1 + 1 * p
	s = -1
	e = -1
	for i in range(n):
		(v, w) = b[i]
		if v <= m:
			res[w] = 1
		elif v >= m1:
			res[w] = 0
		else:
			if s == -1:
				s = i
			e = i
	num = (e - s + 1) // 2
	c = 0
	for i in range(s, e + 1):
		(v, w) = b[i]
		if c < num:
			res[w] = 1
			c += 1
		else:
			res[w] = 0
	print(*res)


for i1 in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	l1 = [0] * n
	y = 0
	for i in range(n):
		if t % 2 != 0:
			if a[i] <= t // 2:
				print(1, end=' ')
			else:
				print(0, end=' ')
		elif a[i] <= t // 2:
			if a[i] == t // 2 and y == 0:
				print(y, end=' ')
				y = 1
			elif a[i] == t // 2 and y == 1:
				print(y, end=' ')
				y = 0
			else:
				print(1, end=' ')
		else:
			print(0, end=' ')
	print()


r = lambda : [*map(int, input().split())]
for _ in range(r()[0]):
	(n, u) = r()
	l = r()
	c = 0
	for i in range(n):
		if l[i] < u / 2:
			l[i] = 0
		elif l[i] > u / 2:
			l[i] = 1
		else:
			l[i] = c % 2
			c += 1
	print(*l)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	myList = list(map(int, input().split()))
	flag = 1
	for i in range(x):
		if myList[i] < y / 2:
			myList[i] = 1
		elif myList[i] > y / 2:
			myList[i] = 0
		else:
			myList[i] = flag
			flag ^= 1
	print(*myList)


def chk(a, T):
	a.sort()
	f = {}
	for i in a:
		if f.get(i, 0) == 0:
			f[i] = 1
		else:
			f[i] += 1
	cnt = 0
	for i in a:
		f[i] -= 1
		if f.get(T - i, 0) > 0:
			cnt += 1
	return cnt
for t in range(int(input())):
	(n, T) = map(int, input().split())
	a1 = list(map(int, input().split()))
	a = sorted(a1)
	i = 0
	j = n - 1
	(c, d) = ([], [])
	ans = [-1] * n
	while i < j:
		if a[i] + a[j] > T:
			d.append(a[j])
			ans[j] = 1
			j -= 1
		elif a[i] + a[j] < T:
			c.append(a[i])
			ans[i] = 0
			i += 1
		else:
			c.append(a[i])
			d.append(a[j])
			ans[i] = 0
			ans[j] = 1
			i += 1
			j -= 1
	if ans[i] == -1:
		x1 = chk(c + [a[i]], T) + chk(d, T)
		x2 = chk(d + [a[i]], T) + chk(c, T)
		if x1 < x2:
			ans[i] = 0
			c.append(a[i])
		else:
			ans[i] = 1
			d.append(a[i])
	elif ans[j] == -1:
		x1 = chk(c + [a[j]], T) + chk(d, T)
		x2 = chk(d + [a[j]], T) + chk(c, T)
		if x1 < x2:
			ans[j] = 0
			c.append(a[j])
		else:
			ans[j] = 1
			d.append(a[j])
	fc = {}
	fd = {}
	for i in c:
		if fc.get(i, 0) == 0:
			fc[i] = 1
		else:
			fc[i] += 1
	for i in d:
		if fd.get(i, 0) == 0:
			fd[i] = 1
		else:
			fd[i] += 1
	ans1 = [-1] * n
	for i in range(n):
		if fc.get(a1[i], 0) > 0:
			fc[a1[i]] -= 1
			ans1[i] = 0
		else:
			ans1[i] = 1
	print(*ans1)


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
INF = float('inf')
mod = 10 ** 9 + 7
for _ in range(int(data())):
	(n, t) = mdata()
	a = mdata()
	d = dd(int)
	ans = [0] * n
	for i in range(n):
		if t - a[i] in d:
			d[a[i]] = ans[i] = 1 - d[t - a[i]]
		else:
			d[a[i]] = 0
	outl(ans)


t = int(input())
for _ in range(t):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in range(n):
		a[i] = (a[i], i)
	bckt = [-1] * n
	if T % 2 == 0:
		ct = 0
		for i in range(n):
			if a[i][0] == T // 2:
				if ct % 2:
					bckt[i] = 1
				else:
					bckt[i] = 0
				ct += 1
	a.sort()
	seen = set()
	if bckt[a[0][1]] == -1:
		bckt[a[0][1]] = 1
		seen.add(a[0][0])
	for i in range(n):
		if bckt[a[i][1]] == -1:
			if T - a[i][0] in seen:
				bckt[a[i][1]] = bckt[a[0][1]] ^ 1
			else:
				bckt[a[i][1]] = bckt[a[0][1]]
				seen.add(a[i][0])
	print(*bckt)


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	l = []
	p = 0
	for i in arr:
		if i < k / 2:
			l.append(1)
		elif i > k / 2:
			l.append(0)
		else:
			l.append(p)
			if p:
				p = 0
			else:
				p = 1
	print(*l)


t = int(input())
for _ in range(t):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	d = [0] * n
	for i in range(n):
		a[i] = [a[i], i]
	a.sort()
	r = 0
	pp = 0
	d[a[0][1]] = 0
	for i in range(1, n):
		if a[i][0] + a[i - 1][0] > T:
			r = 1
			d[a[i][1]] = r
		elif a[i][0] + a[i - 1][0] == T:
			if pp % 2 == 0:
				d[a[i][1]] = 1
			else:
				d[a[i][1]] = 0
			pp += 1
		else:
			d[a[i][1]] = r
	for i in range(n):
		print(d[i], end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, T) = map(int, input().split())
	l1 = [int(x) for x in input().split()]
	current = 0
	for i in range(n):
		if T % 2 == 0 and l1[i] == T // 2:
			if current:
				l1[i] = 0
				current = 0
			else:
				l1[i] = 1
				current = 1
		else:
			l1[i] = int(l1[i] > T // 2)
	print(*l1)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from heapq import *
from math import gcd, factorial, floor, ceil
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 10 ** 9 + 7

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	(n, t) = sep()
	a = lis()
	c = []
	d = []
	cnt = {}
	for i in range(n):
		if a[i] in cnt:
			cnt[a[i]].append(i)
		else:
			cnt[a[i]] = [i]
	col = [0] * n
	for i in cnt:
		if len(cnt[i]) == 0:
			continue
		if i * 2 == t:
			for j in range(len(cnt[i]) // 2):
				c.append(i)
				d.append(i)
				col[cnt[i][j]] = 1
			if len(cnt[i]) % 2 == 1:
				c.append(i)
			continue
		if t - i in cnt:
			for j in range(min(len(cnt[i]), len(cnt[t - i]))):
				c.append(i)
				d.append(t - i)
				col[cnt[t - i][j]] = 1
			if cnt[i] > cnt[t - i]:
				for j in range(abs(len(cnt[i]) - len(cnt[t - i]))):
					c.append(i)
			else:
				for j in range(len(cnt[i]), len(cnt[t - i])):
					d.append(t - i)
					col[cnt[t - i][j]] = 1
			cnt[i] = []
			cnt[t - i] = []
		else:
			for j in range(len(cnt[i])):
				c.append(i)
	print(' '.join((str(col[i]) for i in range(n))))
testcase(int(inp()))


import sys, io, os, time
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
input = sys.stdin.readline
for ii in range(int(input())):
	(n, t) = map(int, input().split())
	arr = list(map(int, input().split()))
	countc = defaultdict(int)
	countd = defaultdict(int)
	c = []
	d = []
	for i in range(n):
		if t - arr[i] not in countc:
			countc[arr[i]] += 1
			c.append(i)
		elif t - arr[i] not in countd:
			countd[arr[i]] += 1
			d.append(i)
		elif countc[t - arr[i]] > countd[t - arr[i]]:
			countd[arr[i]] += 1
			d.append(i)
		else:
			countc[arr[i]] += 1
			c.append(i)
	ans = [0] * n
	for i in c:
		ans[i] = 0
	for i in d:
		ans[i] = 1
	print(*ans)


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	from collections import defaultdict
	mpc = {}
	mpd = {}
	mp = defaultdict(list)
	res = [0] * n
	for i in range(n):
		if t - a[i] not in mpc:
			mpc[a[i]] = 1
			res[i] = 1
		elif t - a[i] not in mpd:
			mpd[a[i]] = 1
		else:
			mp[a[i]].append(i)
	for key in mp.keys():
		for j in range(len(mp[key])):
			if j % 2:
				res[mp[key][j]] = 1
	print(*res)


t = int(input())
for case in range(1, t + 1):
	(n, T) = list(map(int, input().split()))
	elems = sorted(list(map(lambda v: (v[1], v[0]), enumerate(list(map(int, input().split()))))))
	split = T / 2
	equals = 0
	for (v, i) in elems:
		if v == split:
			equals += 1
	first_side = equals / 2
	final_index = 0
	for (i, (value, index)) in enumerate(elems):
		final_index = i
		if split > value:
			continue
		if split == value:
			first_side -= 1
			if first_side < 0:
				break
		if split < value:
			break
	painted = ['0'] * len(elems)
	for i in range(final_index):
		painted[elems[i][1]] = '1'
	print(' '.join(painted))


t = int(input())
for i in range(t):
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	flag = 0
	if T % 2 != 0:
		for i in range(n):
			if a[i] <= T // 2 or a[i] > T:
				print(0, end=' ')
			else:
				print(1, end=' ')
		print()
	else:
		for i in range(n):
			if a[i] < T // 2 or a[i] > T:
				print(0, end=' ')
			if a[i] > T // 2 and a[i] <= T:
				print(1, end=' ')
			if a[i] == T // 2:
				print(flag, end=' ')
				flag = 1 - flag
		print()


import math

def get_int():
	return int(input())

def get_ints():
	return [int(i) for i in input().split()]
for t in range(0, get_int()):
	(n, T) = get_ints()
	a_array = get_ints()
	results = [-1] * n
	m = {}
	for i in range(0, n):
		e = a_array[i]
		if e in m:
			m[e] = m[e] + 1
		else:
			m[e] = 1
	for i in range(0, n):
		e = a_array[i]
		if T - e in m:
			if e > T - e:
				results[i] = 0
			elif e == T - e:
				results[i] = m[e] % 2
				m[e] = m[e] - 1
			else:
				results[i] = 1
		else:
			results[i] = 0
	print(*results, sep=' ')


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	x = list(map(int, input().split()))
	y = []
	j = True
	for i in range(len(x)):
		if x[i] < t / 2:
			y.append(1)
		elif x[i] > t / 2:
			y.append(0)
		elif x[i] == t / 2:
			if j == True:
				y.append(1)
				j = False
			else:
				y.append(0)
				j = True
	print(*y)


import sys
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda : list(map(int, input().strip().split()))
MOD = 998244353

def f(n):
	if n < 10:
		return n
	return f(n % 10 + f(n // 10))

def main():
	ans = []
	for _ in range(int(input())):
		(n, T) = read()
		arr = read()
		dic = defaultdict(int)
		ans_arr = [0] * n
		alter = 0
		for i in range(n):
			if T % 2 == 0 and arr[i] == T // 2:
				ans_arr[i] = alter
				alter = alter ^ 1
			elif not arr[i] in dic:
				dic[T - arr[i]] = 0
				ans_arr[i] = 1
		ans.append(' '.join(map(str, ans_arr)))
	print('\n'.join(ans))
main()


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	if k % 2 == 0:
		ss = k // 2
		cnt = 0
		for i in a:
			if i < ss:
				print(1, end=' ')
			elif i == ss:
				print(cnt % 2, end=' ')
				cnt += 1
			else:
				print(0, end=' ')
	else:
		ss = k // 2
		for i in a:
			if i <= ss:
				print(1, end=' ')
			else:
				print(0, end=' ')
	print()


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	s = [0] * n
	b = 1
	for i in range(n):
		if a[i] > t // 2:
			s[i] = 1
		elif a[i] == t // 2 and t % 2 == 0:
			s[i] = b
			b ^= 1
	print(*s)


import sys
input = sys.stdin.readline

def solve():
	(n, x) = map(int, input().split())
	L = list(map(int, input().split()))
	ans = [0] * n
	flag = 1
	for i in range(n):
		if x & 1 == 0 and L[i] == x // 2:
			ans[i] = 1 ^ flag
			flag ^= 1
		else:
			ans[i] = int(L[i] > x // 2)
	print(*ans)
for _ in range(int(input())):
	solve()


from sys import stdin
input = stdin.readline
from collections import Counter
from collections import defaultdict
for _ in range(int(input())):
	(n, T) = map(int, input().split())
	a = [*map(int, input().split())]
	answer = [None for i in range(n)]
	revmap = Counter(a)
	indmap = defaultdict(set)
	for (i, j) in enumerate(a):
		indmap[j].add(i)
	for i in range(n):
		if revmap[a[i]] != 0:
			if a[i] + a[i] == T:
				flip = 1
				for x in indmap[a[i]]:
					answer[x] = flip
					flip = abs(flip - 1)
				revmap[a[i]] = 0
			elif revmap[T - a[i]] != 0:
				for x in indmap[a[i]]:
					answer[x] = 0
				for x in indmap[T - a[i]]:
					answer[x] = 1
				revmap[a[i]] = 0
				revmap[T - a[i]] = 0
			else:
				for x in indmap[a[i]]:
					answer[x] = 0
				revmap[a[i]] = 0
	print(*answer)


import sys
import math
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	alt = 0
	ans = []
	for i in range(len(arr)):
		if k % 2 == 1:
			if arr[i] < k / 2:
				ans.append(0)
			else:
				ans.append(1)
		elif arr[i] == k // 2:
			ans.append(alt % 2)
			alt += 1
		elif arr[i] < k // 2:
			ans.append(0)
		else:
			ans.append(1)
	print(*ans)


gans = []
for _ in range(int(input())):
	(n, T) = map(int, input().split())
	u = list(map(int, input().split()))
	ans = [-1] * n
	if T % 2 == 1:
		for i in range(n):
			if u[i] <= T // 2:
				ans[i] = 1
			else:
				ans[i] = 0
		gans.append(' '.join(map(str, ans)))
	else:
		cnt = 0
		T2 = T // 2
		for i in range(n):
			if u[i] < T2:
				ans[i] = 1
			elif u[i] > T2:
				ans[i] = 0
			else:
				cnt += 1
		cnt1 = 0
		cur = 0
		for i in range(n):
			if u[i] == T2:
				cnt1 += 1
				ans[i] = cur
				if cnt1 * 2 >= cnt:
					cur = 1
		gans.append(' '.join(map(str, ans)))
print('\n'.join(gans))


t = int(input())
for _ in range(t):
	(n, f) = map(int, input().split())
	a = list(map(int, input().split()))
	s = set()
	ans = ''
	bool = True
	half = -1
	if f % 2 == 0:
		half = f // 2
	for i in range(n):
		compl = f - a[i]
		if a[i] == half:
			if bool:
				print(0, end=' ')
			else:
				print(1, end=' ')
			bool = not bool
		elif compl in s:
			print(1, end=' ')
		else:
			print(0, end=' ')
			s.add(a[i])
	print()


from math import floor
t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	d = dict()
	for i in l:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	white = set()
	black = set()
	for i in range(n):
		if k - l[i] in d:
			if l[i] not in white and l[i] not in black:
				white.add(l[i])
				black.add(k - l[i])
		else:
			white.add(l[i])
	present = False
	if k % 2 == 0 and k // 2 in d:
		temp1 = d[k // 2] // 2
		present = True
	for i in l:
		if present and i == k // 2:
			if temp1 > 0:
				print(0, end=' ')
				temp1 -= 1
			else:
				print(1, end=' ')
		elif i in white:
			print(0, end=' ')
		else:
			print(1, end=' ')
	print()


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
from collections import defaultdict

def gift():
	for _ in range(t):
		(n, k) = list(map(int, input().split()))
		array = list(map(int, input().split()))
		dic1 = defaultdict(lambda : [])
		ans = [0] * n
		first = True
		for i in range(n):
			if array[i] == k / 2:
				if first:
					ans[i] = 1
					first = False
				else:
					first = True
			elif len(dic1[k - array[i]]) == 0:
				dic1[array[i]].append(i)
				ans[i] = 1
		yield ' '.join([str(x) for x in ans])
t = int(input())
ans = gift()
print(*ans, sep='\n')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	l = 0
	ans = [0 for i in range(n)]
	for i in range(n):
		if a[i] > t / 2:
			ans[i] = 1
		elif a[i] == t / 2:
			l ^= 1
			ans[i] = l
	print(*ans)


t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	dct = {}
	dct2 = {}
	for i in a:
		dct[i] = dct.get(i, 0) + 1
	lst = [0] * n
	for i in range(len(a)):
		now = dct2.get(a[i], 0)
		lst[i] = now
		if 2 * a[i] == m:
			dct2[a[i]] = 1 - now
		elif dct2.get(a[i], 0) == 0:
			dct2[m - a[i]] = 1
	print(' '.join([str(x) for x in lst]))


for _ in range(int(input())):
	(n, T) = map(int, input().split())
	redDreamer = list(map(int, input().split()))
	j = 0
	ans = []
	for i in redDreamer:
		if not T & 1 and i == T // 2:
			j = j % 2
			ans.append(j)
			j += 1
		elif 2 * i < T:
			ans.append(0)
		else:
			ans.append(1)
	print(*ans)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz/'
M = 998244353
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	(n, k) = value()
	a = array()
	color = defaultdict(lambda : -1)
	for i in a:
		if color[i] == -1:
			color[i] = 0
			color[k - i] = 1
	ans = []
	c = 0
	for i in a:
		if k % 2 == 0 and i == k // 2:
			ans.append(c)
			c ^= 1
		elif color[i] == -1:
			ans.append(1)
		else:
			ans.append(color[i])
	print(*ans)


for i in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	g = t // 2
	b = []
	s = []
	oop = '1'
	for i in a:
		if i < g:
			b.append(1)
			s.append(i)
		elif i == g:
			if t % 2 == 0:
				if oop == '0':
					b.append(0)
					s.append(i)
					oop = '1'
				else:
					b.append(1)
					s.append(i)
					oop = '0'
			else:
				b.append(1)
				s.append(i)
		else:
			b.append(0)
			s.append(i)
	for i in range(len(b) - 1):
		print(b[i], end=' ')
	print(b[-1])


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	liczby = list(map(int, input().split()))
	flaga = True
	for x in range(n):
		if liczby[x] < t / 2:
			print(0, end=' ')
		elif liczby[x] > t / 2:
			print(1, end=' ')
		else:
			if flaga:
				print(1, end=' ')
			else:
				print(0, end=' ')
			flaga = not flaga
	print()


import sys
LI = lambda : list(map(int, sys.stdin.readline().strip('\n').split()))
MI = lambda : map(int, sys.stdin.readline().strip('\n').split())
SI = lambda : sys.stdin.readline().strip('\n')
II = lambda : int(sys.stdin.readline().strip('\n'))
for _ in range(II()):
	(n, t) = MI()
	(clr, par) = ([0] * n, 0)
	for (i, v) in enumerate(MI()):
		if v < t / 2:
			clr[i] = 1
		elif v == t // 2:
			if par:
				clr[i] = 1
			par = not par
	print(*clr)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	(wh, bl) = ({}, {})
	for el in l:
		if el > k:
			print(0, end=' ')
		elif k - el not in wh:
			print(0, end=' ')
			if el in wh:
				wh[el] += 1
			else:
				wh[el] = 1
		elif k - el not in bl:
			print(1, end=' ')
			if el in bl:
				bl[el] += 1
			else:
				bl[el] = 1
		elif wh[k - el] > bl[k - el]:
			print(1, end=' ')
			if el in bl:
				bl[el] += 1
			else:
				bl[el] = 1
		else:
			print(0, end=' ')
			if el in wh:
				wh[el] += 1
			else:
				wh[el] = 1
	print()


import sys
input = sys.stdin.readline

def inInt():
	return int(input())

def inStr():
	return input().strip('\n')

def inIList():
	return list(map(int, input().split()))

def inSList():
	return input().split()

def bsearch(nums, target):
	N = len(nums or [])
	l = 0
	r = N - 1
	while l <= r:
		mid = (l + r) // 2
		if nums[mid] < target:
			l = mid + 1
		elif nums[mid] > target:
			r = mid - 1
		else:
			return (None, mid, None)
	return (r if r >= 0 else None, None, l if l <= N - 1 else None)

def yesOrNo(val):
	print('YES' if val else 'NO')

def printSpacedArray(nums):
	print(*nums)

def solve():
	(n, T) = inIList()
	t = T / 2
	nums = inIList()
	res = []
	if T % 2:
		for i in range(n):
			if nums[i] < t:
				res.append(0)
			else:
				res.append(1)
	else:
		h = 0
		for i in nums:
			if i == t:
				h += 1
		s = 0
		for i in range(n):
			if nums[i] < t:
				res.append(0)
			elif nums[i] > t:
				res.append(1)
			else:
				if s < h / 2:
					res.append(0)
				else:
					res.append(1)
				s += 1
	print(*res)
tests = inInt()
for case in range(tests):
	solve()


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = [-1] * n
	cand = []
	for i in range(n):
		if t % 2 == 0:
			if a[i] < t // 2:
				ans[i] = 0
			elif a[i] > t // 2:
				ans[i] = 1
			else:
				cand.append(i)
		elif a[i] <= t // 2:
			ans[i] = 0
		else:
			ans[i] = 1
	l = len(cand)
	for i in range(l):
		if i < l // 2:
			ans[cand[i]] = 0
		else:
			ans[cand[i]] = 1
	print(' '.join(map(str, ans)))


t = int(input())
for _ in range(t):
	(n, t) = map(int, input().split())
	arr = list(map(int, input().split()))
	color = [0] * len(arr)
	isEven = False
	for i in range(len(arr)):
		if arr[i] < t / 2:
			color[i] = 0
		if arr[i] > t / 2:
			color[i] = 1
		if arr[i] == t / 2:
			color[i] = 0 if isEven else 1
			isEven = not isEven
	print(' '.join(map(str, color)))


def solve():
	(n, T) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	ans = []
	half_T = T / 2
	value = 0
	for i in range(n):
		if a[i] < T / 2:
			ans.append(0)
		elif a[i] > T / 2:
			ans.append(1)
		else:
			ans.append(value)
			value = 1 if value == 0 else 0
	print(*ans)
t = int(input().strip())
for _ in range(t):
	solve()


from bisect import *
from collections import *
from random import *
from decimal import *
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def st():
	return input().rstrip('\n')

def lis():
	return list(map(int, input().split()))

def ma():
	return map(int, input().split())
t = inp()
while t:
	t -= 1
	(n, k) = ma()
	a = lis()
	z = [0] * n
	f = Counter(a)
	fl = set()
	tu = 0
	for i in range(n):
		if k - a[i] in f:
			if k - a[i] == a[i] and f[a[i]] == 1:
				continue
			if a[i] in fl and k - a[i] != a[i]:
				continue
			z[i] = 1
			if k - a[i] == a[i]:
				z[i] = tu % 2
				tu += 1
			fl.add(k - a[i])
	print(*z)


t = int(input())
for i in range(t):
	(n, t) = map(int, input().split())
	l = list(map(int, input().split()))
	s1 = set()
	s2 = set()
	res = []
	count = 0
	for j in range(n):
		if l[j] > t:
			res.append('1')
			s2.add(l[j])
		elif t - l[j] in s1 and t - l[j] in s2:
			res.append(count)
			count ^= 1
		elif t - l[j] in s1:
			res.append('1')
			s2.add(l[j])
		else:
			res.append('0')
			s1.add(l[j])
	print(*res)


for test in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	c = d = []
	r = 0
	ck = 0
	for i in a:
		if 2 * i == k:
			r = ck % 2
			ck += 1
		elif 2 * i < k:
			r = 0
		else:
			r = 1
		print(r, end=' ')
	print()


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	list1 = [int(i) for i in input().split()]
	count = 0
	for i in range(n):
		if k / 2 - list1[i] < 0:
			list1[i] = 0
		elif k / 2 - list1[i] > 0:
			list1[i] = 1
		elif count == 0:
			count = 1
			list1[i] = 0
		else:
			count = 0
			list1[i] = 1
	print(*list1)


def find(x):
	(l, r, ans) = (0, n - 1, n)
	while l <= r:
		m = (l + r) // 2
		if a[m][0] == x:
			ans = m
			r = m - 1
		elif a[m][0] > x:
			r = m - 1
		else:
			l = m + 1
	return ans
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = []
	id = 0
	for x in input().split():
		a.append([int(x), id])
		id += 1
	a.sort()
	arr = [0] * (n + 1)
	for i in range(n):
		if arr[i] == 0:
			if a[i][0] * 2 != k:
				arr[i] = 1
				j = i
				while j < n and a[j][0] == a[i][0]:
					if arr[j] == 0:
						arr[j] = 1
					j += 1
				j = find(k - a[i][0])
				while j < n and a[j][0] == k - a[i][0]:
					if arr[j] == 0:
						arr[j] = 2
					j += 1
			else:
				j = i
				ok = True
				while j < n and a[j][0] == a[i][0]:
					if arr[j] == 0:
						if ok:
							arr[j] = 1
							j += 1
							ok = False
						else:
							arr[j] = 2
							j += 1
							ok = True
	ans = [0] * (n + 1)
	for i in range(n):
		ans[a[i][1]] = arr[i] - 1
	for i in range(n):
		print(ans[i], end=' ')
	print()


from math import floor, ceil
t = int(input())
for i in range(t):
	(n, T) = map(int, input().split())
	arr = [int(i) for i in input().split()]
	count = {}
	for i in arr:
		count[i] = count.get(i, 0) + 1
	res = 0
	color = {}
	for i in set(arr):
		if i == T - i:
			x = count[i]
			(a, b) = (floor(x / 2), ceil(x / 2))
			res += a * (a - 1) // 2 + b * (b - 1) // 2
			color[i] = [0] * a + [1] * b
		else:
			color[i] = 0
			color[T - i] = 1
	for i in arr:
		try:
			print(color[i].pop(), end=' ')
		except:
			print(color[i], end=' ')
	print()


def testCase():
	(n, T) = map(int, input().split())
	a = list(map(int, input().split()))
	c = dict()
	d = dict()
	count = 0
	ans = [0] * n
	for i in range(n):
		val = T - a[i]
		if val not in d.keys() and val not in c.keys():
			c[a[i]] = 1
			ans[i] = 0
		elif val not in d.keys():
			d[a[i]] = 1
			ans[i] = 1
		elif val not in c.keys():
			c[a[i]] = 1
			ans[i] = 0
		elif c[val] <= d[val]:
			count += c[val]
			c[a[i]] += 1
			ans[i] = 0
		else:
			count += d[val]
			d[a[i]] += 1
			ans[i] = 1
	for i in ans:
		print(i, end=' ')
	print()
test = int(input())
while test:
	testCase()
	test -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	f = 1
	for i in range(len(l)):
		x = l[i]
		if x > k / 2:
			l[i] = 1
			continue
		if x < k / 2:
			l[i] = 0
			continue
		l[i] = f
		f = f ^ 1
	print(*l)


from collections import Counter

def process():
	(n, t) = map(int, input().split())
	arr = list(map(int, input().split()))
	data = dict(Counter(arr))
	for key in data:
		if data[key] == 0:
			continue
		opp = t - key
		if opp == key:
			data[key] //= 2
		elif opp in data:
			data[opp] = 0
	color = [0] * n
	for i in range(n):
		if data[arr[i]] > 0:
			color[i] = 1
			data[arr[i]] -= 1
	print(*color)
for i in range(int(input())):
	process()


for o in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(map(int, input().split()))
	if k % 2 == 0:
		a = s.count(k / 2)
		c = 0
		for i in range(n):
			if s[i] > int(k / 2):
				s[i] = '1'
			elif s[i] < int(k / 2):
				s[i] = '0'
			elif s[i] == int(k / 2):
				if c >= int(a // 2):
					s[i] = '1'
				else:
					s[i] = '0'
				c = c + 1
	else:
		for i in range(n):
			if s[i] > int(k // 2):
				s[i] = '1'
			else:
				s[i] = '0'
	s = ' '.join(s)
	print(s)


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	s = set()
	l = list(map(int, input().split()))
	f = [0 for i in range(n)]
	for i in range(n):
		if l[i] in s:
			f[i] = 1
		else:
			s.add(abs(t - l[i]))
	if t % 2 == 0:
		cnt = l.count(t // 2) // 2
		for i in range(n):
			if cnt and l[i] == t // 2:
				f[i] = 0
				cnt -= 1
	if not f.count(1):
		f[0] = 1
	print(*f)


from sys import stdin

def iinput():
	return int(stdin.readline())

def minput():
	return map(int, stdin.readline().split())

def linput():
	return list(map(int, stdin.readline().split()))

def sum_pair(arr, n, x):
	pairs = []
	s = set()
	for e in arr:
		if x - e in s:
			pairs.append([e, x - e])
		s.add(e)
	return pairs
from collections import Counter, defaultdict
t = iinput()
while t:
	t -= 1
	(n, k) = minput()
	a = linput()
	p = sum_pair(a, n, k)
	c = Counter(a)
	color = defaultdict(int)
	visited = defaultdict(bool)
	for e in p:
		if not visited[e[0]] or not visited[e[1]]:
			if e[0] == e[1]:
				q = c[e[0]] // 2
				w = c[e[0]] - q
				c[-1 * e[0]] = w
				c[e[0]] = q
				color[e[0]] = 0
				color[0 - e[0]] = 1
			else:
				color[e[0]] = 0
				color[e[1]] = 1
			visited[e[0]] = visited[e[1]] = True
	col = [0] * n
	for i in range(n):
		if a[i] in color and c[a[i]] > 0:
			c[a[i]] -= 1
			col[i] = color[a[i]]
		elif -1 * a[i] in color and c[-1 * a[i]] > 0:
			c[-1 * a[i]] -= 1
			col[i] = color[-1 * a[i]]
	print(*col)


from sys import stdin, stdout
import math
import heapq
import collections
input = stdin.readline

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputstrings():
	return [x for x in input().split()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(n, T) = inputnums()
	a = inputlist()
	d = {}
	for i in range(n):
		if a[i] in d:
			continue
		elif a[i] <= T:
			d[T - a[i]] = 1
	cur = False
	for i in range(n):
		if a[i] * 2 == T:
			if cur:
				print(1, end=' ')
				cur = False
			else:
				print(0, end=' ')
				cur = True
			continue
		if a[i] in d:
			print(1, end=' ')
		else:
			print(0, end=' ')
	print()


for cases in range(int(input())):
	(n, T) = map(int, input().split())
	arr = list(map(int, input().split()))
	white = {}
	black = {}
	ans = []
	for i in arr:
		if T - i not in white.keys():
			white[i] = 1
			ans.append(0)
		elif T - i not in black.keys():
			black[i] = 1
			ans.append(1)
		elif white[T - i] < black[T - i]:
			white[i] += 1
			ans.append(0)
		else:
			black[i] += 1
			ans.append(1)
	for i in range(n - 1):
		print(ans[i], end=' ')
	print(ans[n - 1])


import os, sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	res = [0 for i in range(n)]
	d = []
	d1 = []
	turn = 0
	for i in range(n):
		if k - a[i] not in d:
			d.append(a[i])
		elif k - a[i] not in d1:
			d1.append(a[i])
		elif turn == 0:
			d.append(a[i])
			turn = 1
		else:
			d1.append(a[i])
			turn = 0
	j = 0
	i = 0
	m = len(d)
	while i < n and j < m:
		if a[i] == d[j]:
			res[i] = 1
			i += 1
			j += 1
		else:
			i += 1
	print(*res)


for _ in range(int(input())):
	(n, t) = map(int, input().split())
	l = list(map(int, input().split()))
	a = [0] * n
	x = t / 2
	c = l.count(t / 2)
	j = 0
	for i in range(n):
		if l[i] > x:
			a[i] = 1
		elif l[i] == x and j < c // 2:
			a[i] = 1
			j += 1
	print(*a)


from sys import stdin
input = stdin.readline

def A():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		a = sorted(list(map(int, input().split())))
		tot = 0
		for i in range(1, n):
			tot += (k - a[i]) // a[0]
		print(tot)

def B():
	from collections import defaultdict
	t = int(input())
	for _ in range(t):
		(n, T) = map(int, input().split())
		a = list(map(int, input().split()))
		d = defaultdict()
		colors = [0] * n
		for i in range(n):
			colors[i] = d.get(a[i], 0)
			d[T - a[i]] = (1 + colors[i]) % 2
		print(*colors)
B()


from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
	(n, t) = map(int, input().split())
	arr = list(map(int, input().split()))
	fl = 1
	ans = []
	for d in arr:
		if d < t / 2:
			ans.append(0)
		elif d > t / 2:
			ans.append(1)
		elif fl == 1:
			ans.append(1)
			fl = 0
		else:
			ans.append(0)
			fl = 1
	ans = list(map(str, ans))
	print(' '.join(ans))


from collections import defaultdict

def f():
	return 0
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	w = defaultdict(f)
	b = defaultdict(f)
	ans = []
	for i in range(n):
		if b[k - a[i]] > w[k - a[i]]:
			w[a[i]] += 1
			ans.append(1)
		else:
			b[a[i]] += 1
			ans.append(0)
	for i in ans:
		print(i, end=' ')
	print()


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(beauty, s, n, count):
	pass

def sortSecond(val):
	return val[1]
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
alphs = 'abcdefghijklmnopqrstuvwxyz'
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect
import functools as fnt

def solve():
	(n, T) = read()
	a = get_list()
	c = [0] * n
	z = 1
	for (i, x) in enumerate(a):
		if x > T / 2:
			c[i] = 1
		elif x == T / 2:
			c[i] = z
			z ^= 1
	print(*c)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = scanner()
for i in range(t):
	solve()