Little X has n distinct integers: p_1, p_2, ..., p_{n}. He wants to divide all of them into two sets A and B. The following two conditions must be satisfied:  If number x belongs to set A, then number a - x must also belong to set A.  If number x belongs to set B, then number b - x must also belong to set B. 

Help Little X divide the numbers into two sets or determine that it's impossible.


-----Input-----

The first line contains three space-separated integers n, a, b (1 ≤ n ≤ 10^5; 1 ≤ a, b ≤ 10^9). The next line contains n space-separated distinct integers p_1, p_2, ..., p_{n} (1 ≤ p_{i} ≤ 10^9).


-----Output-----

If there is a way to divide the numbers into two sets, then print "YES" in the first line. Then print n integers: b_1, b_2, ..., b_{n} (b_{i} equals either 0, or 1), describing the division. If b_{i} equals to 0, then p_{i} belongs to set A, otherwise it belongs to set B.

If it's impossible, print "NO" (without the quotes).


-----Examples-----
Input
4 5 9
2 3 4 5

Output
YES
0 0 1 1

Input
3 3 4
1 2 4

Output
NO



-----Note-----

It's OK if all the numbers are in the same set, and the other one is empty.

Difficulty: competition

Starter code:

Solutions:
from collections import defaultdict

def solve(n, a, b, xs):
    group = [None] * n
    id_ = {x: i for i, x in enumerate(xs)}
    if a == b:
        for x in xs:
            if a - x not in id_:
                return False
        group = [0] * n
    else:
        for i, x in enumerate(xs):
            if group[i] is not None:
                continue
            y = a - x
            z = b - x
            f1 = y in id_ and group[id_[y]] is None
            f2 = z in id_ and group[id_[z]] is None
            if f1 + f2 == 0:
                return False
            elif f1 + f2 == 1:
                g = int(f2)
                # End of link
                link = []
                t = a if f1 else b
                while x in id_:
                    link.append(x)
                    x = t - x
                    if x + x == t:
                        break
                    t = a + b - t
                # print(link)
                if len(link) % 2 == 0:
                    for i, x in enumerate(link):
                        group[id_[x]] = g
                elif link[0] * 2 == (b, a)[g]:
                    for i, x in enumerate(link):
                        group[id_[x]] = 1 - g
                elif link[-1] * 2 == (a, b)[g]:
                    for i, x in enumerate(link):
                        group[id_[x]] = g
                else:
                    # Found invalid link, answer is "NO"
                    return False

    return group

n, a, b = list(map(int, input().split()))
xs = list(map(int, input().split()))
group = solve(n, a, b, xs)
if isinstance(group, list):
    print('YES')
    print(' '.join(map(str, group)))
else:
    print('NO')


class DisjointSet:
    def __init__(self, n):
        self._fa = list(range(n))

    def union(self, x, y):
        x = self.get_father(x)
        y = self.get_father(y)
        self._fa[x] = y
        return y

    def get_father(self, x):
        y = self._fa[x]
        if self._fa[y] == y:
            return y
        else:
            z = self._fa[y] = self.get_father(y)
            return z

    def __repr__(self):
        return repr([self.get_father(i) for i in range(len(self._fa))])

def solve(n, a, b, xs):
    h = {x: i for i, x in enumerate(xs)}
    if a == b:
        if all(a - x in h for x in xs):
            return [0] * n
        return False
    g1 = n
    g2 = n + 1
    ds = DisjointSet(n + 2)

    for i, x in enumerate(xs):
        for t in (a, b):
            if t - x in h:
                ds.union(i, h[t - x])

    for i, x in enumerate(xs):
        b1 = (a - x) in h
        b2 = (b - x) in h
        if b1 + b2 == 0:
            return False
        if b1 + b2 == 1:
            if b1:
                ds.union(i, g1)
            else:
                ds.union(i, g2)
            if ds.get_father(g1) == ds.get_father(g2):
                return False
    group = [None] * n
    for i, x in enumerate(xs):
        f = ds.get_father(i)
        if f < n:
            return False
        group[i] = f - n
    return group

