Today Johnny wants to increase his contribution. His plan assumes writing $n$ blogs. One blog covers one topic, but one topic can be covered by many blogs. Moreover, some blogs have references to each other. Each pair of blogs that are connected by a reference has to cover different topics because otherwise, the readers can notice that they are split just for more contribution. Set of blogs and bidirectional references between some pairs of them is called blogs network.

There are $n$ different topics, numbered from $1$ to $n$ sorted by Johnny's knowledge. The structure of the blogs network is already prepared. Now Johnny has to write the blogs in some order. He is lazy, so each time before writing a blog, he looks at it's already written neighbors (the blogs referenced to current one) and chooses the topic with the smallest number which is not covered by neighbors. It's easy to see that this strategy will always allow him to choose a topic because there are at most $n - 1$ neighbors.

For example, if already written neighbors of the current blog have topics number $1$, $3$, $1$, $5$, and $2$, Johnny will choose the topic number $4$ for the current blog, because topics number $1$, $2$ and $3$ are already covered by neighbors and topic number $4$ isn't covered.

As a good friend, you have done some research and predicted the best topic for each blog. Can you tell Johnny, in which order he has to write the blogs, so that his strategy produces the topic assignment chosen by you?


-----Input-----

The first line contains two integers $n$ $(1 \leq n \leq 5 \cdot 10^5)$ and $m$ $(0 \leq m \leq 5 \cdot 10^5)$ — the number of blogs and references, respectively.

Each of the following $m$ lines contains two integers $a$ and $b$ ($a \neq b$; $1 \leq a, b \leq n$), which mean that there is a reference between blogs $a$ and $b$. It's guaranteed that the graph doesn't contain multiple edges.

The last line contains $n$ integers $t_1, t_2, \ldots, t_n$, $i$-th of them denotes desired topic number of the $i$-th blog ($1 \le t_i \le n$).


-----Output-----

If the solution does not exist, then write $-1$. Otherwise, output $n$ distinct integers $p_1, p_2, \ldots, p_n$ $(1 \leq p_i \leq n)$, which describe the numbers of blogs in order which Johnny should write them. If there are multiple answers, print any.


-----Examples-----
Input
3 3
1 2
2 3
3 1
2 1 3

Output
2 1 3

Input
3 3
1 2
2 3
3 1
1 1 1

Output
-1

Input
5 3
1 2
2 3
4 5
2 1 2 2 1

Output
2 5 1 3 4



-----Note-----

In the first example, Johnny starts with writing blog number $2$, there are no already written neighbors yet, so it receives the first topic. Later he writes blog number $1$, it has reference to the already written second blog, so it receives the second topic. In the end, he writes blog number $3$, it has references to blogs number $1$ and $2$ so it receives the third topic.

Second example: There does not exist any permutation fulfilling given conditions.

Third example: First Johnny writes blog $2$, it receives the topic $1$. Then he writes blog $5$, it receives the topic $1$ too because it doesn't have reference to single already written blog $2$. Then he writes blog number $1$, it has reference to blog number $2$ with topic $1$, so it receives the topic $2$. Then he writes blog number $3$ which has reference to blog $2$, so it receives the topic $2$. Then he ends with writing blog number $4$ which has reference to blog $5$ and receives the topic $2$.

Difficulty: MEDIUM

Starter code:

Solutions:
from collections import defaultdict
import os, io
from sys import stdout
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, m) = list(map(int, input().split()))
adj = defaultdict(list)
for _ in range(m):
	(u, v) = list(map(int, input().split()))
	adj[u].append(v)
	adj[v].append(u)
t = list(map(int, input().split()))
t = [(index + 1, value) for (index, value) in enumerate(t)]
t = sorted(t, key=lambda tup: tup[1])
writtenTopicsForBlog = {}
result = []
impossible = False
for (blog, topic) in t:
	neighboursTopics = set([])
	for neighbour in adj[blog]:
		if neighbour in writtenTopicsForBlog:
			neighboursTopics.add(writtenTopicsForBlog[neighbour])
	minimumTopic = 1
	while minimumTopic in neighboursTopics:
		minimumTopic += 1
	if topic in neighboursTopics or topic != minimumTopic:
		impossible = True
		print(-1)
		break
	writtenTopicsForBlog[blog] = topic
	result.append(str(blog))
if not impossible:
	print(' '.join(result))


def main():
	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')
	(n, m) = map(int, input().split())
	g = [[] for _ in range(n)]
	for _ in range(m):
		(a, b) = map(int, input().split())
		g[a - 1].append(b - 1)
		g[b - 1].append(a - 1)
	t = list(map(int, input().split()))
	from collections import defaultdict
	d = defaultdict(set)
	for i in range(n):
		for j in g[i]:
			d[i].add(t[j])
	flag = 1
	import bisect
	for i in range(n):
		if t[i] in d[i]:
			print(-1)
			sys.exit()
		temp = sorted(list(d[i]))
		if bisect.bisect_right(temp, t[i]) == t[i] - 1:
			pass
		else:
			flag = 0
			break
	if not flag:
		print(-1)
		sys.exit()
	t = [(t[i], i) for i in range(n)]
	t.sort()
	ans = []
	for i in t:
		ans.append(i[1] + 1)
	print(*ans)
