You are given an undirected graph without self-loops or multiple edges which consists of $n$ vertices and $m$ edges. Also you are given three integers $n_1$, $n_2$ and $n_3$.

Can you label each vertex with one of three numbers 1, 2 or 3 in such way, that:   Each vertex should be labeled by exactly one number 1, 2 or 3;  The total number of vertices with label 1 should be equal to $n_1$;  The total number of vertices with label 2 should be equal to $n_2$;  The total number of vertices with label 3 should be equal to $n_3$;  $|col_u - col_v| = 1$ for each edge $(u, v)$, where $col_x$ is the label of vertex $x$. 

If there are multiple valid labelings, print any of them.


-----Input-----

The first line contains two integers $n$ and $m$ ($1 \le n \le 5000$; $0 \le m \le 10^5$) — the number of vertices and edges in the graph.

The second line contains three integers $n_1$, $n_2$ and $n_3$ ($0 \le n_1, n_2, n_3 \le n$) — the number of labels 1, 2 and 3, respectively. It's guaranteed that $n_1 + n_2 + n_3 = n$.

Next $m$ lines contan description of edges: the $i$-th line contains two integers $u_i$, $v_i$ ($1 \le u_i, v_i \le n$; $u_i \neq v_i$) — the vertices the $i$-th edge connects. It's guaranteed that the graph doesn't contain self-loops or multiple edges.


-----Output-----

If valid labeling exists then print "YES" (without quotes) in the first line. In the second line print string of length $n$ consisting of 1, 2 and 3. The $i$-th letter should be equal to the label of the $i$-th vertex.

If there is no valid labeling, print "NO" (without quotes).


-----Examples-----
Input
6 3
2 2 2
3 1
5 4
2 5

Output
YES
112323

Input
5 9
0 2 3
1 2
1 3
1 5
2 3
2 4
2 5
3 4
3 5
4 5

Output
NO

Difficulty: MEDIUM

Starter code:

Solutions:
(n, m) = map(int, input().split())
(x, y, z) = map(int, input().split())
ed = []
for _ in range(n):
	ed.append([])
for _ in range(m):
	(a, b) = map(int, input().split())
	a -= 1
	b -= 1
	ed[a].append(b)
	ed[b].append(a)
cl = [0] * n

def bfs(v, c):
	cl[v] = c
	h = w = 0
	if c == 1:
		h = 1
	else:
		w = 1
	for i in ed[v]:
		if cl[i] == c:
			return [False, h, w]
		elif cl[i] == 0:
			(f, hh, ww) = bfs(i, -c)
			h += hh
			w += ww
			if not f:
				return [False, h, w]
	return [True, h, w]
q = []
for i in range(n):
	if cl[i] == 0:
		(f, h, w) = bfs(i, 1)
		if not f:
			exit(print('NO'))
		q.append([i, min(h, w), max(h, w) - min(h, w), 1 - 2 * (h < w)])
yy = y
for (_, i, __, ___) in q:
	yy -= i
if yy < 0:
	exit(print('NO'))
dp = [(yy + 1) * [0] for _ in range(len(q) + 1)]
dp[0][0] = 1
for i in range(len(q)):
	(_, __, ii, ___) = q[i]
	for j in range(yy + 1):
		dp[i + 1][j] = dp[i][j]
	for j in range(yy + 1):
		if ii + j > yy:
			break
		dp[i + 1][ii + j] |= dp[i][j]
if dp[-1][-1] == 0:
	exit(print('NO'))
k = yy
qq = []
for i in range(len(q), 0, -1):
	if dp[i][k] == dp[i - 1][k]:
		qq.append((q[i - 1][0], -q[i - 1][3]))
	else:
		qq.append((q[i - 1][0], q[i - 1][3]))
		k -= q[i - 1][2]
cl = [0] * n
visited = set()
for (i, c) in qq:
	stack = [i]
	visited.add(i)
	cl[i] = c
	for j in stack:
		for k in ed[j]:
			if k in visited:
				continue
			visited.add(k)
			cl[k] = -cl[j]
			stack.append(k)
for i in range(n):
	if cl[i] == 1:
		cl[i] = '2'
	elif x:
		cl[i] = '1'
		x -= 1
	else:
		cl[i] = '3'
print('YES')
print(''.join(cl))


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 factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

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 comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')

def main():
	(n, m) = RL()
	(n1, n2, n3) = RL()
	gp = [[] for _ in range(n + 1)]
	for _ in range(m):
		(f, t) = RL()
		gp[f].append(t)
		gp[t].append(f)
	rec = [0] * (n + 1)
	arr = []
	parr = []

	def solve(node):
		q = deque()
		q.append((node, 1))
		cls = [-1] * (n + 1)
		cls[node] = 1
		while q:
			(nd, c) = q.popleft()
			rec[nd] = 1
			for nex in gp[nd]:
				if cls[nex] == c:
					return False
				if cls[nex] != -1:
					continue
				q.append((nex, c ^ 1))
				cls[nex] = c ^ 1
		b = w = 0
		for i in cls:
			if i == 1:
				b += 1
			elif i == 0:
				w += 1
		arr.append([b, w])
		parr.append(cls)
	for i in range(1, n + 1):
		if rec[i] == 0 and gp[i] != []:
			ret = solve(i)
			rec[i] = 1
			if ret == False:
				print('NO')
				break
	else:
		le = len(parr)
		dp = [[False] * (n2 + 1) for _ in range(le + 1)]
		dp[0][0] = True
		for i in range(1, le + 1):
			(a, b) = arr[i - 1]
			for j in range(1, n2 + 1):
				if j >= a and dp[i - 1][j - a] == True or (j >= b and dp[i - 1][j - b] == True):
					dp[i][j] = True
		if dp[-1][-1] or not arr:
			if not arr:
				res = '1' * n1 + '2' * n2 + '3' * n3
				print('YES')
				print(res)
			else:
				res = [1] * (n + 1)
				pre = n2
				for i in range(le, 0, -1):
					(a, b) = arr[i - 1]
					if dp[i - 1][pre - a]:
						pre -= a
						tag = 1
					elif dp[i - 1][pre - b]:
						pre -= b
						tag = 0
					for (ind, nd) in enumerate(parr[i - 1]):
						if tag == 0:
							if nd == 0:
								res[ind] = 2
							elif nd == 1:
								res[ind] = 1
						elif nd == 1:
							res[ind] = 2
						elif nd == 0:
							res[ind] = 1
				for i in range(1, len(res)):
					if res[i] != 2:
						if n1 <= 0:
							res[i] = 3
						n1 -= 1
					res[i] = str(res[i])
				print('YES')
				print(''.join(res[1:]))
		else:
			print('NO')
main()


import sys
sys.setrecursionlimit(10 ** 4)
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 MI1():
	return map(int1, 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]

def main():
	(n, m) = MI()
	(n1, n2, n3) = MI()
	to = [[] for _ in range(n)]
	for _ in range(m):
		(u, v) = MI1()
		to[u].append(v)
		to[v].append(u)

	def dfs(u, pu=-1, c=0):
		for v in to[u]:
			if v == pu:
				continue
			if color[v] == -1:
				color[v] = 1 - c
				cur[1 - c].append(v)
				if not dfs(v, u, 1 - c):
					return False
			elif (color[v] + c) % 2 == 0:
				return False
		return True
	color = [-1] * n
	cnt = []
	for u in range(n):
		if color[u] != -1:
			continue
		color[u] = 0
		cur = [[u], []]
		if not dfs(u):
			print('NO')
			exit()
		cnt.append(cur)
	cn = len(cnt)
	dp = [{} for _ in range(cn + 1)]
	dp[0] = {0: 0}
	for i in range(cn):
		for s in dp[i].keys():
			(k0, k1) = (len(cnt[i][0]), len(cnt[i][1]))
			if s + k0 <= n2:
				dp[i + 1][s + k0] = 0
			if s + k1 <= n2:
				dp[i + 1][s + k1] = 1
	if n2 not in dp[cn]:
		print('NO')
		exit()
	for i in range(cn, 0, -1):
		if dp[i][n2]:
			for j in range(2):
				for u in cnt[i - 1][j]:
					color[u] = 1 - color[u]
		n2 -= len(cnt[i - 1][dp[i][n2]])
	for u in range(n):
		if color[u] == 0:
			color[u] = 2
		elif n1 > 0:
			color[u] = 1
			n1 -= 1
		else:
			color[u] = 3
	print('YES')
	print(*color, sep='')
main()