n, a, b = list(map(int, input().split()))
xs = list(map(int, input().split()))
group = solve(n, a, b, xs)
if isinstance(group, list):
    print('YES')
    print(' '.join(map(str, group)))
else:
    print('NO')


class DisjointSet:
    def __init__(self, n):
        self._fa = list(range(n))

    def union(self, x, y):
        x = self.get_father(x)
        y = self.get_father(y)
        self._fa[x] = y
        return y

    def get_father(self, x):
        y = self._fa[x]
        if self._fa[y] == y:
            return y
        else:
            z = self._fa[y] = self.get_father(y)
            return z

    def __repr__(self):
        return repr([self.get_father(i) for i in range(len(self._fa))])

def solve(n, a, b, xs):
    h = {x: i for i, x in enumerate(xs)}
    if a == b:
        if all(a - x in h for x in xs):
            return [0] * n
        return False
    g1 = n
    g2 = n + 1
    ds = DisjointSet(n + 2)

    for i, x in enumerate(xs):
        for t in (a, b):
            if t - x in h:
                ds.union(i, h[t - x])

    for i, x in enumerate(xs):
        b1 = (a - x) in h
        b2 = (b - x) in h
        if b1 + b2 == 0:
            return False
        if b1 + b2 == 1:
            if b1:
                ds.union(i, g1)
            else:
                ds.union(i, g2)
            if ds.get_father(g1) == ds.get_father(g2):
                return False
    group = [None] * n
    for i, x in enumerate(xs):
        f = ds.get_father(i)
        if f < n:
            return False
        group[i] = f - n
    return group

n, a, b = map(int, input().split())
xs = list(map(int, input().split()))
group = solve(n, a, b, xs)
if isinstance(group, list):
    print('YES')
    print(' '.join(map(str, group)))
else:
    print('NO')

def find(u):
    nonlocal par
    if u != par[u]:
        par[u] = find(par[u])
    return par[u]

def union(u, v):
    u = find(u)
    v = find(v)
    par[u] = v

n, a, b = map(int, input().split())
p = list(map(int, input().split()))
mp = dict()
for i in range(n):
    mp[p[i]] = i + 1
par = [i for i in range(n + 2)]

for i in range(n):
    union(i + 1, mp.get(a - p[i], n + 1))
    union(i + 1, mp.get(b - p[i], 0))

A = find(0)
B = find(n + 1)

if A != B:
    print('YES')
    print(' '.join(['1' if find(i) == B else '0' for i in range(1, n + 1)]))
else:
    print('NO')

MAX = 100001
parent = []

def makeSet():
    nonlocal parent
    parent = [i for i in range(MAX + 1)]

def findSet(u):
    nonlocal parent
    if u != parent[u]:
        parent[u] = findSet(parent[u])
    return parent[u]

def unionSet(u, v):
    up = findSet(u)
    vp = findSet(v)
    parent[up] = vp

makeSet()
n, a, b = map(int, input().split())
p = list(map(int, input().split()))
pos = dict()
for i in range(n):
    pos[p[i]] = i + 1

for i in range(n):
    unionSet(i + 1, pos.get(a - p[i], n + 1))
    unionSet(i + 1, pos.get(b - p[i], 0))

A = findSet(0)
B = findSet(n + 1)

if A != B:
    print('YES')
    for i in range(1, n + 1):
        if findSet(i) == B:
            print('1', end = " ")
        else:
            print('0', end = " ")
else:
    print('NO')


parent = []
ranks = []


def make_set(n):
    nonlocal parent, ranks
    parent = [i for i in range(n + 5)]
    ranks = [0 for i in range(n + 5)]


def find_set(u):
    if parent[u] != u:
        parent[u] = find_set(parent[u])
    else:
        parent[u] = u
    return parent[u]