main()


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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 = self.os.read(self._fd, max(self.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 = self.os.read(self._fd, max(self.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:
			self.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 collections as col
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	(N, M) = getInts()
	neighbours = col.defaultdict(set)
	max_neighbour = col.defaultdict(int)
	for n in range(1, N + 1):
		max_neighbour[n] = 0
		neighbours[n] = set()
	edge = []
	for m in range(M):
		(A, B) = getInts()
		edge.append((A, B))
	T = [0] + getInts()
	for (A, B) in edge:
		if T[A] == T[B]:
			print(-1)
			return
		if T[A] > T[B]:
			neighbours[A].add(T[B])
			max_neighbour[A] = max(max_neighbour[A], T[B])
		else:
			neighbours[B].add(T[A])
			max_neighbour[B] = max(max_neighbour[B], T[A])
	for n in range(1, N + 1):
		if max_neighbour[n] != T[n] - 1 or len(neighbours[n]) != T[n] - 1:
			print(-1)
			return
	T = [(t, i) for (i, t) in enumerate(T)]
	T.sort(reverse=True)
	T.pop()
	ans = []
	while T:
		(t, i) = T.pop()
		ans.append(i)
	print(*ans)
	return
solve()


import os, io
from sys import stdout
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
I = lambda : list(map(int, input().split()))
(n, edge) = I()
go = [[] for _ in range(n + 1)]
for _ in range(edge):
	(a, b) = I()
	go[a].append(b)
	go[b].append(a)
s = I()
arr = []
for (i, x) in enumerate(list(s)):
	i += 1
	arr.append((x, i))
arr.sort()
count = [0] * (n + 1)
gone = [False] * (n + 1)
ans = []
for (topic, blog) in arr:
	gone[blog] = True
	if count[blog] + 1 != topic:
		print(-1)
		exit()
	ans.append(blog)
	for x in go[blog]:
		if gone[x] == False and count[x] not in (topic - 1, topic):
			print(-1)
			exit()
		count[x] = topic
print(' '.join([str(x) for x in ans]))


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

def solve(N, M, edges, topics):
	g = defaultdict(list)
	for (u, v) in edges:
		g[u].append(v)
		g[v].append(u)
	assert len(topics) == N
	vertices = sorted(range(N), key=lambda k: topics[k])
	seen = set()
	for v in vertices:
		best = -1
		uniq = set()
		for adj in g[v]:
			if adj in seen:
				best = max(best, topics[adj])
				uniq.add(topics[adj])
		if best + 1 != topics[v] or len(uniq) != topics[v]:
			return -1
		seen.add(v)
	return ' '.join((str(x + 1) for x in vertices))
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(N, M) = [int(x) for x in input().split()]
edges = [[int(x) - 1 for x in input().split()] for i in range(M)]
topics = [int(x) - 1 for x in input().split()]
ans = solve(N, M, edges, topics)
print(ans)


import os
import sys
from io import BytesIO, IOBase
import threading
from collections import defaultdict, Counter
from math import factorial as fac

def main():
	(n, m) = map(int, input().split())
	adj_list = defaultdict(list)
	for i in range(m):
		(u, v) = map(int, input().split())
		adj_list[u].append(v)
		adj_list[v].append(u)
	color = list(map(int, input().split()))
	blog_no = list(range(1, n + 1))
	color = list(zip(blog_no, color))
	violate = False
	for i in range(1, n + 1):
		color_i = color[i - 1][1]
		small_color = set()
		for v in adj_list[i]:
			if color[v - 1][1] == color_i:
				violate = True
				print(-1)
				exit(0)
			if color[v - 1][1] < color_i:
				small_color.add(color[v - 1][1])
		if len(small_color) == color_i - 1:
			violate = False
		else:
			violate = True
			print(-1)
			exit(0)
		small_color.clear()
	color.sort(key=lambda x: x[1])
	print(' '.join([str(color[i][0]) for i in range(n)]))
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, io, os

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 solve(n, m, ee, t):
	a = 1
	g = [[] for i in range(n)]
	for e in ee:
		g[e[0] - 1].append(e[1] - 1)
		g[e[1] - 1].append(e[0] - 1)
	p = sorted(list(range(n)), key=lambda x: (t[x], x))
	for v in p:
		x = t[v]
		f = {}
		cnt = 0
		for w in g[v]:
			if t[w] == x:
				return [-1]
			if t[w] < x and t[w] not in f:
				cnt += 1
				f[t[w]] = 1
		if cnt != x - 1:
			return [-1]
	return [i + 1 for i in p]

def main():
	(n, m) = ria()
	e = []
	for _ in range(m):
		e.append(ria())
	t = ria()
	wia(solve(n, m, e, t))

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 os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, m) = map(int, input().split())
D = []
usedcolours = []
for i in range(n + 1):
	usedcolours.append(set())
for i in range(m):
	D.append(list(map(int, input().split())))
temp = list(map(int, input().split()))
for i in D:
	usedcolours[i[0]].add(temp[i[1] - 1])
	usedcolours[i[1]].add(temp[i[0] - 1])
t = []
for i in range(n):
	t.append([i + 1, temp[i]])
t = sorted(t, key=lambda student: student[1])
failflag = 0
for i in range(1, n + 1):
	tempans = 1
	while True:
		if not tempans in usedcolours[i]:
			break
		tempans += 1
	if tempans != temp[i - 1]:
		failflag = 1
		break
ans = []
for i in range(n):
	ans.append(str(t[i][0]))
if failflag == 1:
	print(-1)
else:
	print(' '.join(ans))


from collections import *
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def main():
	(N, M) = list(map(int, input().split()))
	g = defaultdict(list)
	for i in range(M):
		(a, b) = list(map(int, input().split()))
		g[a].append(b)
		g[b].append(a)
	l = [0] + list(map(int, input().split()))
	sets = [i for i in range(N + 1)]
	sets.sort(key=lambda x: l[x])
	ans = [1 for i in range(N + 1)]
	anslist = []
	for i in sets[1:]:
		if l[i] != ans[i]:
			print(-1)
			exit()
		anslist.append(i)
		for j in g[i]:
			if ans[j] == l[i]:
				ans[j] = l[i] + 1
	print(*anslist)
main()


from sys import stdin, stdout
import heapq as hq
from collections import defaultdict
t = 1
for tc in range(t):
	(n, m) = list(map(int, stdin.readline().split()))
	neigh = [[] for x in range(n + 1)]
	for mc in range(m):
		(a, b) = list(map(int, stdin.readline().split()))
		neigh[a].append(b)
		neigh[b].append(a)
	ar = [-1] + list(map(int, stdin.readline().split()))
	nextval = [1 for x in range(n + 1)]
	res = []
	valid = True
	for topic in range(1, max(ar) + 1):
		for i in range(1, n + 1):
			if ar[i] == topic:
				if topic != nextval[i]:
					valid = False
					break
				res.append(i)
				for ne in neigh[i]:
					if nextval[ne] == topic:
						nextval[ne] += 1
		if not valid:
			break
	if valid:
		for val in res:
			stdout.write(str(val) + ' ')
		stdout.write('\n')
	else:
		stdout.write(str(-1) + '\n')


import sys
input = sys.stdin.buffer.readline

def print(val):
	sys.stdout.write(val + '\n')

def prog():
	(n, m) = map(int, input().split())
	adj_list = [[False, []] for i in range(n + 1)]
	for _ in range(m):
		(a, b) = map(int, input().split())
		adj_list[a][1].append(b)
		adj_list[a][0] = True
		adj_list[b][1].append(a)
		adj_list[b][0] = True
	topic = list(map(int, input().split()))
	worked = True
	for blog in range(1, n + 1):
		t = topic[blog - 1]
		curr_blog = adj_list[blog]
		if curr_blog[0] == False and t != 1:
			worked = False
			break
		else:
			lowerthan = set()
			for neighbor in curr_blog[1]:
				n_t = topic[neighbor - 1]
				if n_t == t:
					worked = False
					break
				elif n_t < t:
					lowerthan.add(n_t)
			if len(lowerthan) != t - 1:
				worked = False
			if worked == False:
				break
	if not worked:
		print(str(-1))
	else:
		in_order = [[] for i in range(n + 1)]
		for blog in range(1, n + 1):
			in_order[topic[blog - 1]].append(str(blog))
		final = []
		for a in in_order:
			final.extend(a)
		print(' '.join(final))
prog()


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, m) = map(int, input().split())
adj = [[] for i in range(n + 1)]
for i in range(m):
	(u, v) = map(int, input().split())
	adj[u].append(v)
	adj[v].append(u)
topics = [0] + list(map(int, input().split()))
bckt = [10 ** 9] * (n + 1)
ans = []
q = []
for i in range(1, n + 1):
	q.append((i, topics[i]))
q.sort(key=lambda x: x[1], reverse=True)
ok = True
while q:
	(e, t) = q.pop()
	ct = 1
	s = set()
	for j in adj[e]:
		s.add(bckt[j])
	while ct in s:
		ct += 1
	if t == ct:
		bckt[e] = t
		ans.append(e)
	else:
		ok = False
		break
if ok:
	print(*ans)
else:
	print(-1)


import sys
input = sys.stdin.buffer.readline
(n, m) = list(map(int, input().split()))
nodes = [[] for i in range(n)]
small_all = [0 for i in range(n)]
for i in range(m):
	(a, b) = list(map(int, input().split()))
	nodes[a - 1].append(b - 1)
	nodes[b - 1].append(a - 1)
I = lambda : list(map(int, input().split()))
col = I()
colors = list(range(n))
colors.sort(key=lambda x: col[x])
assigned = [0] * n
order = []
for c in colors:
	tt = col[c]
	if small_all[c] + 1 != tt:
		print(-1)
		exit()
	assigned[c] = tt
	for child in nodes[c]:
		if small_all[child] == tt - 1:
			small_all[child] += 1
	order.append(c + 1)
order = [str(x) for x in order]
print(' '.join(order))


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import sys
from collections import deque

def solve(n, m, Edges, T):
	if n == 1:
		if T[0] == 1:
			return [1]
		return [-1]
	L = []
	for (i, t) in enumerate(T):
		L.append((t, i))
	L.sort()
	Visited = [False] * n
	Ans = []
	for (num, fr) in L:
		Visited[fr] = True
		s = set()
		for to in Edges[fr]:
			if Visited[to]:
				if T[to] == num:
					return [-1]
				s.add(T[to])
		if len(s) != num - 1:
			return [-1]
		Ans.append(fr + 1)
	return Ans

def main():
	(n, m) = map(int, input().split())
	Edges = [[] for _ in range(n)]
	for _ in range(m):
		(a, b) = map(lambda x: int(x) - 1, input().split())
		Edges[a].append(b)
		Edges[b].append(a)
	T = list(map(int, input().split()))
	Ans = solve(n, m, Edges, T)
	sys.stdout.write(' '.join(map(str, Ans)) + '\n')
main()


import os
import sys
from io import BytesIO, IOBase

def main():
	(n, m) = map(int, input().split())
	e = [[] for _ in range(n)]
	for _ in range(m):
		(u, v) = map(int, input().split())
		(u, v) = (u - 1, v - 1)
		e[u].append(v)
		e[v].append(u)
	a = [int(x) for x in input().split()]
	tc = [i for i in range(n)]
	tc.sort(key=lambda x: a[x])
	for v in tc:
		if len(e[v]) + 1 < a[v]:
			print(-1)
			exit(0)
		vis = [True] * (a[v] + 1)
		for x in e[v]:
			if a[x] > a[v]:
				continue
			vis[a[x]] = False
		if not vis[a[v]] or any(vis[1:-1]):
			print(-1)
			exit(0)
	print(' '.join((str(x + 1) for x in tc)))
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 io
import os

def main():
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
	(n, m) = map(int, input().split())
	dct = {x: [] for x in range(1, n + 1)}
	for _ in range(m):
		(a, b) = map(int, input().split())
		dct[a].append(b)
		dct[b].append(a)
	mini = [-1 for _ in range(n)]
	dct1 = {x: [] for x in range(1, n + 1)}
	arr = list(map(int, input().split()))
	for i in range(n):
		dct1[arr[i]].append(i + 1)
	ans = []
	for x in range(1, max(arr) + 1):
		fl = 1
		for y in dct1[x]:
			fl = 0
			se = set()
			for ne in dct[y]:
				if mini[ne - 1] != -1:
					se.add(mini[ne - 1])
				if mini[ne - 1] == x:
					fl = 1
					break
			if len(se) != x - 1 or fl:
				fl = 1
				break
			else:
				ans.append(y)
				mini[y - 1] = x
		if fl:
			print(-1)
			break
	if not fl:
		for kk in ans:
			print(kk, end=' ')
main()


import sys
input = sys.stdin.buffer.readline

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

def sieve(n):
	a = [1] * n
	for i in range(2, n):
		if a[i]:
			for j in range(i * i, n, i):
				a[j] = 0
	return a

def solve():
	(n, m) = I()
	graph = [[] for i in range(n)]
	for i in range(m):
		(u, v) = I()
		graph[u - 1].append(v - 1)
		graph[v - 1].append(u - 1)
	w = I()
	colors = [0] * n
	nodes = list(range(n))
	nodes.sort(key=lambda x: w[x])
	for node in nodes:
		currcolor = w[node]
		done = set()
		for neigh in graph[node]:
			if colors[neigh] != 0:
				done.add(colors[neigh])
		if done != set(list(range(1, currcolor))):
			print(-1)
			return
		colors[node] = currcolor
	print(*[i + 1 for i in nodes])
solve()


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, m) = map(int, input().split())
rebase = lambda x: int(x) - 1
E = [[] for u in range(n)]
for j in range(m):
	(u, v) = map(rebase, input().split())
	E[u].append(v)
	E[v].append(u)
t = list(map(rebase, input().split()))
vis = [False] * n
for u in range(n):
	for v in E[u]:
		vis[t[v]] = True
	x = 0
	while vis[x]:
		x += 1
	if x != t[u]:
		print(-1)
		exit()
	for v in E[u]:
		vis[t[v]] = False
p = list(zip(t, range(n)))
p.sort()
print(*[u + 1 for (x, u) in p])


import sys
import math
input = sys.stdin.readline
(N, M) = map(int, input().split(' '))
A = [[] for i in range(N)]
for i in range(M):
	(x, y) = map(int, input().split(' '))
	x -= 1
	y -= 1
	A[x].append(y)
	A[y].append(x)
topics = list(map(int, input().split(' ')))
blogs_by_topic = {}
for i in range(N):
	topic = topics[i] - 1
	if topic not in blogs_by_topic:
		blogs_by_topic[topic] = [i]
	else:
		blogs_by_topic[topic].append(i)
T = [None for i in range(N)]
ans = []
for t in range(N):
	blogs = blogs_by_topic.get(t, None)
	if not blogs:
		continue
	for blog in blogs:
		T[blog] = t
		other_topics = set()
		for adj in A[blog]:
			if T[adj] is not None:
				other_topics.add(T[adj])
		if other_topics and max(other_topics) >= t or len(other_topics) != t:
			print(-1)
			exit(0)
		ans.append(blog + 1)
print(' '.join(map(str, ans)))


import sys
input = sys.stdin.buffer.readline
(n, edge) = map(int, input().split())
go = [[] for _ in range(n + 1)]
for _ in range(edge):
	(a, b) = map(int, input().split())
	go[a].append(b)
	go[b].append(a)
s = map(int, input().split())
arr = []
for (i, x) in enumerate(list(s)):
	i += 1
	arr.append((x, i))
arr.sort()
count = [0] * (n + 1)
gone = [False] * (n + 1)
ans = []
for (topic, blog) in arr:
	gone[blog] = True
	if count[blog] + 1 != topic:
		print(-1)
		exit()
	ans.append(blog)
	for x in go[blog]:
		if gone[x] == False and count[x] not in (topic - 1, topic):
			print(-1)
			exit()
		count[x] = topic
print(' '.join([str(x) for x in ans]))


import sys
from collections import deque
I = list(map(int, open(0).read().split()))
(N, M) = (I[0], I[1])
X = [[] for _ in range(N)]
ii = 2
for _ in range(M):
	(a, b) = (I[ii], I[ii + 1])
	ii += 2
	(a, b) = (a - 1, b - 1)
	X[a].append(b)
	X[b].append(a)
B = []
while ii < len(I):
	B.append(I[ii] - 1)
	ii += 1
A = sorted([(a << 19) + i for (i, a) in enumerate(B)])
m = (1 << 19) - 1
DONE = [0] * N
ANS = []
for x in A:
	(a, i) = (x >> 19, x & m)
	if a > len(X[i]):
		print(-1)
		exit()
	L = [0] * (a + 1)
	for j in X[i]:
		if DONE[j]:
			L[B[j]] = 1
	if sum(L) != a or L[-1] != 0:
		print(-1)
		exit()
	DONE[i] = 1
	ANS.append(i)
print(*[a + 1 for a in ANS])


import sys
from collections import defaultdict
input = sys.stdin.buffer.readline
buffer_ = [0] * 500001

def solve(neighbors, desired):
	ordering = []
	for (index, color) in enumerate(desired[1:], 1):
		ordering.append((color, index))
	proposed = []
	for (_, index) in sorted(ordering):
		proposed.append(index)
	for vertex in proposed:
		(my_desired, count) = (desired[vertex], 0)
		for neighbor in neighbors[vertex]:
			neighbor_desired = desired[neighbor]
			if neighbor_desired == my_desired:
				return None
			elif neighbor_desired > my_desired:
				continue
			elif buffer_[neighbor_desired] != vertex:
				buffer_[neighbor_desired] = vertex
				count += 1
		if count != my_desired - 1:
			return None
	return proposed
(n, m) = map(int, input().split())
neighbors = defaultdict(set)
for i in range(m):
	(a, b) = map(int, input().split())
	neighbors[a].add(b)
	neighbors[b].add(a)
desired = [0] + list(map(int, input().split()))
ordering = solve(neighbors, desired)
print('-1' if ordering is None else ' '.join(map(str, ordering)))


import sys
from collections import deque
input = sys.stdin.buffer.readline
print = sys.stdout.write
(n, m) = map(int, input().split())
e = [[] for _ in range(n + 1)]
for _ in range(m):
	(a, b) = map(int, input().split())
	e[a].append(b)
	e[b].append(a)
tg = [0] + list(map(int, input().split()))
te = [[] for _ in range(n + 1)]
incc = [0] * (n + 1)
for u in range(1, n + 1):
	for v in e[u]:
		if tg[v] > tg[u]:
			te[u].append(v)
			incc[v] += 1
res = []
q = deque([u for u in range(1, n + 1) if incc[u] == 0])
while q:
	u = q.popleft()
	res.append(u)
	for v in te[u]:
		incc[v] -= 1
		if incc[v] == 0:
			q.append(v)
if len(res) != n:
	print('-1\n')
	exit()
topic = [0] * (n + 1)
for u in res:
	(cc, utp) = (set(), tg[u])
	for v in e[u]:
		vtp = topic[v]
		if vtp != 0 and vtp <= utp:
			cc.add(vtp)
	if not (len(cc) == utp - 1 and utp not in cc):
		print('-1\n')
		exit()
	topic[u] = utp
print(' '.join(map(str, res)) + '\n')


import sys
input = sys.stdin.buffer.readline
(n, m) = list(map(int, input().split()))
con = [[] for _ in range(n)]
for _ in range(m):
	(a, b) = list(map(int, input().split()))
	con[a - 1].append(b - 1)
	con[b - 1].append(a - 1)
t = [int(x) for x in input().split()]
od = sorted(list(range(n)), key=lambda f: t[f])
cn = [1] * n
ans = []
for ii in od:
	tt = t[ii]
	if cn[ii] != tt:
		print(-1)
		return
	for jj in con[ii]:
		if cn[jj] == tt:
			cn[jj] += 1
	ans.append(ii + 1)
print(' '.join(map(str, ans)))


import os
import sys
import io
from io import BytesIO, IOBase

def main():
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
	I = lambda : list(map(int, input().split()))
	(n, m) = I()
	g = [[] for i in range(n)]
	for i in range(m):
		(a, b) = I()
		g[a - 1].append(b - 1)
		g[b - 1].append(a - 1)
	rc = I()
	c = [i for i in range(1, n + 1)]
	c.sort(key=lambda x: rc[x - 1])
	col = [0] * n
	mcol = [1] * n
	f = 1
	for i in range(n):
		x = c[i] - 1
		i = x
		if rc[x] == mcol[i]:
			col[i] = rc[x]
			for j in g[i]:
				if mcol[j] == mcol[i]:
					mcol[j] += 1
		else:
			f = 0
			break
	print(*(c if f else [-1]))
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
from array import array
import typing as Tp

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def output(*args):
	sys.stdout.buffer.write(('\n'.join(map(str, args)) + '\n').encode('utf-8'))

def main():
	from collections import deque
	(n, m) = map(int, input().split())
	adj = [[] for _ in range(n + 1)]
	for (u, v) in (map(int, input().split()) for _ in range(m)):
		adj[u].append(v)
		adj[v].append(u)
	topic = [0] + list(map(int, input().split()))
	prev = [0] * (n + 1)
	prev_cnt = [0] * (n + 1)
	dq = deque()
	for i in range(1, n + 1):
		for dest in adj[i]:
			if topic[i] > topic[dest]:
				prev_cnt[i] += 1
			if topic[i] == topic[dest]:
				print(-1)
				exit()
		if topic[i] == 1:
			dq.append(i)
	ans = []
	while dq:
		v = dq.popleft()
		ans.append(v)
		for dest in adj[v]:
			if topic[v] < topic[dest]:
				if not prev[dest] <= topic[v] <= prev[dest] + 1:
					print(-1)
					exit()
				prev[dest] = topic[v]
				prev_cnt[dest] -= 1
				if topic[v] + 1 == topic[dest] and prev_cnt[dest] == 0:
					dq.append(dest)
	if len(ans) == n:
		output(' '.join(map(str, ans)))
	else:
		output('-1')
main()


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')
(n, m) = map(int, input().split())
graph = [[] for s in range(n)]
for s in range(m):
	(a, b) = map(int, input().split())
	a -= 1
	b -= 1
	graph[a].append(b)
	graph[b].append(a)
col = list(map(int, input().split()))
broke = False
for s in range(n):
	if col[s] > len(graph[s]) + 1:
		broke = True
		break
	enc = set([])
	sum1 = 0
	for b in graph[s]:
		if col[b] == col[s]:
			broke = True
			break
		else:
			if not col[b] in enc:
				if col[b] < col[s]:
					sum1 += col[b]
			enc.add(col[b])
	if sum1 == col[s] * (col[s] - 1) // 2:
		continue
	else:
		broke = True
		break
if broke == False:
	vals = [(col[s], s) for s in range(n)]
	vals.sort(key=lambda x: x[0])
	ans = [k[1] + 1 for k in vals]
	print(*ans)
else:
	print(-1)


import sys
input = sys.stdin.buffer.readline
(n, m) = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]
t = list(map(int, input().split()))
graph = [[] for i in range(n)]
for (a, b) in info:
	a -= 1
	b -= 1
	graph[a].append(b)
	graph[b].append(a)