import sys, math
import io, os
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.buffer.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')
mod = int(1000000000.0) + 7
(n, m) = mdata()
(n1, n2, n3) = mdata()
g = [[] for i in range(n + 1)]
for i in range(m):
	(u, v) = mdata()
	g[u].append(v)
	g[v].append(u)
vis = [0] * (n + 1)
v = [0] * (n + 1)
ans = [0] * (n + 1)
l1 = [1] * n1 + [3] * n3
dp = []
for i in range(1, n + 1):
	if vis[i] == 0:
		q = [i]
		l = [[], []]
		while q:
			s = q.pop()
			if vis[s] == 1:
				continue
			vis[s] = 1
			l[v[s]].append(s)
			for j in g[s]:
				if vis[j] == 0:
					v[j] = 1 - v[s]
					q.append(j)
				elif v[s] - v[j] == 0:
					out('NO')
					exit()
		if len(l[1]) > len(l[0]):
			(l[0], l[1]) = (l[1], l[0])
		dp.append(l)
dp.sort(key=lambda x: len(x[0]) - len(x[1]), reverse=True)
for l in dp:
	if max(len(l1), n2) < len(l[0]) or min(len(l1), n2) < len(l[1]):
		out('NO')
		exit()
	if len(l1) > n2:
		for i in l[0]:
			ans[i] = l1.pop()
		for i in l[1]:
			ans[i] = 2
		n2 -= len(l[1])
	else:
		for i in l[1]:
			ans[i] = l1.pop()
		for i in l[0]:
			ans[i] = 2
		n2 -= max(len(l[0]), len(l[1]))
out('YES')
outl(ans[1:])


import sys
sys.setrecursionlimit(10 ** 6)
readline = sys.stdin.readline
read = sys.stdin.read
ns = lambda : readline().rstrip()
ni = lambda : int(readline().rstrip())
nm = lambda : map(int, readline().split())
nl = lambda : list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
	(n, m) = nm()
	a = nl()
	G = [list() for _ in range(n)]
	for _ in range(m):
		(u, v) = nm()
		u -= 1
		v -= 1
		G[u].append(v)
		G[v].append(u)
	color = [-1] * n
	roots = list()

	def dfs(v, p):
		(siz, bla) = (1, color[v])
		for x in G[v]:
			if x == p:
				continue
			if color[x] < 0:
				color[x] = color[v] ^ 1
				(rs, rb) = dfs(x, v)
				siz += rs
				bla += rb
			elif color[x] == color[v]:
				print('NO')
				exit()
		return (siz, bla)
	for v in range(n):
		if color[v] < 0:
			color[v] = 0
			(siz, bla) = dfs(v, -1)
			roots.append((v, siz, bla))
	dp = [1] * (len(roots) + 1)
	for (i, (v, siz, bla)) in enumerate(roots):
		dp[i + 1] = dp[i] << bla | dp[i] << siz - bla
	if dp[len(roots)] >> a[1] & 1 == 0:
		print('NO')
		return
	cur = a[1]
	ans = [0] * n

	def dfs2(v, p, c):
		if c ^ color[v]:
			if a[0]:
				ans[v] = 1
				a[0] -= 1
			else:
				ans[v] = 3
				a[2] -= 1
		else:
			ans[v] = 2
			a[1] -= 1
		for x in G[v]:
			if not ans[x]:
				dfs2(x, v, c)
	for i in range(len(roots) - 1, -1, -1):
		(v, siz, bla) = roots[i]
		if cur >= bla and dp[i] >> cur - bla & 1:
			fl = 1
			cur -= bla
		else:
			fl = 0
			cur -= siz - bla
		dfs2(v, -1, fl)
	print('YES')
	print(*ans, sep='')
	return
solve()


mod = 1000000007
eps = 10 ** (-9)

def main():
	import sys
	from collections import deque
	input = sys.stdin.buffer.readline
	(N, M) = map(int, input().split())
	(n1, n2, n3) = map(int, input().split())
	adj = [[] for _ in range(N + 1)]
	for _ in range(M):
		(a, b) = map(int, input().split())
		adj[a].append(b)
		adj[b].append(a)
	seen = [-1] * (N + 1)
	BW = []
	for v0 in range(1, N + 1):
		if seen[v0] != -1:
			continue
		que = deque()
		que.append(v0)
		seen[v0] = 0
		B = [v0]
		W = []
		while que:
			v = que.popleft()
			for u in adj[v]:
				if seen[u] == -1:
					seen[u] = seen[v] ^ 1
					if seen[u] == 0:
						B.append(u)
					else:
						W.append(u)
					que.append(u)
				elif seen[u] == seen[v]:
					print('NO')
					exit()
		BW.append((B, W))
	G = len(BW)
	dp = [[0] * (n2 + 1) for _ in range(G + 1)]
	dp[0][0] = 1
	for i in range(G):
		b = len(BW[i][0])
		w = len(BW[i][1])
		for j in range(n2 + 1):
			if dp[i][j]:
				if j + b <= n2:
					dp[i + 1][j + b] = 1
				if j + w <= n2:
					dp[i + 1][j + w] = 1
	if not dp[-1][n2]:
		print('NO')
		exit()
	val = n2
	ans = [0] * (N + 1)
	for i in range(G - 1, -1, -1):
		b = len(BW[i][0])
		w = len(BW[i][1])
		ok = 0
		if val - b >= 0:
			if dp[i][val - b]:
				val -= b
				for v in BW[i][0]:
					ans[v] = 2
				ok = 1
		if not ok:
			if val - w >= 0:
				if dp[i][val - w]:
					val -= w
					for v in BW[i][1]:
						ans[v] = 2
	flg = n1
	for i in range(1, N + 1):
		if ans[i] == 0:
			if flg:
				ans[i] = 1
				flg -= 1
			else:
				ans[i] = 3
	print('YES')
	print(''.join(map(str, ans[1:])))
main()


def is_bipartite(s):
	n = len(graph)
	stack = [s]
	visited[s] = 0
	tmp = [s]
	cnt = [1, 0]
	while stack:
		v = stack.pop()
		for nxt_v in graph[v]:
			if visited[nxt_v] == -1:
				visited[nxt_v] = visited[v] ^ 1
				stack.append(nxt_v)
				tmp.append(nxt_v)
				cnt[visited[nxt_v]] += 1
			elif visited[nxt_v] ^ visited[v] == 0:
				return (False, (-1, -1), (-1, -1))
	return (True, cnt, tmp)
(n, m) = map(int, input().split())
(n1, n2, n3) = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]
graph = [[] for i in range(n)]
for (a, b) in info:
	a -= 1
	b -= 1
	graph[a].append(b)
	graph[b].append(a)
visited = [-1] * n
ans = []
inds = []
for i in range(n):
	if visited[i] == -1:
		(flag, cnt, ind) = is_bipartite(i)
		if flag:
			ans.append(cnt)
			inds.append(ind)
			continue
		else:
			print('NO')
			exit()
dp = [[False] * (n + 1) for i in range(len(ans) + 1)]
dp[0][0] = True
for i in range(len(ans)):
	(wei0, wei1) = ans[i]
	for w in range(n + 1):
		if w + wei0 < n + 1:
			dp[i + 1][w + wei0] = dp[i][w] or dp[i + 1][w + wei0]
		if w + wei1 < n + 1:
			dp[i + 1][w + wei1] = dp[i][w] or dp[i + 1][w + wei1]
if dp[-1][n2] == False:
	print('NO')
	exit()
c = n2
which = []
for i in range(len(ans))[::-1]:
	for (j, val) in enumerate(ans[i]):
		if c - val >= 0:
			if dp[i][c - val]:
				c = c - val
				which.append(j)
				break
which = which[::-1]
res = [-1] * n
for i in range(len(which)):
	whi = which[i]
	for ind in inds[i]:
		if visited[ind] == whi:
			res[ind] = 2
for i in range(n):
	if res[i] == -1:
		if n1 > 0:
			res[i] = 1
			n1 -= 1
		else:
			res[i] = 3
print('YES')
print(''.join(map(str, res)))


import sys
input = sys.stdin.buffer.readline
(N, M) = map(int, input().split())
(n1, n2, n3) = map(int, input().split())