def union_set(u, v):
    up = find_set(u)
    vp = find_set(v)

    if ranks[up] > ranks[vp]:
        parent[vp] = up
    elif ranks[up] < ranks[vp]:
        parent[up] = vp
    else:
        parent[up] = vp
        ranks[vp] += 1


def solution():
    set_indicators = dict()
    n, a, b = list(map(int, input().split()))
    numbers = list(map(int, input().split()))
    A = n + 1
    B = A + 1

    make_set(n)
    for i in range(n):
        set_indicators[numbers[i]] = i

    for i in range(n):
        if set_indicators.get(a - numbers[i]) is not None:
            union_set(i, set_indicators.get(a - numbers[i]))
        else:
            union_set(i, B)
        if set_indicators.get(b - numbers[i]) is not None:
            union_set(i, set_indicators.get(b - numbers[i]))
        else:
            union_set(i, A)
    if find_set(A) == find_set(B):
        print('NO')
        return

    print('YES')
    print(''.join('1 ' if find_set(i) == find_set(n + 2) else '0 ' for i in range(n)))


solution()


def find(u):
    nonlocal par
    if u != par[u]:
        par[u] = find(par[u])
    return par[u]

def union(u, v):
    u = find(u)
    v = find(v)
    par[u] = v

n, a, b = map(int, input().split())
p = list(map(int, input().split()))
mp = dict()
for i in range(n):
    mp[p[i]] = i + 1
par = [i for i in range(n + 2)]

for i in range(n):
    union(i + 1, mp.get(a - p[i], n + 1))
    union(i + 1, mp.get(b - p[i], 0))

A = find(0)
B = find(n + 1)

if A != B:
    print('YES')
    print(' '.join(['1' if find(i) == B else '0' for i in range(1, n + 1)]))
else:
    print('NO')

import sys
from collections import defaultdict as dd
input = sys.stdin.readline
I = lambda : list(map(int,input().split()))

n,a,b=I()
l=I()
dic=dd(int)
for i in range(n):
	dic[l[i]]=1
bs=[]
pa=dd(int)
for i in range(n):
	if dic[a-l[i]]==0:
		bs.append(l[i])
	else:
		pa[l[i]]=a-l[i]
j=0
while j<len(bs):		
	for i in range(j,len(bs)):
		cr=bs[i]
		dic[cr]=2
		if dic[b-cr]==0:
			print("NO");return
		dic[b-cr]=2
		if dic[a-b+cr]==1:
			dic[a-b+cr]=2
			bs.append(a-b+cr)
		j+=1
		#ct=0;vt=a-b+cr
		#while vt!=pa[pa[vt]]:
		#	vt=pa[vt];dic[b-vt]=2
		#	dic[vt]=2
an=[0]*n
for i in range(n):
	an[i]=dic[l[i]]-1
print("YES")
print(*an)


import sys
from collections import defaultdict as dd
input = sys.stdin.readline
I = lambda : list(map(int,input().split()))

n,a,b=I()
l=I()
dic=dd(int)
for i in range(n):
	dic[l[i]]=1
bs=[]
pa=dd(int)
for i in range(n):
	if dic[a-l[i]]==0:
		bs.append(l[i])
	else:
		pa[l[i]]=a-l[i]
j=0
while j<len(bs):		
	for i in range(j,len(bs)):
		cr=bs[i]
		dic[cr]=2
		if dic[b-cr]==0:
			print("NO");return
		dic[b-cr]=2
		if dic[a-b+cr]==1:
			dic[a-b+cr]=2
			bs.append(a-b+cr)
		j+=1
		#ct=0;vt=a-b+cr
		#while vt!=pa[pa[vt]]:
		#	vt=pa[vt];dic[b-vt]=2
		#	dic[vt]=2
an=[0]*n
for i in range(n):
	an[i]=dic[l[i]]-1
print("YES")
print(*an)