t = sorted([(val, i) for (i, val) in enumerate(t)])
ans = [0] * n
for (val, v) in t:
	set_ = set([])
	for nxt_v in graph[v]:
		set_.add(ans[nxt_v])
	for i in range(1, val):
		if i not in set_:
			print(-1)
			exit()
	if val in set_:
		print(-1)
		exit()
	ans[v] = val
print(*[t[i][1] + 1 for i in range(n)])


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, m) = list(map(int, input().split()))
graph = [[] for i in range(n + 1)]
for i in range(m):
	(a, b) = list(map(int, input().split()))
	graph[a].append(b)
	graph[b].append(a)
t = list(map(int, input().split()))
nodes = list(range(1, n + 1))
nodes.sort(key=lambda x: t[x - 1])
f = 0
tdict = [1] * (n + 1)
for node in nodes:
	tval = t[node - 1]
	if tval == tdict[node]:
		for child in graph[node]:
			if tdict[child] == tval:
				tdict[child] += 1
				graph[child].remove(node)
	else:
		print(-1)
		f = 1
		break
if f == 0:
	print(' '.join(map(str, nodes)))


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key, lru_cache
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
M = mod = 10 ** 9 + 7

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().split()]

def st():
	return str(input().rstrip())[2:-1]

def val():
	return int(input().rstrip())