def check():
	graph = [[] for _ in range(N)]
	for _ in range(M):
		(a, b) = map(int, input().split())
		graph[a - 1].append(b - 1)
		graph[b - 1].append(a - 1)
	Color = [-1] * N
	P = []
	ok = True
	for n in range(N):
		if Color[n] != -1:
			continue
		q = [n]
		Color[n] = 0
		Cs = [[n], []]
		while q:
			qq = []
			for p in q:
				for np in graph[p]:
					if Color[np] == -1:
						qq.append(np)
						Color[np] = Color[p] ^ 1
						Cs[Color[np]].append(np)
					elif Color[np] != Color[p] ^ 1:
						ok = False
						break
			q = qq
		P.append(Cs)
	return (ok, P)

def main():
	(ok, P) = check()
	dp = [[None] * (n2 + 1) for _ in range(len(P) + 1)]
	dp[0][0] = 0
	for i in range(len(P)):
		a = len(P[i][0])
		b = len(P[i][1])
		for n in range(n2 + 1):
			if not dp[i][n] is None:
				if n + a <= n2:
					dp[i + 1][n + a] = ~a
				if n + b <= n2:
					dp[i + 1][n + b] = b
	if not ok or dp[-1][n2] is None:
		print('NO')
	else:
		print('YES')
		tmp = n2
		Use2 = [-1] * N
		for i in reversed(range(len(P))):
			leng = dp[i + 1][tmp]
			label = 1
			if leng < 0:
				label = 0
				leng = ~leng
			for n in P[i][label]:
				Use2[n] = 1
			for n in P[i][label ^ 1]:
				Use2[n] = 0
			tmp -= leng
		ans = []
		num1 = 0
		for (n, use2) in enumerate(Use2):
			if use2:
				ans.append('2')
			elif num1 < n1:
				num1 += 1
				ans.append('1')
			else:
				ans.append('3')
		print(''.join(ans))
main()


(n, m) = map(int, input().split())
(n1, n2, n3) = map(int, input().split())
adj = [[] for _ in range(n)]
for _ in range(m):
	(a, b) = map(int, input().split())
	a -= 1
	b -= 1
	adj[a].append(b)
	adj[b].append(a)
color = [0] * n

def bfs(v, c):
	color[v] = c
	h = w = 0
	if c == 1:
		h = 1
	else:
		w = 1
	for nxt in adj[v]:
		if color[nxt] == c:
			return [False, h, w]
		elif color[nxt] == 0:
			(f, hh, ww) = bfs(nxt, -c)
			h += hh
			w += ww
			if not f:
				return [False, h, w]
	return [True, h, w]
q = []
for i in range(n):
	if color[i] == 0:
		(f, h, w) = bfs(i, 1)
		if not f:
			exit(print('NO'))
		q.append([i, min(h, w), abs(h - w), 1 - 2 * (h < w)])
remaining2 = n2
for (_, i, __, ___) in q:
	remaining2 -= i
if remaining2 < 0:
	exit(print('NO'))
dp = [(remaining2 + 1) * [0] for _ in range(len(q) + 1)]
dp[0][0] = 1
for i in range(len(q)):
	(_, __, ii, ___) = q[i]
	for j in range(remaining2 + 1):
		dp[i + 1][j] = dp[i][j]
	for j in range(remaining2 + 1):
		if ii + j > remaining2:
			break
		dp[i + 1][ii + j] |= dp[i][j]
if dp[-1][-1] == 0:
	exit(print('NO'))
k = remaining2
qq = []
for i in range(len(q), 0, -1):
	if dp[i][k] == dp[i - 1][k]:
		qq.append((q[i - 1][0], -q[i - 1][3]))
	else:
		qq.append((q[i - 1][0], q[i - 1][3]))
		k -= q[i - 1][2]
color = [0] * n
visited = set()
for (i, c) in qq:
	stack = [i]
	visited.add(i)
	color[i] = c
	for j in stack:
		for k in adj[j]:
			if k in visited:
				continue
			visited.add(k)
			color[k] = -color[j]
			stack.append(k)
for i in range(n):
	if color[i] == 1:
		color[i] = '2'
	elif n1:
		color[i] = '1'
		n1 -= 1
	else:
		color[i] = '3'
print('YES')
print(''.join(color))


from sys import stdin, stdout

def graph_coloring(n, n1, n2, n3, dic):
	s = [-1] * (n + 1)
	n13 = n1 + n3
	dp = []
	res = []
	ttlcnt = 0
	for i in range(1, n + 1):
		if s[i] != -1:
			continue
		v = dfs(i, 0, dic, s)
		l = len(v[0])
		r = len(v[1])
		if not v[2]:
			res.append('NO')
			return res
		ttlcnt += l + r
		cur = {}
		if len(dp) == 0:
			if l <= n2 and ttlcnt - l <= n13:
				cur[l] = [True, v[0]]
			if r <= n2 and ttlcnt - r <= n13:
				cur[r] = [True, v[1]]
		else:
			for k in dp[-1]:
				if k + l <= n2 and ttlcnt - k - l <= n13:
					cur[k + l] = [True, v[0]]
				if k + r <= n2 and ttlcnt - k - r <= n13:
					cur[k + r] = [True, v[1]]
		dp.append(cur)
	if n2 not in dp[-1]:
		res.append('NO')
	else:
		res.append('YES')
		c_a = [0] * n
		grp = len(dp)
		for grp in range(grp - 1, -1, -1):
			cnt = len(dp[grp][n2][1])
			for vtx in dp[grp][n2][1]:
				c_a[vtx - 1] = 2
			n2 -= cnt
		for i in range(len(c_a)):
			if c_a[i] == 0:
				if n1 > 0:
					c_a[i] = 1
					n1 -= 1
				elif n3 > 0:
					c_a[i] = 3
					n3 -= 1
		res.append(''.join(map(str, c_a)))
	return res

def dfs(vtx, color, dic, s):
	res = [[], [], True]
	if s[vtx] != -1:
		if s[vtx] != color:
			res[2] = False
		return res
	s[vtx] = color
	res[color].append(vtx)
	if vtx in dic:
		for nxt in dic[vtx]:
			subres = dfs(nxt, color ^ 1, dic, s)
			if not subres[2]:
				return [[], [], False]
			res[0].extend(subres[0])
			res[1].extend(subres[1])
	return res
(n, m) = map(int, stdin.readline().split())
(n1, n2, n3) = map(int, stdin.readline().split())
dic = {}
for _ in range(m):
	(u, v) = map(int, stdin.readline().split())
	if u not in dic:
		dic[u] = []
	if v not in dic:
		dic[v] = []
	dic[u].append(v)
	dic[v].append(u)
res_a = graph_coloring(n, n1, n2, n3, dic)
for res in res_a:
	stdout.write(res + '\n')


import os
import sys
if os.path.exists('/mnt/c/Users/Square/square/codeforces'):
	f = iter(open('E.txt').readlines())

	def input():
		return next(f).strip()
else:
	input = lambda : sys.stdin.readline()
fprint = lambda *args: print(*args, flush=True)
import math
try:
	(n, m) = map(int, input().split())
	g = {i: [] for i in range(n + 1)}
	(n1, n2, n3) = map(int, input().split())
	c = [-1] * (n + 1)
	for _ in range(m):
		(u, v) = map(int, input().split())
		g[u].append(v)
		g[v].append(u)
	num = 0
	S = []
	V = []
	for i in range(1, n + 1):
		if c[i] == -1:
			r = [0] * 2
			tmp = [[], []]
			c[i] = num
			r[c[i] % 2] += 1
			tmp[c[i] % 2].append(i)
			stack = [i]
			while stack:
				u = stack.pop()
				for v in g[u]:
					if c[v] == -1:
						c[v] = num + (c[u] + 1) % 2
						r[c[v] % 2] += 1
						tmp[c[v] % 2].append(v)
						stack.append(v)
					elif c[u] == c[v]:
						raise RuntimeError
			num += 10
			S.append(r)
			V.append(tmp)
	N = n + 1
	s = len(S) + 1
	d = [-2] * (N * s)
	d[0] = -1
	for (lev, (r1, r2)) in enumerate(S):
		add = lev * N + N
		for i in range(n):
			if d[i + lev * N] != -2:
				d[i + r1 + add] = lev
				d[i + r2 + add] = lev
	if d[N * (s - 1) + n2] == -2:
		raise RuntimeError
	cur = n2
	ords = []
	for (lev, (r1, r2)) in reversed(list(enumerate(S))):
		add = lev * N
		if cur - r1 >= 0 and d[add + cur - r1] == lev - 1:
			ords.append(0)
			cur -= r1
		else:
			ords.append(1)
			cur -= r2
	ords = list(reversed(ords))
	colors = ['0'] * (n + 1)
	for (o, r) in zip(ords, V):
		for col in r[o]:
			colors[col] = '2'
	for i in range(1, n + 1):
		if colors[i] == '0':
			if n1 > 0:
				colors[i] = '1'
				n1 -= 1
			else:
				colors[i] = '3'
	print('YES')
	print(''.join(colors[1:]))
except RuntimeError:
	print('NO')


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

def bfs(root):
	visited[root] = 0
	parity = [1, 0]
	store = [root]
	queue = deque([root])
	while queue:
		vertex = queue.popleft()
		for child in graph[vertex]:
			if visited[child] == -1:
				visited[child] = visited[vertex] ^ 1
				store.append(child)
				queue.append(child)
				parity[visited[child]] += 1
			elif visited[child] == visited[vertex]:
				return (False, (-1, -1), (-1, -1))
	return (True, parity, store)
(n, m) = map(int, input().split())
(n1, n2, n3) = map(int, input().split())
graph = defaultdict(list)
for i in range(m):
	(u, v) = map(int, input().split())
	u -= 1
	v -= 1
	graph[u].append(v)
	graph[v].append(u)
visited = [-1] * n
ans = []
ind = []
for i in range(n):
	if visited[i] == -1:
		(ret, ret2, ret3) = bfs(i)
		if not ret:
			print('NO')
			exit()
		ind.append(ret3)
		ans.append(ret2)
dp = [[False] * (n + 1) for _ in range(len(ans) + 1)]
dp[0][0] = True
for i in range(len(ans)):
	(even, odd) = (ans[i][0], ans[i][1])
	for j in range(len(dp[0])):
		if even + j < n + 1:
			dp[i + 1][j + even] = dp[i][j] or dp[i + 1][j + even]
		if odd + j < n + 1:
			dp[i + 1][j + odd] = dp[i][j] or dp[i + 1][j + odd]
if dp[-1][n2] == False:
	print('NO')
	exit()
c = n2
which = []
for i in range(len(ans))[::-1]:
	for (j, val) in enumerate(ans[i]):
		if c - val >= 0:
			if dp[i][c - val]:
				c = c - val
				which.append(j)
				break
which = which[::-1]
res = [-1] * n
for i in range(len(which)):
	whi = which[i]
	for indu in ind[i]:
		if visited[indu] == whi:
			res[indu] = 2
for i in range(n):
	if res[i] == -1:
		if n1 > 0:
			res[i] = 1
			n1 -= 1
		else:
			res[i] = 3
print('YES')
print(''.join(map(str, res)))