def li2():
	return [str(i)[2:-1] for i in input().rstrip().split()]

def li3():
	return [int(i) for i in st()]
(n, m) = li()
g = defaultdict(list)
for i in range(m):
	(a, b) = li()
	g[a].append(b)
	g[b].append(a)
l = [0] + li()
makesets = [i for i in range(n + 1)]
makesets.sort(key=lambda x: l[x])
ans = [1 for i in range(n + 1)]
curr = 1
mainans = []
for i in makesets[1:]:
	if l[i] != ans[i]:
		print(-1)
		exit()
	mainans.append(i)
	for j in g[i]:
		if ans[j] == l[i]:
			ans[j] = l[i] + 1
	curr += 1
print(*mainans)


import os, io
from sys import stdout
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def main():
	I = lambda : list(map(int, input().split()))
	(n, m) = I()
	g = [[] for i in range(n)]
	for i in range(m):
		(a, b) = I()
		g[a - 1].append(b - 1)
		g[b - 1].append(a - 1)
	rc = I()
	c = [i for i in range(1, n + 1)]
	c.sort(key=lambda x: rc[x - 1])
	mcol = [1] * n
	f = 1
	for i in range(n):
		x = c[i] - 1
		i = x
		if rc[x] == mcol[i]:
			for j in g[i]:
				if mcol[j] == mcol[i]:
					mcol[j] += 1
					if rc[j] < mcol[j]:
						break
		else:
			f = 0
			c = [-1]
			break
	stdout.write(' '.join((str(i) for i in c)))
main()


import os, io
from sys import stdout
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
I = lambda : list(map(int, input().split()))
(n, m) = I()
g = [[] for i in range(n)]
for i in range(m):
	(x, y) = I()
	x -= 1
	y -= 1
	g[x].append(y)
	g[y].append(x)
col = I()
arr = list(range(n))
arr.sort(key=lambda x: col[x])
ch = [1] * n
ans = []
f = 1
for i in arr:
	t = col[i]
	if t == ch[i]:
		for j in g[i]:
			if ch[j] == t:
				ch[j] += 1
		ans.append(i + 1)
	else:
		f = 0
		break
if f:
	print(*ans)