class UnionFind:

	def __init__(self, n):
		self.par = [i for i in range(n + 1)]
		self.rank = [0] * (n + 1)

	def find(self, x):
		if self.par[x] == x:
			return x
		else:
			self.par[x] = self.find(self.par[x])
			return self.par[x]

	def unite(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.rank[x] < self.rank[y]:
			self.par[x] = y
		else:
			self.par[y] = x
			if self.rank[x] == self.rank[y]:
				self.rank[x] += 1

	def same_check(self, x, y):
		return self.find(x) == self.find(y)
(n, m) = map(int, input().split())
(n1, n2, n3) = map(int, input().split())
uf = UnionFind(n)
g = [[] for _ in range(n)]
for _ in range(m):
	(a, b) = map(int, input().split())
	uf.unite(a - 1, b - 1)
	g[a - 1].append(b - 1)
	g[b - 1].append(a - 1)
d = dict()
ds = [-1] * n
idx = 0
c = []
c2 = []
l = []
for i in range(n):
	p = uf.find(i)
	if p in d:
		continue
	l.append(p)
	d[p] = idx
	idx += 1
	s = [p]
	ds[p] = 0
	cnt = 0
	cnt2 = 1
	while s:
		k = s.pop()
		for node in g[k]:
			if ds[node] == -1:
				s.append(node)
				ds[node] = ds[k] ^ 1
				cnt += ds[node]
				cnt2 += ds[node] ^ 1
			elif ds[node] != ds[k] ^ 1:
				print('NO')
				exit(0)
	c.append(cnt)
	c2.append(cnt2)
dp = [[False] * (n + 1) for _ in range(len(c) + 1)]
dp[0][0] = True
prv = [[0] * (n + 1) for _ in range(len(c) + 1)]
for i in range(len(c)):
	for j in range(n + 1):
		if j >= c[i]:
			dp[i + 1][j] |= dp[i][j - c[i]]
			if dp[i][j - c[i]]:
				prv[i + 1][j] = j - c[i]
		if j >= c2[i]:
			dp[i + 1][j] |= dp[i][j - c2[i]]
			if dp[i][j - c2[i]]:
				prv[i + 1][j] = j - c2[i]
if dp[-1][n2]:
	print('YES')
	ans = [-1] * n
	idx = n2
	for i in range(1, len(c) + 1):
		if idx - prv[-i][idx] == c[-i]:
			s = [l[-i]]
			while s:
				p = s.pop()
				ans[p] = ds[p] ^ 1
				for node in g[p]:
					if ans[node] == -1:
						s.append(node)
		else:
			s = [l[-i]]
			while s:
				p = s.pop()
				ans[p] = ds[p]
				for node in g[p]:
					if ans[node] == -1:
						s.append(node)
		idx = prv[-i][idx]
	cnt = 0
	for i in range(n):
		if ans[i] == 0:
			ans[i] = 2
		elif cnt < n1:
			ans[i] = 1
			cnt += 1
		else:
			ans[i] = 3
	print(''.join(map(str, ans)))
else:
	print('NO')


import sys
input = sys.stdin.readline
from collections import deque
(n, m) = map(int, input().split())
(n1, n2, n3) = map(int, input().split())
g = [[] for i in range(n)]
for _ in range(m):
	(u, v) = map(int, input().split())
	g[u - 1].append(v - 1)
	g[v - 1].append(u - 1)
seen = [-1] * n
BW = []
for v0 in range(n):
	if seen[v0] != -1:
		continue
	dq = deque([v0])
	B = [v0]
	W = []
	seen[v0] = 0
	while dq:
		ver = dq.popleft()
		for to in g[ver]:
			if seen[to] == -1:
				seen[to] = seen[ver] ^ 1
				if seen[to] == 0:
					B.append(to)
				else:
					W.append(to)
				dq.append(to)
			elif seen[to] == seen[ver]:
				print('NO')
				exit()
	BW.append((B, W))
l = len(BW)
dp = [[0] * (n2 + 1) for i in range(l + 1)]
dp[0][0] = 1
for i in range(l):
	b = len(BW[i][0])
	w = len(BW[i][1])
	for j in range(n2 + 1):
		if dp[i][j]:
			if j + b <= n2:
				dp[i + 1][j + b] = 1
			if j + w <= n2:
				dp[i + 1][j + w] = 1
if not dp[-1][n2]:
	print('NO')
	exit()
val = n2
ans = [0] * n
for i in range(l)[::-1]:
	b = len(BW[i][0])
	w = len(BW[i][1])
	ok = 0
	if val - b >= 0 and dp[i][val - b]:
		val -= b
		for v in BW[i][0]:
			ans[v] = 2
		ok = 1
	if not ok:
		if val - w >= 0:
			if dp[i][val - w]:
				val -= w
				for v in BW[i][1]:
					ans[v] = 2
flg = n1
for i in range(n):
	if ans[i] == 0:
		if flg:
			ans[i] = 1
			flg -= 1
		else:
			ans[i] = 3
print('YES')
print(''.join(map(str, ans)))


import os, sys
from io import BytesIO, IOBase
from collections import deque
from array import array

def main():
	(n, m) = map(int, input().split())
	(n1, n2, n3) = map(int, input().split())
	path = [array('i', []) for _ in range(n)]
	for _ in range(m):
		(u1, v1) = map(lambda xx: int(xx) - 1, input().split())
		path[u1].append(v1)
		path[v1].append(u1)
	(poi, visi, nums, cou) = (array('i', [0] * n), array('i', [0] * n), [], 0)
	for i in range(n):
		if visi[i]:
			continue
		cou += 1
		(visi[i], curr, su, zz) = (cou, deque([i]), [1, 0], [0] * n)
		while len(curr):
			x = curr.popleft()
			z = zz[x] ^ 1
			for y in path[x]:
				sig = -1 if z else 1
				if visi[y]:
					if visi[y] == sig * cou:
						continue
					print('NO')
					return
				(visi[y], zz[y]) = (sig * cou, z)
				su[z] += 1
				curr.append(y)
		nums.append((su[0], su[1]))
	dp = [array('b', [0] * (n2 + 1)) for _ in range(len(nums))]
	pr = [array('b', [0] * (n2 + 1)) for _ in range(len(nums))]
	for x in range(2):
		if nums[0][x] <= n2:
			dp[0][nums[0][x]] = 1
			pr[0][nums[0][x]] = x
	for i in range(1, len(nums)):
		for j in range(n2 + 1):
			if not dp[i - 1][j]:
				continue
			for x in range(2):
				if j + nums[i][x] <= n2:
					dp[i][j + nums[i][x]] = 1
					pr[i][j + nums[i][x]] = x
	if not dp[-1][n2]:
		print('NO')
	else:
		(x, arr) = (n2, {})
		for i in range(len(nums) - 1, -1, -1):
			arr[i] = pr[i][x]
			x -= nums[i][pr[i][x]]
		ans = [1] * n
		for i in range(n):
			z = arr[abs(visi[i]) - 1]
			if visi[i] > 0 and (not z) or (visi[i] < 0 and z):
				ans[i] = 2
			elif n3:
				ans[i] = 3
				n3 -= 1
		print('YES')
		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()


def col(i):
	if i == 1:
		return 2
	if i == 2:
		return 1
	return

def dfs(i, colour):
	visited[i] = colour
	stack = []
	stack.append(i)
	adj_vert[0].append(i)
	while stack:
		elem = stack.pop()
		for j in a[elem]:
			if visited[j] == visited[elem]:
				return -1
			elif visited[j] == 0:
				visited[j] = col(visited[elem])
				if visited[j] == colour:
					adj_vert[0].append(j)
				else:
					adj_vert[1].append(j)
				stack.append(j)
	return 0
(n, m) = [int(i) for i in input().split()]
(n1, n2, n3) = [int(i) for i in input().split()]
a = [[] for i in range(n)]
bad_flg = False
for i in range(m):
	(a1, a2) = [int(i) for i in input().split()]
	a[a1 - 1].append(a2 - 1)
	a[a2 - 1].append(a1 - 1)
visited = [0] * n
adj_comp = []
cnt = 0
for i in range(n):
	adj_vert = [[], []]
	if visited[i] == 0:
		cnt += 1
		res = dfs(i, 1)
		if res == -1:
			bad_flg = True
			break
		else:
			adj_comp.append(adj_vert)
if bad_flg:
	print('NO')
else:
	dp = [[-1] * (n + 1) for i in range(cnt + 1)]
	dp[0][0] = 1
	for i in range(1, cnt + 1):
		for j in range(n + 1):
			if dp[i - 1][j] > -1:
				if j + len(adj_comp[i - 1][0]) < n + 1:
					dp[i][j + len(adj_comp[i - 1][0])] = 0
				if j + len(adj_comp[i - 1][1]) < n + 1:
					dp[i][j + len(adj_comp[i - 1][1])] = 1
	if dp[cnt][n2] == -1:
		bad_flg = True
	if bad_flg:
		print('NO')
	else:
		ans = [[], []]
		j = n2
		for p in range(cnt, 0, -1):
			if dp[p][j] == 1:
				for i in adj_comp[p - 1][1]:
					ans[0].append(i)
				j -= len(adj_comp[p - 1][1])
			else:
				for i in adj_comp[p - 1][0]:
					ans[0].append(i)
				j -= len(adj_comp[p - 1][0])
		while n1 > 0:
			for i in range(n):
				if i not in ans[0]:
					n1 -= 1
					ans[1].append(i)
					if n1 == 0:
						break
		print('YES')
		for i in range(n):
			if i in ans[0]:
				print(2, end='')
			elif i in ans[1]:
				print(1, end='')
			else:
				print(3, end='')


import io
import os
from collections import Counter, defaultdict, deque

def bfs(source, graph):
	q = deque([source])
	dist = {source: 0}
	while q:
		node = q.popleft()
		d = dist[node]
		for nbr in graph[node]:
			if nbr not in dist:
				dist[nbr] = d + 1
				q.append(nbr)
	return dist

def solve(N, M, N1, N2, N3, edges):
	g = [[] for i in range(N + 1)]
	for (u, v) in edges:
		g[u].append(v)
		g[v].append(u)
	seen = set()
	comps = []
	for source in range(N):
		if source not in seen:
			compDist = bfs(source, g)
			layers = [[], []]
			for (u, d) in compDist.items():
				mod = d % 2
				for v in g[u]:
					if compDist[v] % 2 == mod:
						return 'NO'
				layers[mod].append(u)
			comps.append(layers)
			seen.update(compDist.keys())
	possible = [{0}]
	for comp in comps:
		nextPossible = set()
		for x in possible[-1]:
			for layer in comp:
				if x + len(layer) <= N2:
					nextPossible.add(x + len(layer))
		possible.append(nextPossible)
	if N2 not in possible[-1]:
		return 'NO'
	two = set()
	target = N2
	for i in range(len(possible) - 1, -1, -1):
		assert target in possible[i]
		for layer in comps[i - 1]:
			if target - len(layer) in possible[i - 1]:
				target -= len(layer)
				two.update(layer)
				break
	ans = []
	count = 0
	for u in range(N):
		if u in two:
			ans.append(2)
		elif count < N1:
			ans.append(1)
			count += 1
		else:
			ans.append(3)
	return 'YES' + '\n' + ''.join(map(str, ans))
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(N, M) = [int(x) for x in input().split()]
(N1, N2, N3) = [int(x) for x in input().split()]
edges = [[int(x) - 1 for x in input().split()] for i in range(M)]
ans = solve(N, M, N1, N2, N3, edges)
print(ans)


import sys
input = sys.stdin.readline
flush = sys.stdout.flush
(n, m) = map(int, input().split())
(n1, n2, n3) = map(int, input().split())
nbhd = [[] for _ in range(n)]
for _ in range(m):
	(u, v) = map(int, input().split())
	nbhd[u - 1].append(v - 1)
	nbhd[v - 1].append(u - 1)
color = [None] * n
bipar = []
for v in range(n):
	if color[v] is not None:
		continue
	color[v] = 0
	cnt = [[], []]
	cnt[0].append(v)
	S = [v]
	while S != []:
		w = S.pop()
		for u in nbhd[w]:
			if color[u] is None:
				color[u] = color[w] ^ 1
				S.append(u)
				cnt[color[u]].append(u)
	bipar.append(cnt)
for i in range(n):
	for j in nbhd[i]:
		if color[i] == color[j]:
			print('NO')
			quit()
k = len(bipar)
ddp = [[False] * (n2 + 1) for _ in range(k + 1)]
ddp[0][0] = True
for i in range(1, k + 1):
	for j in range(n2 + 1):
		if j >= len(bipar[i - 1][0]) and ddp[i - 1][j - len(bipar[i - 1][0])]:
			ddp[i][j] = True
		if j >= len(bipar[i - 1][1]) and ddp[i - 1][j - len(bipar[i - 1][1])]:
			ddp[i][j] = True
if not ddp[k][n2]:
	print('NO')
	quit()
idx = [None] * k
temp = n2
for i in reversed(range(k)):
	if temp - len(bipar[i][0]) >= 0 and ddp[i][temp - len(bipar[i][0])]:
		idx[i] = 0
		temp -= len(bipar[i][0])
	elif temp - len(bipar[i][1]) >= 0 and ddp[i][temp - len(bipar[i][1])]:
		idx[i] = 1
		temp -= len(bipar[i][1])
color = [3] * n
for (i, x) in enumerate(bipar):
	for y in x[idx[i]]:
		color[y] = 2
for i in range(n):
	if n1 == 0:
		break
	if color[i] == 3:
		color[i] = 1
		n1 -= 1
print('YES')
print(*color, sep='')


import math

class Bags:

	def __init__(self):
		self.dictNodeColor = {}
		self.numOnes = 0
		self.numTwos = 0

def DFS(node, color, bags, visited):
	if visited[node] and bags.dictNodeColor[node] != color:
		return True
	if visited[node]:
		return False
	bags.dictNodeColor[node] = color
	if color == 1:
		bags.numOnes = bags.numOnes + 1
	else:
		bags.numTwos = bags.numTwos + 1
	visited[node] = True
	cycle = False
	if not node in dictGraph:
		return False
	for n in dictGraph[node]:
		if color == 1:
			cycle = DFS(n, 2, bags, visited)
		else:
			cycle = DFS(n, 1, bags, visited)
		if cycle:
			break
	return cycle
dictGraph = {}
t = 1
for testcase in range(t):
	(numVertices, numEdges) = map(int, input().split())
	(n1, n2, n3) = map(int, input().split())
	dictGraph = {}
	for i in range(numEdges):
		(u, v) = map(int, input().split())
		u = u - 1
		v = v - 1
		if u in dictGraph:
			dictGraph[u] = dictGraph[u] + [v]
		else:
			dictGraph[u] = [v]
		if v in dictGraph:
			dictGraph[v] = dictGraph[v] + [u]
		else:
			dictGraph[v] = [u]
	visited = [False] * numVertices
	allBags = []
	cycle = False
	for i in range(numVertices):
		if visited[i] == False:
			b = Bags()
			rs = DFS(i, 1, b, visited)
			allBags.append(b)
			if rs == True:
				cycle = True
				break
	if cycle:
		print('NO')
	else:
		cols = n2
		rows = len(allBags)
		dp = [[-1 for cc in range(cols + 1)] for rr in range(rows)]
		for col in range(cols + 1):
			if allBags[0].numOnes == col:
				dp[0][col] = allBags[0].numOnes
			if allBags[0].numTwos == col:
				dp[0][col] = allBags[0].numTwos
		for row in range(1, rows):
			i1 = allBags[row].numOnes
			i2 = allBags[row].numTwos
			for col in range(cols + 1):
				if col - i1 >= 0 and dp[row - 1][col - i1] != -1:
					dp[row][col] = i1
				elif col - i2 >= 0 and dp[row - 1][col - i2] != -1:
					dp[row][col] = i2
		if dp[rows - 1][cols] == -1:
			print('NO')
		else:
			print('YES')
			dictAnswer = {}
			counter = len(allBags) - 1
			r = rows - 1
			c = cols
			while counter > -1:
				number = dp[r][c]
				bag = allBags[counter]
				twos = 2
				if bag.numOnes == number:
					twos = 1
				for key in bag.dictNodeColor:
					if bag.dictNodeColor[key] == twos:
						dictAnswer[key] = 2
					elif n1 > 0:
						dictAnswer[key] = 1
						n1 = n1 - 1
					else:
						dictAnswer[key] = 3
				counter = counter - 1
				r = r - 1
				c = c - number
			answer = ''
			for i in range(numVertices):
				answer += str(dictAnswer[i])
			print(answer)


graph = [[] for i in range(5006)]

def main():
	(n, m) = map(int, input().split())
	(n1, n2, n3) = map(int, input().split())
	for i in range(m):
		(x, y) = map(int, input().split())
		graph[x].append(y)
		graph[y].append(x)
	graphColoring(n, n1, n2)

def graphColoring(n, n1, n2):
	color = [None] * (n + 1)
	bipartitions = []
	for v in range(1, n + 1):
		if color[v] is not None:
			continue
		color[v] = 0
		connectedComponents = [[], []]
		connectedComponents[0].append(v)
		S = [v]
		while S != []:
			w = S.pop()
			for u in graph[w]:
				if color[u] is not None:
					if color[u] == color[w]:
						print('NO')
						return
					else:
						continue
				color[u] = color[w] ^ 1
				S.append(u)
				connectedComponents[color[u]].append(u)
		bipartitions.append(connectedComponents)
	answer(bipartitions, n1, n2, n)

def answer(bipartitions, n1, n2, n):
	k = len(bipartitions)
	mat = [[False] * (n2 + 1) for _ in range(k + 1)]
	mat[0][0] = True
	for i in range(1, k + 1):
		for j in range(n2 + 1):
			if j >= len(bipartitions[i - 1][0]) and mat[i - 1][j - len(bipartitions[i - 1][0])]:
				mat[i][j] = True
			if j >= len(bipartitions[i - 1][1]) and mat[i - 1][j - len(bipartitions[i - 1][1])]:
				mat[i][j] = True
	if not mat[k][n2]:
		print('NO')
		return
	idx = [0] * k
	temp = n2
	for i in reversed(range(k)):
		if temp - len(bipartitions[i][0]) >= 0 and mat[i][temp - len(bipartitions[i][0])]:
			idx[i] = 0
			temp -= len(bipartitions[i][0])
		elif temp - len(bipartitions[i][1]) >= 0 and mat[i][temp - len(bipartitions[i][1])]:
			idx[i] = 1
			temp -= len(bipartitions[i][1])
	color = [0] * (n + 1)
	for i in range(0, len(bipartitions)):
		if idx[i] == 1:
			while len(bipartitions[i][1]) > 0:
				w = bipartitions[i][1].pop()
				color[w] = 1
		else:
			while len(bipartitions[i][0]) > 0:
				w = bipartitions[i][0].pop()
				color[w] = 1
	res = ''
	for i in range(1, n + 1):
		if color[i]:
			res += str(2)
		elif n1 > 0:
			res += str(1)
			n1 -= 1
		else:
			res += str(3)
	print('YES')
	print(res)
main()


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

def bfs(s):
	color[s] = 1
	q = deque([s])
	d[s][1].append(s)
	while q:
		v = q.popleft()
		for nv in G[v]:
			if color[nv] == 0:
				color[nv] = -color[v]
				q.append(nv)
				if color[nv] == 1:
					d[s][1].append(nv)
				else:
					d[s][0].append(nv)
			elif color[nv] == color[v]:
				return (-1, -1)
	return (len(d[s][1]), len(d[s][0]))
(n, m) = map(int, input().split())
(n1, n2, n3) = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
	(u, v) = map(int, input().split())
	G[u - 1].append(v - 1)
	G[v - 1].append(u - 1)
d = defaultdict(lambda : defaultdict(list))
color = [0] * n
sta = []
bw = []
for i in range(n):
	if color[i] == 0:
		(b, w) = bfs(i)
		if b == -1:
			print('NO')
			exit()
		sta.append(i)
		bw.append((b, w))
dp = [[-1] * (n + 1) for _ in range(len(bw) + 1)]
dp[0][0] = True
for i in range(len(bw)):
	for j in range(n + 1):
		if dp[i][j] == -1:
			continue
		dp[i + 1][j + bw[i][0]] = 0
		dp[i + 1][j + bw[i][1]] = 1
if dp[-1][n2] == -1:
	print('NO')
	exit()
ans = [''] * n
for i in range(len(bw), 0, -1):
	if dp[i][n2] == 0:
		for v in d[sta[i - 1]][1]:
			ans[v] = '2'
		n2 -= bw[i - 1][0]
	else:
		for v in d[sta[i - 1]][0]:
			ans[v] = '2'
		n2 -= bw[i - 1][1]
for v in range(n):
	if ans[v] == '':
		if n1 > 0:
			ans[v] = '1'
			n1 -= 1
		else:
			ans[v] = '3'
print('YES')
print(''.join(ans))


import sys
input = sys.stdin.readline
from collections import defaultdict as dd, deque as dq
d = dd(list)
comp_b = dd(list)
comp_w = dd(list)
(n, m) = map(int, input().split())
(n1, n2, n3) = map(int, input().split())
color = [-1] * (n + 1)

def bfs(u, iid):
	q = dq([u])
	color[u] = 0
	comp_b[iid].append(u)
	while q:
		a = q.pop()
		for i in d[a]:
			if color[i] == -1:
				col = 1 - color[a]
				color[i] = col
				if col == 0:
					comp_b[iid].append(i)
				else:
					comp_w[iid].append(i)
				q.appendleft(i)
			elif color[i] == color[a]:
				return False
	return True
for i in range(m):
	(u, v) = map(int, input().split())
	d[u].append(v)
	d[v].append(u)
iid = 1
for i in range(1, n + 1):
	if color[i] == -1:
		if not bfs(i, iid):
			print('NO')
			exit()
		iid += 1
dp = [[False] * (n + 1) for i in range(iid)]
dp[0][0] = True
for i in range(1, iid):
	for j in range(n2 + 1):
		if j >= len(comp_b[i]) and dp[i - 1][j - len(comp_b[i])]:
			dp[i][j] = True
		if j >= len(comp_w[i]) and dp[i - 1][j - len(comp_w[i])]:
			dp[i][j] = True
if dp[iid - 1][n2] == False:
	print('NO')
	exit()
res = [0] * (n + 1)
cur = n2
for i in range(iid - 1, 0, -1):
	if cur >= len(comp_b[i]) and dp[i - 1][cur - len(comp_b[i])]:
		for j in comp_b[i]:
			res[j] = 2
			cur -= 1
	else:
		for j in comp_w[i]:
			res[j] = 2
			cur -= 1
print('YES')
for i in range(1, n + 1):
	if res[i] == 0:
		if n1:
			res[i] = 1
			n1 -= 1
		else:
			res[i] = 3
	print(res[i], end='')


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
from typing import List
INF = 10 ** 6 + 10

def solve(N, M, G, A, B, C):
	if M == 0:
		return ['YES', '1' * A + '2' * B + '3' * C]
	vis = [0 for _ in range(N + 1)]
	marks = [0 for _ in range(N + 1)]

	def bfs(u, mark, idx):
		q = [(u, mark)]
		vis[u] = idx
		(a, b) = (0, 0)
		while q:
			nq = []
			for (u, mark) in q:
				marks[u] = mark
				a += mark ^ 1
				b += 1
				for v in G[u]:
					if vis[v] == 0:
						vis[v] = idx
						nq.append((v, mark ^ 1))
					elif marks[u] == marks[v]:
						return (INF, 2 * INF)
			q = nq
		return (a, b)
	groupId = 1
	colors = []
	for i in range(1, N + 1):
		if vis[i] > 0:
			continue
		(a, b) = bfs(i, 0, groupId)
		if a >= INF:
			return ['NO']
		colors.append((a, b - a))
		groupId += 1
	NC = len(colors)
	dp = [[-1 for _ in range(2 * N + 1)] for _ in range(NC + 1)]
	dp[0][0] = 0
	for i in range(NC):
		(a, b) = colors[i]
		for j in range(N + 1):
			if dp[i][j] != -1:
				dp[i + 1][j + a] = 0
				dp[i + 1][j + b] = 1
	if dp[NC][B] == -1:
		return ['NO']
	select = []
	(i, j) = (NC, B)
	while i > 0:
		select.append(dp[i][j])
		(i, j) = (i - 1, j - colors[i - 1][dp[i][j]])
	select = select[::-1]
	for i in range(1, N + 1):
		if select[vis[i] - 1] == 1:
			marks[i] ^= 1
	for i in range(1, N + 1):
		if marks[i] == 0:
			marks[i] = 2
		elif A > 0:
			marks[i] = 1
			A -= 1
		else:
			marks[i] = 3
	return ['YES', ''.join(map(str, marks[1:]))]
(N, M) = map(int, input().split())
(A, B, C) = map(int, input().split())
G = collections.defaultdict(list)
for i in range(M):
	(u, v) = map(int, input().split())
	G[u].append(v)
	G[v].append(u)
print('\n'.join(solve(N, M, G, A, B, C)))


from sys import stdin, gettrace
from collections import deque
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():
	(n, m) = map(int, input().split())
	(n1, n2, n3) = map(int, input().split())
	adj = [[] for _ in range(n)]
	for _ in range(m):
		(u, v) = map(int, input().split())
		adj[u - 1].append(v - 1)
		adj[v - 1].append(u - 1)
	components = []
	grp = [-1] * n
	for i in range(n):
		if grp[i] == -1:
			q = deque()
			q.append(i)
			grp[i] = 0
			components.append([[i], []])
			while q:
				u = q.popleft()
				for v in adj[u]:
					if grp[v] == -1:
						grp[v] = 1 - grp[u]
						components[-1][grp[v]].append(v)
						q.append(v)
					elif grp[v] == grp[u]:
						print('NO')
						return
	dp = [[0 for _ in range(n + 2)] for _ in range(len(components))]
	dp[0][len(components[0][0]) + 1] = -1
	dp[0][len(components[0][1]) + 1] = 1
	for (i, comp) in enumerate(components[1:]):
		l0 = len(comp[0])
		l1 = len(comp[1])
		for j in range(1, n2 + 2):
			if dp[i][j]:
				dp[i + 1][j + l0] = -j
				dp[i + 1][j + l1] = j
	if not dp[-1][n2 + 1]:
		print('NO')
		return
	print('YES')
	j = n2 + 1
	colour = ['x'] * n
	for i in range(len(components) - 1, -1, -1):
		g = 0 if dp[i][j] < 0 else 1
		j = abs(dp[i][j])
		for u in components[i][g]:
			colour[u] = '2'
		for u in components[i][1 - g]:
			if n1 > 0:
				colour[u] = '1'
				n1 -= 1
			else:
				colour[u] = '3'
	print(''.join(colour))
main()


import sys
input = sys.stdin.readline
(N, M) = map(int, input().split())
(n1, n2, n3) = map(int, input().split())
G = [set() for _ in range(N + 1)]
for _ in range(M):
	(u, v) = map(int, input().split())
	G[u].add(v)
	G[v].add(u)
cl = [-1 for _ in range(N + 1)]
vs = set()
Y = []
for i in range(1, N + 1):
	if i in vs:
		continue
	cl[i] = 0
	tmp = [[i], []]
	stack = [i]
	vs.add(i)
	while stack:
		v = stack.pop()
		for u in G[v]:
			if cl[u] == cl[v]:
				print('NO')
				sys.exit()
			if u in vs:
				continue
			cl[u] = 1 - cl[v]
			tmp[cl[u]].append(u)
			vs.add(u)
			stack.append(u)
	Y.append(tmp)
k = len(Y)
dp = [[0] * (N + 1) for _ in range(k + 1)]
dp[0][0] = 1
for i in range(k):
	(y1, y2) = (len(Y[i][0]), len(Y[i][1]))
	for j in range(N, -1, -1):
		tmp = 0
		if j - y1 >= 0:
			tmp = dp[i][j - y1]
		if j - y2 >= 0:
			tmp = dp[i][j - y2] | tmp
		dp[i + 1][j] = tmp
if dp[-1][n2] == 0:
	print('NO')
	sys.exit()
mch = n2
ans = [0] * (N + 1)
for i in range(k - 1, -1, -1):
	(y1, y2) = (len(Y[i][0]), len(Y[i][1]))
	if mch >= y1 and dp[i][mch - y1]:
		for u in Y[i][0]:
			ans[u] = 2
		for u in Y[i][1]:
			if n1 > 0:
				ans[u] = 1
				n1 -= 1
			else:
				ans[u] = 3
		mch -= y1
	else:
		for u in Y[i][0]:
			if n1 > 0:
				ans[u] = 1
				n1 -= 1
			else:
				ans[u] = 3
		for u in Y[i][1]:
			ans[u] = 2
		mch -= y2
print('YES')
print(''.join((str(u) for u in ans[1:])))


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 prod(a, mod=10 ** 9 + 7):
	ans = 1
	for each in a:
		ans = ans * each % mod
	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 not True else 1):
	(n, m) = map(int, input().split())
	(n1, n2, n3) = map(int, input().split())
	graph = [[] for __ in range(n + 1)]
	for __ in range(m):
		(x, y) = map(int, input().split())
		graph[x] += [y]
		graph[y] += [x]

	def dfs(graph, alpha):
		n = len(graph)
		stack = [alpha]
		colors[alpha] = 1
		p1 = 1
		comp = []
		while stack:
			v = stack[-1]
			if not visited[v]:
				visited[v] = True
				for u in graph[v]:
					if not visited[u]:
						stack.append(u)
					if colors[u] == -1:
						colors[u] = 1 - colors[v]
						if colors[u] == 1:
							p1 += 1
					if colors[u] != 1 - colors[v]:
						return (False, None)
			else:
				comp += [stack.pop()]
		return (comp, p1)
	visited = [False] * (n + 1)
	pos = True
	colors = [-1] * (n + 1)
	components = []
	(req, extra) = (0, [])
	for i in range(1, n + 1):
		if not visited[i]:
			(x, p1) = dfs(graph, i)
			if not x:
				pos = False
				break
			components += [x]
			p2 = len(x) - p1
			req += min(p1, p2)
			if p1 != p2:
				extra += [abs(p1 - p2)]
	target = n2 - req

	def check_subset_sum(a, n):
		dp = [[]] * (n + 1)
		for i in range(len(a)):
			for j in range(n, a[i] - 1, -1):
				if j == a[i]:
					dp[j] = [a[i]]
				elif dp[j]:
					continue
				elif dp[j - a[i]]:
					dp[j] = dp[j - a[i]] + [a[i]]
		return dp[-1]
	dp = []
	if target >= 0:
		dp = check_subset_sum(extra, target)
	if pos and sum(dp) == target:
		print('YES')
		ans = [1] * (n + 1)
		for comp in components:
			odd = [i for i in comp if colors[i] == 1]
			even = [i for i in comp if colors[i] == 0]
			if len(odd) == len(even):
				for k in odd:
					ans[k] = 2
			else:
				if len(even) > len(odd):
					(odd, even) = (list(even), list(odd))
				if len(odd) - len(even) in dp:
					dp.remove(len(odd) - len(even))
					for k in odd:
						ans[k] = 2
				else:
					for k in even:
						ans[k] = 2
		if ans.count(2) != n2:
			print(0 / 0)
		for i in range(1, n + 1):
			if not n3:
				break
			if ans[i] == 1:
				n3 -= 1
				ans[i] = 3
		print(*ans[1:], sep='')
	else:
		print('NO')