else:
	print(-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')
(n, m) = map(int, input().split())
adj = [[] for i in range(n + 1)]
for i in range(m):
	(x, y) = map(int, input().split())
	adj[x].append(y)
	adj[y].append(x)
l = list(map(int, input().split()))
l1 = []
for i in range(n):
	l1.append([l[i], i + 1])
l1.sort()
l2 = [0] * (n + 1)
ans = []
a = True
for i in l1:
	s = set()
	for j in adj[i[1]]:
		if l2[j] == 1:
			s.add(l[j - 1])
		if len(s) == i[0] or l[j - 1] == i[0]:
			a = False
			break
	ans.append(i[1])
	l2[i[1]] = 1
	if len(s) != i[0] - 1:
		a = False
	if a == False:
		break
if a == False:
	print(-1)
else:
	print(*ans)


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')
(n, m) = map(int, input().split())
d = [[] for j in range(n + 1)]
f = []
for j in range(m):
	(a, c) = map(int, input().split())
	f.append([a, c])
b = list(map(int, input().split()))
for j in f:
	(a, c) = (j[0], j[1])
	d[a].append(b[c - 1])
	d[c].append(b[a - 1])
h = [0] * (n + 1)
j = 1
while j <= n:
	d[j] = list(set(d[j]))
	e = dict()
	for i in d[j]:
		e[i] = 1
	q = 1
	while q <= b[j - 1]:
		if q not in e.keys():
			h[j] = q
			break
		q += 1
	j += 1
a = []
for j in range(n):
	a.append([b[j], j + 1])
a.sort()
j = 0
p = 1
f = []
g = 0
while j < n:
	(x, y) = (a[j][0], a[j][1])
	if h[y] == x:
		f.append(y)
	else:
		g = 1
		break
	j += 1
if g == 1:
	print(-1)
else:
	print(*f)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from operator import itemgetter
(n, m) = map(int, input().split())
graph = [[] for i in range(n + 1)]
for i in range(m):
	(x, y) = map(int, input().split())
	graph[x].append(y)
	graph[y].append(x)
a = [int(j) for j in input().split()]
f = [(a[j], j + 1) for j in range(n)]
f.sort(key=itemgetter(0))
fail = False
a = []
checked = [1 for j in range(n + 1)]
for (num, node) in f:
	if checked[node] == num:
		for nei in graph[node]:
			if checked[nei] == num:
				checked[nei] += 1
	else:
		fail = True
		print(-1)
		break
if fail == False:
	ans = [f[i][1] for i in range(n)]
	print(*ans)


from sys import stdin, stdout
arr_in = lambda : [int(x) for x in stdin.buffer.readline().split()]
out = lambda o: stdout.write('{}\n'.format(o))
arr_out = lambda o: out(' '.join(map(str, o)))
(n, m) = map(int, stdin.buffer.readline().split())
neighbors = [[] for _ in range(n)]
for _ in range(m):
	(a, b) = map(int, stdin.buffer.readline().split())
	neighbors[a - 1].append(b)
	neighbors[b - 1].append(a)
t = arr_in()
result = []
use = [1] * n
order = sorted(list(range(n)), key=lambda x: t[x])
for item in order:
	curr = t[item]
	if use[item] != curr:
		out(-1)
		exit()
	for neighbor in neighbors[item]:
		if use[neighbor - 1] == curr:
			use[neighbor - 1] += 1
	result.append(item + 1)
arr_out(result)


import sys
I = lambda : list(map(int, input().split()))
input = sys.stdin.buffer.readline
(n, m) = I()
g = [[] for i in range(n)]
for i in range(m):
	(x, y) = I()
	x -= 1
	y -= 1
	g[x].append(y)
	g[y].append(x)
col = I()
arr = list(range(n))
arr.sort(key=lambda x: col[x])
ch = [1] * n
ans = []
f = 1
for i in arr:
	t = col[i]
	if t == ch[i]:
		for j in g[i]:
			if ch[j] == t:
				ch[j] += 1
		ans.append(i + 1)
	else:
		f = 0
		break
if f:
	print(*ans)
else:
	print(-1)


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
neig = [0] * n
for i in range(n):
	neig[i] = [0]
for i in range(m):
	(a, b) = map(int, input().split())
	a -= 1
	b -= 1
	neig[a][0] += 1
	neig[b][0] += 1
	neig[a].append(b)
	neig[b].append(a)
pref = list(map(int, input().split()))
order = [0] * n
for i in range(n):
	order[i] = []
possible = True
mx = max(pref)
for i in range(n):
	if neig[i][0] + 1 >= pref[i]:
		ok = [False] * (pref[i] - 1)
		oks = 0
		for j in range(1, neig[i][0] + 1):
			if pref[neig[i][j]] == pref[i]:
				possible = False
				break
			if pref[neig[i][j]] < pref[i] and (not ok[pref[neig[i][j]] - 1]):
				ok[pref[neig[i][j]] - 1] = True
				oks += 1
		if oks < pref[i] - 1:
			possible = False
		if not possible:
			break
		order[pref[i] - 1].append(i + 1)
	else:
		possible = False
		break
sol = []
for i in range(mx):
	if len(order[i]) == 0:
		possible = False
	else:
		for j in order[i]:
			sol.append(j)
if possible:
	print(*sol)
else:
	print(-1)


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'
(n, m) = map(int, input().split())
tr = [[] for i in range(n)]
for i in range(m):
	(a, b) = map(int, input().split())
	tr[a - 1].append(b - 1)
	tr[b - 1].append(a - 1)
t = list(map(int, input().split()))
s = {i: [] for i in range(n)}
for i in range(n):
	s[t[i] - 1].append(i)
an = []
vis = [False for i in range(n)]
for i in range(n):
	while s[i]:
		x = s[i].pop()
		j = 1
		tr[x].sort(key=lambda x: t[x])
		for y in tr[x]:
			if vis[y]:
				if t[y] == j:
					j += 1
		if j != i + 1:
			print(-1)
			exit()
		vis[x] = True
		an.append(x + 1)
print(*an)


import sys
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 LI1():
	return list(map(int1, sys.stdin.readline().split()))

def LLI1(rows_number):
	return [LI1() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	(n, m) = MI()
	uv = LLI1(m)
	tt = LI1()
	tot = [set() for _ in range(n)]
	for (u, v) in uv:
		tu = tt[u]
		tv = tt[v]
		if tu == tv:
			print(-1)
			exit()
		if tu > tv:
			(tu, tv) = (tv, tu)
			(u, v) = (v, u)
		tot[v].add(tu)
	for u in range(n):
		if len(tot[u]) != tt[u]:
			print(-1)
			exit()
	ttou = [[] for _ in range(n)]
	for (u, t) in enumerate(tt):
		ttou[t].append(u)
	ans = []
	for uu in ttou:
		for u in uu:
			ans.append(u + 1)
	print(*ans)
main()


import sys
input = sys.stdin.buffer.readline
(n, m) = [int(x) for x in input().split()]
neighbours = dict()
maxInNeighbours = dict()
for i in range(1, n + 1):
	neighbours[i] = []
	maxInNeighbours[i] = 0
for _ in range(m):
	(a, b) = [int(x) for x in input().split()]
	neighbours[a].append(b)
	neighbours[b].append(a)
desiredTopic = [-1] + [int(x) for x in input().split()]
blogs = list(range(1, n + 1))
blogs.sort(key=lambda blog: desiredTopic[blog])
ok = True
for blog in blogs:
	blogTopic = desiredTopic[blog]
	if maxInNeighbours[blog] + 1 != blogTopic:
		ok = False
		break
	else:
		for neighbour in neighbours[blog]:
			if maxInNeighbours[neighbour] == blogTopic - 1:
				maxInNeighbours[neighbour] = blogTopic
if ok:
	print(' '.join([str(x) for x in blogs]))
else:
	print('-1')


from sys import stdin, stdout
import sys
from math import *
input = stdin.buffer.readline
(n, m) = map(int, input().split())
g = []
for i in range(n):
	g.append([])
for i in range(m):
	(x, y) = map(int, input().split())
	x -= 1
	y -= 1
	g[x].append(y)
	g[y].append(x)
l = list(map(int, input().split()))
l = [[l[i], i] for i in range(n)]
l.sort()
ch = [1] * n
rslt = []
ans = True
for i in range(n):
	c = l[i][0]
	if ch[l[i][1]] == c:
		for v in g[l[i][1]]:
			if c == ch[v]:
				ch[v] += 1
		rslt.append(l[i][1] + 1)
	else:
		ans = False
		break
if ans == False:
	print('-1')
else:
	print(*rslt)


import sys, math
import io, os
data = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

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

def main():
	(n, m) = mdata()
	g = [set() for i in range(n)]
	for i in range(m):
		(a, b) = mdata()
		g[a - 1].add(b - 1)
		g[b - 1].add(a - 1)
	t = mdata()
	t1 = sorted(range(n), key=lambda x: t[x])
	vis = [0] * n
	flag = True
	ans = []
	for i in t1:
		s = set()
		a = i
		for j in g[a]:
			if vis[j] == 1 and t[j] <= t[i]:
				s.add(t[j])
		if t[i] - 1 != len(s) or t[i] in s:
			flag = False
			break
		vis[i] = 1
		ans.append(i + 1)
	if flag == False:
		out(-1)
	else:
		print(*ans)
main()


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
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 SegmentTree:

	def __init__(self, data, default=-10 ** 6, 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 SegmentTree1:

	def __init__(self, data, default=10 ** 6, 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)
MOD = 10 ** 9 + 7

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
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(50001)]
pp = []

def SieveOfEratosthenes(n=50000):
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for i in range(50001):
		if prime[i]:
			pp.append(i)
r = sys.stdin.buffer.readline
(n, m) = map(int, r().split())
network = [[] for _ in range(n)]
for _ in range(m):
	(a, b) = map(int, r().split())
	network[a - 1].append(b - 1)
	network[b - 1].append(a - 1)
lst = list(map(int, r().split()))
arr = list(range(n))
arr.sort(key=lambda x: lst[x])
ret = [1] * n
res = []
for i in arr:
	t = lst[i]
	if t == ret[i]:
		for j in network[i]:
			if ret[j] == t:
				ret[j] += 1
		res.append(i + 1)
	else:
		print(-1)
		exit(0)
print(*res)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from collections import defaultdict, deque

def bfs(node):
	vis[node] = 1
	q = deque([node])
	while q:
		cur = q.popleft()
		dict1 = {}
		for j in edge[cur]:
			if vis[j] == 0:
				vis[j] = 1
				q.append(j)
			if topic[j - 1] == topic[cur - 1]:
				return False
			if topic[j - 1] < topic[cur - 1]:
				dict1[topic[j - 1]] = 1
		b = len(dict1.keys())
		if b != topic[cur - 1] - 1:
			return False
	return True
(n, m) = list(map(int, input().split()))
edge = defaultdict(list)
for i in range(m):
	(u, v) = list(map(int, input().split()))
	edge[u].append(v)
	edge[v].append(u)
topic = list(map(int, input().split()))
vis = [0] * (n + 1)
s = 0
for i in range(1, n + 1):
	if vis[i] == 0:
		temp = bfs(i)
		if temp == False:
			s += 1
			break
if s == 1:
	print(-1)
else:
	ans = []
	for i in range(n):
		ans.append([topic[i], i + 1])
	ans.sort(key=lambda x: x[0], reverse=False)
	num = []
	for i in range(n):
		num.append(ans[i][1])
	print(' '.join((str(x) for x in num)))


import sys

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

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

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

def list4d(a, b, c, d, e):
	return [[[[e] * d for j 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
(N, M) = MAP()
edges = []
for i in range(M):
	(a, b) = MAP()
	a -= 1
	b -= 1
	edges.append((a, b))
A = [a - 1 for a in LIST()]
mex = [0] * N
se = [set() for i in range(N)]
for (a, b) in edges:
	if A[a] == A[b]:
		print(-1)
		exit()
	if A[b] not in se[a]:
		se[a].add(A[b])
		if mex[a] == A[b]:
			x = mex[a]
			while x in se[a]:
				x += 1
			mex[a] = x
	if A[a] not in se[b]:
		se[b].add(A[a])
		if mex[b] == A[a]:
			x = mex[b]
			while x in se[b]:
				x += 1
			mex[b] = x
for u in range(N):
	if mex[u] < A[u]:
		print(-1)
		exit()
AI = [(a, i) for (i, a) in enumerate(A)]
AI.sort()
ans = []
for (a, i) in AI:
	ans.append(i + 1)
print(*ans)


import sys
import math
import operator as op
from functools import reduce

def read_line():
	return sys.stdin.readline()[:-1]

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

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]

def read_float_line():
	return [float(v) for v in sys.stdin.readline().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
N = int(1000000.0) + 10
fenwick = [0] * N

def add(i, x, n):
	while i < n:
		fenwick[i] += x
		i = i | i + 1

def fsum(i, n):
	res = 0
	while i >= 0:
		res += fenwick[i]
		i = (i & i + 1) - 1
	return res

def fsum_range(i, j, n):
	return fsum(j, n) - fsum(i - 1, n)
mod = int(1000000000.0) + 7
t = 1
for i in range(t):
	(n, m) = read_int_line()
	g = {}
	for i in range(m):
		(a, b) = read_int_line()
		if a in g:
			g[a].append(b)
		else:
			g[a] = [b]
		if b in g:
			g[b].append(a)
		else:
			g[b] = [a]
	c = read_int_line()
	d = {}
	for i in range(n):
		if c[i] in d:
			d[c[i]].append(i + 1)
		else:
			d[c[i]] = [i + 1]
	l = sorted(d.keys())
	ans = []
	for j in l:
		ans += d[j]
	f = True
	for i in range(n):
		color = c[i]
		adj = {}
		if i + 1 in g:
			for j in g[i + 1]:
				adj[c[j - 1]] = 1
			if color in adj:
				f = False
				break
			for j in range(1, color):
				if j not in adj:
					f = False
					break
		elif c[i] != 1:
			f = False
			break
		if not f:
			break
	if f:
		print(*ans)
	else:
		print(-1)


import sys
ints = (int(x) for x in sys.stdin.read().split())
sys.setrecursionlimit(3000)
N = 5 * 10 ** 5
ans = [[] for i in range(N)]
aux = [-1] * N
G = [[] for i in range(N)]
tgt = [0 for i in range(N)]

def solve(n, G, tgt):
	for i in range(n):
		k = tgt[i]
		for j in G[i]:
			aux[tgt[j]] = i
		if aux[k] == i or len(G[i]) < k or any((aux[t] != i for t in range(k))):
			yield (-1)
			return
		ans[k].append(i)
	for t in range(n):
		for i in ans[t]:
			yield (i + 1)
	return

def main():
	(n, m) = (next(ints) for i in range(2))
	for _ in range(m):
		i = next(ints) - 1
		j = next(ints) - 1
		G[i].append(j)
		G[j].append(i)
	for i in range(n):
		tgt[i] = next(ints) - 1
	print(*solve(n, G, tgt))
	return
main()


from collections import defaultdict
import os, io
from sys import stdout
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, m) = list(map(int, input().split()))
adj = defaultdict(set)
l = []
for _ in range(m):
	(u, v) = list(map(int, input().split()))
	l.append((u, v))
t = list(map(int, input().split()))
c = sorted([(index + 1, value) for (index, value) in enumerate(t)], key=lambda x: x[1])

def sol():
	for (u, v) in l:
		adj[u].add(t[v - 1])
		adj[v].add(t[u - 1])
		if t[v - 1] == t[u - 1]:
			print(-1)
			return
	for (blog, topic) in c:
		minimumTopic = 1
		while minimumTopic in adj[blog]:
			minimumTopic += 1
		if topic != minimumTopic:
			print(-1)
			break
	else:
		print(' '.join((str(i[0]) for i in c)))
sol()


import os
import sys
from io import BytesIO, IOBase

def main():
	(n, m) = map(int, input().split())
	d = {i: [] for i in range(1, n + 1)}
	for i in range(m):
		(a, b) = map(int, input().split())
		d[a].append(b)
		d[b].append(a)
	col = list(map(int, input().split()))
	l = []
	for i in range(1, n + 1):
		l.append([col[i - 1], i])
	l.sort(key=lambda x: x[0])
	flag = 0
	for i in range(n):
		cur_col = l[i][0]
		cur_nod = l[i][1]
		s = set()
		for j in d[cur_nod]:
			if cur_col == 1:
				if col[j - 1] == 1:
					flag = 1
					break
			elif col[j - 1] < cur_col:
				s.add(col[j - 1])
		if flag == 1:
			break
		if len(s) != cur_col - 1:
			flag = 1
			break
	if flag == 1:
		print(-1)
	else:
		for i in range(n):
			print(l[i][1], end=' ')
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))

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

def write(*args, end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(str(args[-1]))
	sys.stdout.write(end)

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

def r_int():
	return int(input())
main()


from sys import stdin, gettrace
if gettrace():
	inputi = input
else:

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

	def inputi():
		return stdin.buffer.readline()

def read_graph(n, m):
	adj = [set() for _ in range(n)]
	for _ in range(m):
		(u, v) = map(int, inputi().split())
		adj[u - 1].add(v - 1)
		adj[v - 1].add(u - 1)
	return adj

def main():
	(n, m) = map(int, inputi().split())
	adj = read_graph(n, m)
	tt = [int(a) for a in inputi().split()]
	res = sorted(range(n), key=lambda i: tt[i])
	mv = [1] * n
	for r in res:
		if mv[r] != tt[r]:
			print(-1)
			return
		for a in adj[r]:
			if tt[r] == mv[a]:
				mv[a] = tt[r] + 1
	print(' '.join(map(lambda r: str(r + 1), res)))
main()


from sys import stdin, stdout
import os, sys, __pypy__

def main():
	(n, m) = list(map(int, stdin.readline().split()))
	tree = [list() for _ in range(n + 1)]
	mn = [0] * (n + 1)
	for _ in range(m):
		(a, b) = list(map(int, stdin.readline().split()))
		tree[a].append(b)
		tree[b].append(a)
	stacks = [list() for _ in range(n + 1)]
	arr = list(map(int, stdin.readline().split()))
	for (i, x) in enumerate(arr):
		stacks[x].append(i + 1)
	is_can = True
	ans = __pypy__.builders.StringBuilder()
	cnt = 0
	for (i, stack) in enumerate(stacks):
		for x in stack:
			if mn[x] + 1 == i:
				ans.append('%d ' % x)
				cnt += 1
				for near in tree[x]:
					if mn[near] + 1 == i:
						mn[near] += 1
			else:
				is_can = False
				break
		if not is_can:
			break
	if not is_can or cnt != n:
		stdout.write('-1\n')
	else:
		os.write(1, ans.build().encode())
main()


import sys
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def main():
	(n, m) = map(int, input().split())
	G = [[] for k in range(n)]
	for k in range(m):
		(a, b) = map(int, input().split())
		G[a - 1].append(b - 1)
		G[b - 1].append(a - 1)
	t = list(map(int, input().split()))
	u = sorted([[t[k], k] for k in range(n)])
	visited = [0] * n
	for k in range(n):
		visited[u[k][1]] = 1
		seen = set([])
		for e in G[u[k][1]]:
			if visited[e] == 1:
				if t[e] >= t[u[k][1]]:
					print(-1)
					exit(0)
				else:
					seen.add(t[e])
		if u[k][0] != len(seen) + 1:
			print(-1)
			exit(0)
	print(*[u[k][1] + 1 for k in range(n)])
main()


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')
(n, m) = map(int, input().split())
arr = [[] for j in range(n + 1)]
f = []
for j in range(m):
	(a, c) = map(int, input().split())
	f.append([a, c])
b = list(map(int, input().split()))
k = []
for j in range(n):
	k.append([b[j], j + 1])
k.sort()
for j in f:
	(a, c) = (j[0], j[1])
	arr[a].append(b[c - 1])
	arr[c].append(b[a - 1])
v = [0] * (n + 1)
j = 1
while j <= n:
	e = dict()
	for i in arr[j]:
		e[i] = 1
	u = 1
	while u <= b[j - 1]:
		if u not in e.keys():
			v[j] = u
			break
		u += 1
	j += 1
j = 0
res = []
flag = 0
while j < n:
	(X, Y) = (k[j][0], k[j][1])
	if v[Y] == X:
		res.append(Y)
	else:
		flag = 1
		break
	j += 1
if flag == 1:
	print(-1)
else:
	print(*res)


import sys
import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, m) = map(int, input().split())
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)
t = list(map(int, input().split()))
for node in range(n):
	topic = t[node]
	if topic > len(graph[node]) + 1:
		print(-1)
		exit(0)
	seen = [False] * topic
	seen[0] = True
	for i in graph[node]:
		if t[i] == topic:
			print(-1)
			exit(0)
		if t[i] < topic:
			seen[t[i]] = True
	if all(seen):
		continue
	print(-1)
	exit(0)
t = [(i + 1, j) for (i, j) in enumerate(t)]
t.sort(key=lambda x: x[1])
sys.stdout.write(' '.join((str(i) for (i, j) in t)))
print()


import sys
read = sys.stdin.buffer.readline
mi = lambda dt: map(dt, read().split())
cin = lambda : int(read())
for _ in range(1):
	(n, m) = mi(int)
	g = {i: [] for i in range(n)}
	for i in range(m):
		(u, v) = mi(int)
		g[u - 1].append(v - 1)
		g[v - 1].append(u - 1)
	vis = [0] * n
	t = list(mi(int))
	flag = True
	mx = max(t)
	d = {i: [] for i in range(1, mx + 1)}
	for i in range(n):
		d[t[i]].append(i)
	ans = []
	for i in range(1, mx + 1):
		for el in d[i]:
			ss = set()
			for j in g[el]:
				ss.add(vis[j])
			sm = 0
			for ell in ss:
				sm += ell
			n = i - 1
			if sm == n * (n + 1) // 2:
				vis[el] = i
				ans.append(el)
			else:
				flag = False
				break
		if flag == False:
			break
	if flag == False:
		print(-1)
	else:
		for el in ans:
			print(el + 1, end=' ')


import sys
from collections import defaultdict as dd
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()
(n, m) = map(int, input().split())
g = [[] for i in range(n)]
for i in range(m):
	(q, w) = map(int, input().split())
	g[q - 1].append(w - 1)
	g[w - 1].append(q - 1)
a = list(map(int, input().split()))
e = sorted(list(range(n)), key=lambda k: a[k])
r = [1] * n
z = []
for i in e:
	s = a[i]
	if r[i] != s:
		print(-1)
		exit()
	for j in g[i]:
		if r[j] == s:
			r[j] += 1
	z.append(i + 1)
print(*z)


import sys
input = sys.stdin.buffer.readline
(n, m) = [int(c) for c in input().split()]
graph = {i: [] for i in range(n + 1)}
for _ in range(m):
	(u, v) = [int(c) for c in input().split()]
	graph[u].append(v)
	graph[v].append(u)
arr = [int(i) for i in input().split()]
inn = {i: [] for i in range(1, n + 1)}
ans = [0 for i in range(n + 1)]
last = [0 for i in range(n + 1)]
for i in range(len(arr)):
	inn[arr[i]].append(i + 1)
result = [0 for i in range(n)]
o = 0
for i in range(1, n + 1):
	for node in inn[i]:
		for v in graph[node]:
			last[ans[v]] = node
		ans[node] = 1
		while last[ans[node]] == node:
			ans[node] += 1
		if ans[node] != i:
			print(-1)
			sys.exit()
		result[o] = node
		o += 1
print(*result)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
import bisect
import heapq
from math 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

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))
inp = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 1000000007

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 graph(vertex):
	return [[] for i in range(0, vertex + 1)]

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 lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

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():
	(n, m) = sep()
	g = graph(n)
	for i in range(0, m):
		(u, v) = sep()
		g[u].append(v)
		g[v].append(u)
	topic = lis()
	new = []
	for i in range(1, n + 1):
		new.append([topic[i - 1], i])
	new.sort(key=lambda x: x[0])
	temp = []
	pos = [0] * (n + 1)
	for i in range(0, len(new)):
		temp.append(new[i][1])
		pos[temp[i]] = i + 1
	flag = True
	chck = [0] * (n + 1)
	l = 0
	for i in temp:
		f = False
		cnt = 0
		for j in g[i]:
			if pos[j] > pos[i]:
				continue
			if topic[j - 1] < topic[i - 1]:
				if chck[topic[j - 1]] <= l:
					cnt += 1
					chck[topic[j - 1]] = l + 1
			else:
				f = True
				break
		if f:
			out(-1)
			nextline()
			flag = False
			break
		elif cnt != topic[i - 1] - 1:
			out(-1)
			nextline()
			flag = False
			break
		l += 1
	if flag:
		printlist(temp)