(n, m) = map(int, input().split())
(n1, n2, n3) = map(int, input().split())
edge = [[] for i in range(n)]
for i in range(m):
	(u, v) = map(int, input().split())
	edge[u - 1].append(v - 1)
	edge[v - 1].append(u - 1)
ans = []

def is_bipartgraph():
	color = [0] * n
	used = [False] * n
	for i in range(n):
		if not used[i]:
			stack = [(i, 1)]
			black = []
			white = []
			while stack:
				(v, c) = stack.pop()
				if not used[v]:
					color[v] = c
					if c == 1:
						black.append(v)
					else:
						white.append(v)
					used[v] = True
					for nv in edge[v]:
						if color[nv] == color[v]:
							return False
						elif color[nv] == 0:
							stack.append((nv, -c))
			ans.append([black, white])
	return True
if is_bipartgraph():
	dp = [[False for i in range(0, n2 + 1)] for j in range(len(ans))]
	if n2 >= len(ans[0][0]):
		dp[0][len(ans[0][0])] = True
	if n2 >= len(ans[0][1]):
		dp[0][len(ans[0][1])] = True
	for i in range(1, len(ans)):
		for j in range(n2 + 1):
			test = False
			if j >= len(ans[i][0]):
				test = test | dp[i - 1][j - len(ans[i][0])]
			if j >= len(ans[i][1]):
				test = test | dp[i - 1][j - len(ans[i][1])]
			dp[i][j] = test
	if dp[-1][n2]:
		even = []
		odd = []
		for i in range(len(ans) - 1, 0, -1):
			if dp[i - 1][n2 - len(ans[i][0])] and n2 >= len(ans[i][0]):
				even += ans[i][0]
				odd += ans[i][1]
				n2 -= len(ans[i][0])
			else:
				even += ans[i][1]
				odd += ans[i][0]
				n2 -= len(ans[i][1])
		if len(ans[0][0]) == n2:
			even += ans[0][0]
			odd += ans[0][1]
		else:
			even += ans[0][1]
			odd += ans[0][0]
		ans = ['' for i in range(n)]
		for i in even:
			ans[i] = '2'
		count = 0
		while odd:
			i = odd.pop()
			if n1 > count:
				ans[i] = '1'
				count += 1
			else:
				ans[i] = '3'
		print('YES')
		print(''.join(ans))
	else:
		print('NO')