testcase(1)


import sys
import os, io

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

def print_list(l):
	print(' '.join(map(str, l)))
from collections import defaultdict
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, m) = map(int, input().split())
dic_neig = defaultdict(list)
for _ in range(m):
	(a, b) = map(int, input().split())
	dic_neig[a].append(b)
	dic_neig[b].append(a)
t = list(map(int, input().split()))
for blog in dic_neig:
	dic_neig[blog] = set((t[i - 1] for i in dic_neig[blog]))
flag = True
for blog in range(1, n + 1):
	topic = t[blog - 1]
	if len(dic_neig[blog]) < topic - 1:
		flag = False
		break
	if not dic_neig[blog]:
		continue
	if topic in dic_neig[blog]:
		flag = False
		break
	if not set(range(1, topic)) <= dic_neig[blog]:
		flag = False
		break
if not flag:
	print(-1)
else:
	dic_topic = defaultdict(list)
	for i in range(n):
		dic_topic[t[i]].append(i + 1)
	res = []
	for i in range(1, n + 1):
		if not dic_topic[i]:
			break
		res += dic_topic[i]
	print_list(res)


from collections import Counter
from collections import defaultdict
from collections import deque
import math
import heapq
import sys
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from bisect import *
rs = lambda : input().strip()
ri = lambda : int(input())
rl = lambda : list(map(int, input().split()))
rls = lambda : list(map(str, input().split()))
(n, m) = rl()
d = []
for i in range(0, n + 1):
	d.append([])