else:
	print('NO')


import sys

def input():
	return sys.stdin.readline().rstrip()
(n, m) = [int(i) for i in input().split()]
(n1, n2, n3) = [int(i) for i in input().split()]
num1 = n1 + n3
num2 = n2
nbrs = [[] for i in range(n)]
for _ in range(m):
	(u, v) = [int(i) for i in input().split()]
	u -= 1
	v -= 1
	nbrs[u].append(v)
	nbrs[v].append(u)

def dfs(nbrs, colors, i, color, blacks, whites, components, component_num):
	colors[i] = color
	components[i] = component_num
	if color > 0:
		blacks += 1
	else:
		whites += 1
	flag = False
	for nbr in nbrs[i]:
		if colors[nbr] == 0:
			result = dfs(nbrs, colors, nbr, -color, blacks, whites, components, component_num)
			if result is None:
				return None
			(blacks, whites) = result
		elif colors[nbr] == color:
			flag = True
			break
	if flag:
		return None
	return (blacks, whites)
colors = [0 for i in range(n)]
component_counts = []
components = [-1 for i in range(n)]
for i in range(n):
	if colors[i] == 0:
		result = dfs(nbrs, colors, i, 1, 0, 0, components, len(component_counts))
		if result is None:
			print('NO')
			raise SystemExit(0)
		(blacks, whites) = result
		component_counts.append((blacks, whites))