for i in range(0, m):
	(a, b) = rl()
	d[a].append(b)
	d[b].append(a)
a = rl()
l = []
for i in range(1, n + 1):
	l.append([a[i - 1], i])
l.sort(key=lambda x: x[0])
blog = [100002] * (n + 1)
vis = [0] * (n + 1)
f = 1
for i in range(0, n):
	vis = [0] * (l[i][0] + 1)
	c = 0
	for j in d[l[i][1]]:
		if blog[j] < l[i][0] and vis[blog[j]] == 0:
			vis[blog[j]] = 1
			c = c + 1
		elif blog[j] == l[i][0]:
			c = -2
			break
	if l[i][0] - 1 != c:
		f = 0
		break
	blog[l[i][1]] = l[i][0]
if f:
	for i in range(0, n):
		print(l[i][1], end=' ')
	print()
else:
	print(-1)


import sys
readline = sys.stdin.buffer.readline
readall = 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()
	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)
	t = nl()
	c = [1] * n
	g = sorted(list(range(n)), key=lambda x: t[x])
	for x in g:
		if c[x] != t[x]:
			print(-1)
			return
		c[x] = t[x]
		for v in G[x]:
			if c[v] == t[x]:
				c[v] += 1
	g = [x + 1 for x in g]
	print(*g)
	return
solve()


from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor, inf
from heapq import *
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())
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
farr = [1]
ifa = []

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	ifa.append(pow(farr[-1], mod - 2, mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa = ifa[::-1]

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

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

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

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 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 flag

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

def GP(it):
	return [[ch, len(list(g))] for (ch, g) in groupby(it)]

class DLN:

	def __init__(self, val):
		self.val = val
		self.pre = None
		self.next = None

def nb(i, j):
	for (ni, nj) in [[i + 1, j], [i - 1, j], [i, j - 1], [i, j + 1]]:
		if 0 <= ni < n and 0 <= nj < m:
			yield (ni, nj)

@bootstrap
def gdfs(r, p):
	if len(g[r]) == 1 and p != -1:
		yield None
	for ch in g[r]:
		if ch != p:
			yield gdfs(ch, r)
	yield None
t = 1
for i in range(t):
	(n, m) = RL()
	g = [[] for i in range(n + 1)]
	for i in range(m):
		(a, b) = RL()
		g[a].append(b)
		g[b].append(a)
	t = RLL()
	res = sorted(((t[i], i + 1) for i in range(n)))
	c = [1] * (n + 1)
	p = []
	for (order, i) in res:
		if order != c[i]:
			print(-1)
			exit()
		for v in g[i]:
			if c[v] == order:
				c[v] += 1
		p.append(i)
	print(*p)


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

def main():
	(n, m) = RL()
	gp = [[] for _ in range(n + 1)]
	for _ in range(m):
		(a, b) = RL()
		gp[a].append(b)
		gp[b].append(a)
	arr = RLL()
	sarr = sorted([(v, i + 1) for (i, v) in enumerate(arr)])
	res = []
	rec = [1] * (n + 1)
	tag = True
	for (dg, ind) in sarr:
		if rec[ind] == dg:
			for nei in gp[ind]:
				if rec[nei] == dg:
					rec[nei] += 1
		else:
			tag = False
			break
		res.append(ind)
	if tag:
		print(*res)
	else:
		print(-1)
main()


import sys, os, io
I = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, m) = map(int, I().split())
adj = [list() for _ in range(1 + n)]
for _ in range(m):
	(u, v) = map(int, I().split())
	adj[u].append(v)
	adj[v].append(u)
val = [0] + list(map(int, I().split()))
mval = [0 for _ in range(1 + n)]
start_order = sorted(list(range(1, 1 + n)), key=lambda x: val[x])
ok = True
for u in start_order:
	if not ok or mval[u] != val[u] - 1:
		ok = False
		break
	for v in adj[u]:
		if val[v] > val[u] and mval[v] < val[u] - 1:
			ok = False
			break
		mval[v] = val[u]
if ok:
	sys.stdout.write(' '.join((str(i) for i in start_order)))
else:
	print(-1)


import os, io
from sys import stdout
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def main():
	(n, m) = map(int, input().split())
	e = [[] for i in range(n)]
	for i in range(m):
		(a, b) = map(int, input().split())
		a -= 1
		b -= 1
		e[a].append(b)
		e[b].append(a)
	l = [[x, i] for (i, x) in enumerate(map(int, input().split()))]
	l.sort()
	d = [-1] * n
	ans = []
	for i in range(n):
		(x, ind) = l[i]
		ans.append(ind + 1)
		now = 0
		s = set()
		for j in e[ind]:
			if d[j] > 0:
				now = max(now, d[j])
				s.add(d[j])
		if now + 1 != x or len(s) != x - 1:
			print(-1)
			exit()
		d[ind] = x
	print(*ans)
main()


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from operator import itemgetter
(n, m) = map(int, input().split())
E = [[] for i in range(n + 1)]
for i in range(m):
	(x, y) = map(int, input().split())
	E[x].append(y)
	E[y].append(x)
T = list(map(int, input().split()))
T_INV = [(T[i], i + 1) for i in range(n)]
T_INV.sort(key=itemgetter(0))
LOWEST = [1] * (n + 1)
for (top, ind) in T_INV:
	if LOWEST[ind] == top:
		for to in E[ind]:
			if LOWEST[to] == top:
				LOWEST[to] += 1
	else:
		print(-1)
		break
else:
	ANS = [T_INV[i][1] for i in range(n)]
	print(*ANS)


import sys
from collections import deque
input = sys.stdin.buffer.readline
(n, m) = map(int, input().split())
e = [[] for _ in range(n + 1)]
for _ in range(m):
	(a, b) = map(int, input().split())
	e[a].append(b)
	e[b].append(a)
tg = [0] + list(map(int, input().split()))
te = [[] for _ in range(n + 1)]
incc = [0] * (n + 1)
for u in range(1, n + 1):
	for v in e[u]:
		if tg[v] > tg[u]:
			te[u].append(v)
			incc[v] += 1
res = []
q = deque([u for u in range(1, n + 1) if incc[u] == 0])
while q:
	u = q.popleft()
	res.append(u)
	for v in te[u]:
		incc[v] -= 1
		if incc[v] == 0:
			q.append(v)
if len(res) != n:
	print(-1)
	exit()
topic = [0] * (n + 1)
for u in res:
	(cc, utp) = ([0] * tg[u], tg[u])
	for v in e[u]:
		vtp = topic[v]
		if vtp == utp:
			print(-1)
			exit()
		elif 0 < vtp < utp:
			cc[vtp] = 1
	if sum(cc) != utp - 1:
		print(-1)
		exit()
	topic[u] = utp
print(*res)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, m) = map(int, input().split())
graph = []
for i in range(n + 1):
	graph.append([])
for i in range(m):
	(a, b) = map(int, input().split())
	graph[a].append(b)
	graph[b].append(a)
temp = list(map(int, input().split()))
t = []
for i in range(n):
	t.append([i + 1, temp[i]])
t = sorted(t, key=lambda student: student[1])
failflag = 0
for i in range(1, n + 1):
	usedcolours = []
	for j in graph[i]:
		usedcolours.append(temp[j - 1])
	usedcolours.sort()
	tempans = 1
	for j in usedcolours:
		if tempans == j:
			tempans += 1
			continue
		if tempans == j + 1:
			continue
		else:
			break
	if tempans != temp[i - 1]:
		failflag = 1
		break
ans = []
for i in range(n):
	ans.append(t[i][0])
if failflag == 1:
	print(-1)
else:
	for i in ans:
		print(i)


import sys
input = sys.stdin.buffer.readline
from collections import deque

class Graph(object):

	def __init__(self, n, d):
		self.n = n
		self.graph = [[] for i in range(n)]
		self.parent = [-1 for i in range(n)]
		self.directed = d

	def addEdge(self, x, y):
		self.graph[x].append(y)
		if not self.directed:
			self.graph[y].append(x)

	def bfs(self, root):
		self.parent = [-1 for i in range(self.n)]
		queue = [root]
		queue = deque(queue)
		vis = [0] * self.n
		while len(queue) != 0:
			element = queue.popleft()
			vis[element] = 1
			for i in self.graph[element]:
				if vis[i] == 0:
					queue.append(i)
					self.parent[i] = element

	def dfs(self, root, ans):
		stack = [root]
		vis = [0] * self.n
		stack2 = []
		while len(stack) != 0:
			element = stack.pop()
			if vis[element]:
				continue
			vis[element] = 1
			stack2.append(element)
			for i in self.graph[element]:
				if vis[i] == 0:
					self.parent[i] = element
					stack.append(i)
		while len(stack2) != 0:
			element = stack2.pop()
			m = 0
			for i in self.graph[element]:
				if i != self.parent[element]:
					m += ans[i]
			ans[element] = m
		return ans

	def shortestpath(self, source, dest):
		self.bfs(source)
		path = [dest]
		while self.parent[path[-1]] != -1:
			path.append(parent[path[-1]])
		return path[::-1]

	def ifcycle(self):
		self.bfs(0)
		queue = [0]
		vis = [0] * n
		queue = deque(queue)
		while len(queue) != 0:
			element = queue.popleft()
			vis[element] = 1
			for i in graph[element]:
				if vis[i] == 1 and i != parent[element]:
					return True
				if vis[i] == 0:
					queue.append(i)
					vis[i] = 1
		return False

	def reroot(self, root, ans):
		stack = [root]
		vis = [0] * n
		while len(stack) != 0:
			e = stack[-1]
			if vis[e]:
				stack.pop()
				continue
			vis[e] = 1
			for i in graph[e]:
				if not vis[e]:
					stack.append(i)
			if self.parent[e] == -1:
				continue

	def check(self, node, blog):
		done = {}
		for i in self.graph[node]:
			if i in b and b[i] < blog:
				done[b[i]] = 1
			if i in b and b[i] == blog:
				return False
		if len(done) == blog - 1:
			return True
		return False
(n, m) = map(int, input().split())
g = Graph(n + 1, False)
for i in range(m):
	(a, b) = map(int, input().split())
	g.addEdge(a, b)
t = list(map(int, input().split()))
l = {}
for i in range(1, n + 1):
	if t[i - 1] not in l:
		l[t[i - 1]] = [i]
	else:
		l[t[i - 1]].append(i)
d = {}
b = {}
ans = []
i = 1
flag = 0
while len(d) != n:
	if i not in l:
		flag = 1
		break
	for j in l[i]:
		if not g.check(j, i):
			flag = 1
			break
		else:
			d[j] = 1
			b[j] = i
			ans.append(j)
	if flag:
		break
	i += 1
if flag:
	print(-1)
	exit()
print(' '.join(map(str, ans)))


import sys
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = lambda : sys.stdin.buffer.readline().rstrip()
(n, m) = map(int, input().split())
g = [[] for i in range(n)]
for i in range(m):
	(q, w) = map(int, input().split())
	g[q - 1].append(w - 1)
	g[w - 1].append(q - 1)
a = list(map(int, input().split()))
e = sorted(list(range(n)), key=lambda k: a[k])
r = [1] * n
z = []
for i in e:
	s = a[i]
	if r[i] != s:
		print(-1)
		exit()
	for j in g[i]:
		if r[j] == s:
			r[j] += 1
	z.append(i + 1)
print(*z)


import sys
readline = sys.stdin.buffer.readline
(N, M) = map(int, readline().split())
Edge = [[] for _ in range(N)]
for _ in range(M):
	(a, b) = map(int, readline().split())
	a -= 1
	b -= 1
	Edge[a].append(b)
	Edge[b].append(a)
topic = list(map(int, readline().split()))
maxi = [0] * N
L = list(range(N))
L.sort(key=lambda x: topic[x])
ans = ' '.join(map(str, [l + 1 for l in L]))
for l in L:
	t = maxi[l] + 1
	if t != topic[l]:
		ans = -1
		break
	for vf in Edge[l]:
		if maxi[vf] == t - 1:
			maxi[vf] = t
print(ans)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, m) = map(int, input().split())
edgeList = []
for _ in range(n):
	edgeList.append([])
for _ in range(m):
	(a, b) = map(int, input().split())
	edgeList[a - 1].append(b - 1)
	edgeList[b - 1].append(a - 1)
topic = list(map(int, input().split()))
isConfigPossible = True
for i in range(n):
	topicCovered = []
	for j in edgeList[i]:
		topicCovered.append(topic[j])
	topicCovered.sort()
	curTopic = 1
	for elem in topicCovered:
		if curTopic < elem:
			break
		elif curTopic == elem:
			curTopic += 1
	if curTopic != topic[i]:
		isConfigPossible = False
		break
if isConfigPossible:
	topicWithIndex = []
	for i in range(n):
		topicWithIndex.append((topic[i], i))
	topicWithIndex.sort(key=lambda x: x[0])
	res = []
	for elem in topicWithIndex:
		res.append(str(elem[1] + 1))
	print(' '.join(res))
else:
	print(-1)


import io
import os

def argsort(seq):
	return sorted(range(len(seq)), key=seq.__getitem__)
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, m) = map(int, input().split())
edges = [[] for _ in range(n)]
blog = [int(1) for _ in range(n)]
for _ in range(m):
	(a, b) = map(int, input().split())
	edges[a - 1].append(b - 1)
	edges[b - 1].append(a - 1)
t = list(map(int, input().split()))
ans = [int(0) for _ in range(n)]
count = 0
for (count, i) in enumerate(argsort(t)):
	ans[count] = i + 1
	for e in edges[i]:
		if blog[e] == t[i]:
			blog[e] += 1
if blog == t:
	print(' '.join(map(str, ans)))
else:
	print(-1)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def f():
	(n, m) = [int(s) for s in input().split()]
	neibors = [[] for _ in range(n)]
	for _ in range(m):
		(a, b) = [int(s) - 1 for s in input().split()]
		neibors[a].append(b)
		neibors[b].append(a)
	t = [int(s) for s in input().split()]

	def countSmaller(nbs, e):
		s = {t[x] for x in nbs}
		ans = 0
		for x in s:
			if x <= e:
				ans += 1
		return ans
	smlCount = [countSmaller(neibors[i], t[i]) for i in range(n)]
	ind = list(range(n))
	ind.sort(key=lambda x: t[x])
	for i in ind:
		if t[i] - 1 != smlCount[i]:
			print(-1)
			return
	print(' '.join((str(i + 1) for i in ind)))
f()


import sys
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from collections import defaultdict
graph = defaultdict(list)
(n, m) = map(int, input().split())
for i in range(m):
	(a, b) = map(int, input().split())
	graph[a].append(b)
	graph[b].append(a)
visited = [0] * (n + 1)
topics = [int(i) for i in input().split()]
for i in range(n):
	topics[i] = [topics[i], i + 1]
copy = topics[:]
topics.sort()
ans = []
for i in topics:
	seta = set()
	for j in graph[i[1]]:
		if visited[j] == 1:
			seta.add(copy[j - 1][0])
	if sum(seta) == i[0] * (i[0] - 1) // 2:
		ans.append(i[1])
		visited[i[1]] = 1
	else:
		print(-1)
		exit()
ans = ' '.join(map(str, ans))
sys.stdout.write(ans + '\n')


import sys
r = sys.stdin.buffer.readline
(n, m) = map(int, r().split())
network = [[] for _ in range(n)]
for _ in range(m):
	(a, b) = map(int, r().split())
	network[a - 1].append(b - 1)
	network[b - 1].append(a - 1)
lst = list(map(int, r().split()))
arr = list(range(n))
arr.sort(key=lambda x: lst[x])
ret = [1] * n
res = []
for i in arr:
	t = lst[i]
	if t == ret[i]:
		for j in network[i]:
			if ret[j] == t:
				ret[j] += 1
		res.append(i + 1)
	else:
		print(-1)
		exit(0)
print(*res)