num_components = len(component_counts)
defaults = []
subset_prob = []
minimum = 0
for (b, w) in component_counts:
	if b <= w:
		defaults.append(True)
	else:
		defaults.append(False)
	subset_prob.append(abs(b - w))
	minimum += min(b, w)
a = subset_prob
X = [[False for i in range(num_components + 1)] for j in range(n + 1)]
for i in range(num_components + 1):
	X[0][i] = True
for i in range(n):
	X[i + 1][0] = False
for i in range(1, n + 1):
	for j in range(1, num_components + 1):
		X[i][j] = X[i][j] or X[i][j - 1]
		if i - a[j - 1] >= 0:
			X[i][j] = X[i][j] or X[i - a[j - 1]][j - 1]
to_split = 0
aim = max(n1 + n3, n2) - minimum
if aim < 0:
	print('NO')
elif not X[aim][num_components]:
	print('NO')
else:
	chosen = aim
	used = [False for i in range(num_components)]
	pending_target = chosen
	for j in range(1, num_components + 1):
		in_question = num_components - j + 1
		if not X[pending_target][in_question - 1]:
			used[in_question - 1] = True
			pending_target = pending_target - a[in_question - 1]
	for i in range(num_components):
		if used[i]:
			defaults[i] = not defaults[i]
	count1 = 0
	for i in range(n):
		if not defaults[components[i]]:
			colors[i] = -colors[i]
		if colors[i] == 1:
			count1 += 1
	if count1 == n1 + n3:
		choice_for = 1
	else:
		choice_for = -1
	ans = ''
	pending_3 = n3
	for i in range(n):
		if colors[i] != choice_for:
			ans += '2'
		elif pending_3 > 0:
			ans += '3'
			pending_3 -= 1
		else:
			ans += '1'
	print('YES')
	print(ans)


import sys
input_ = sys.stdin
(n, m) = map(int, input_.readline().split())
(n1, n2, n3) = map(int, input_.readline().split())
c = 0
E = []
for i in range(n):
	E.append([])
for i in range(m):
	(a, b) = map(int, input_.readline().split())
	E[a - 1].append(b - 1)
	E[b - 1].append(a - 1)
color = [-1 for i in range(n)]
cc = [i for i in range(n)]
cc_f = []

def odfs(c):
	for v in range(n):
		if color[v] == -1:
			cc_f.append([[], []])
			cc[v] = v
			color[v] = 0
			cc_f[c][color[v]].append(v)
			aux = odfs_C(v, 0, c)
			c = c + 1
			if aux == 0:
				return 0
	return 1

def odfs_C(v, cl, c):
	for u in E[v]:
		if color[u] == -1:
			cc[u] = cc[v]
			color[u] = (cl + 1) % 2
			cc_f[c][color[u]].append(u)
			aux = odfs_C(u, (cl + 1) % 2, c)
			if aux == 0:
				return 0
		elif color[u] == cl:
			return 0
	return 1

def reconstruct_sol():
	aux = n2
	for i in range(len(cc_f)):
		cc_aux = cc_f[-(i + 1)]
		if aux - len(cc_aux[0]) >= 0 and dp[-(i + 2)][aux - len(cc_aux[0])] != -1:
			aux -= len(cc_aux[0])
			for v in cc_aux[0]:
				color[v] = 2
		else:
			aux -= len(cc_aux[1])
			for v in cc_aux[1]:
				color[v] = 2
	cont = 0
	s = ''
	for v in range(n):
		if color[v] != 2:
			if cont < n1:
				color[v] = 1
				cont += 1
			else:
				color[v] = 3
		s += str(color[v])
	print(s)
sol = odfs(0)
if sol == 1:
	dp = [[] for i in range(len(cc_f) + 1)]
	for i in range(len(dp)):
		for j in range(n2 + 1):
			dp[i].append(-1)
	dp[0][0] = 1
	for (i, item) in enumerate(cc_f):
		for j in range(n2 + 1):
			if dp[i][j] != -1:
				if j + len(item[0]) <= n2:
					dp[i + 1][j + len(item[0])] = 1
				if j + len(item[1]) <= n2:
					dp[i + 1][j + len(item[1])] = 1
	if dp[len(cc_f)][n2] == 1:
		print('YES')
		reconstruct_sol()
	else:
		print('NO')
else:
	print('NO')