Phoenix's homeland, the Fire Nation had n cities that were connected by m roads, but the roads were all destroyed by an earthquake. The Fire Nation wishes to repair n-1 of these roads so that all the cities are connected again. 

The i-th city has a_i tons of asphalt. x tons of asphalt are used up when repairing a road, and to repair a road between i and j, cities i and j must have at least x tons of asphalt between them. In other words, if city i had a_i tons of asphalt and city j had a_j tons, there would remain a_i+a_j-x tons after repairing the road between them. Asphalt can be moved between cities if the road between them is already repaired.

Please determine if it is possible to connect all the cities, and if so, output any sequence of roads to repair.

Input

The first line contains integers n, m, and x (2 ≤ n ≤ 3 ⋅ 10^5; n-1 ≤ m ≤ 3 ⋅ 10^5; 1 ≤ x ≤ 10^9) — the number of cities, number of roads, and amount of asphalt needed to repair one road.

The next line contains n space-separated integer a_i (0 ≤ a_i ≤ 10^9) — the amount of asphalt initially at city i.

The next m lines contains two integers x_i and y_i (x_i≠ y_i; 1 ≤ x_i, y_i ≤ n) — the cities connected by the i-th road. It is guaranteed that there is at most one road between each pair of cities, and that the city was originally connected before the earthquake.

Output

If it is not possible to connect all the cities, print NO. Otherwise, print YES followed by n-1 integers e_1, e_2, ..., e_{n-1}, the order in which the roads should be repaired. e_i is the index of the i-th road to repair. If there are multiple solutions, print any.

Examples

Input


5 4 1
0 0 0 4 0
1 2
2 3
3 4
4 5


Output


YES
3
2
1
4


Input


2 1 2
1 1
1 2


Output


YES
1


Input


2 1 2
0 1
1 2


Output


NO


Input


5 6 5
0 9 4 0 10
1 2
1 3
2 3
3 4
1 4
4 5


Output


YES
6
4
1
2

Note

In the first example, the roads are repaired in the following order: 

  * Road 3 is repaired, connecting cities 3 and 4. City 4 originally had 4 tons of asphalt. After this road is constructed, 3 tons remain. 
  * Road 2 is repaired, connecting cities 2 and 3. The asphalt from city 4 can be transported to city 3 and used for the road. 2 tons remain. 
  * Road 1 is repaired, connecting cities 1 and 2. The asphalt is transported to city 2 and used for the road. 1 ton remain. 
  * Road 4 is repaired, connecting cities 4 and 5. The asphalt is transported to city 4 and used for the road. No asphalt remains. 

All the cities are now connected.

In the second example, cities 1 and 2 use all their asphalt together to build the road. They each have 1 ton, so together they have 2 tons, which is enough.

In the third example, there isn't enough asphalt to connect cities 1 and 2.

Source: codeforces | Difficulty: VERY_HARD
Tags: Graph algorithms

Graph traversal

Constructive algorithms

Greedy algorithms

Tree algorithms

Spanning trees


Solutions:
from collections import deque

class UnionFind:

	def __init__(self, n):
		self.parent = list(range(n))

	def find(self, a):
		acopy = a
		while a != self.parent[a]:
			a = self.parent[a]
		while acopy != a:
			(self.parent[acopy], acopy) = (a, self.parent[acopy])
		return a

	def union(self, a, b):
		self.parent[self.find(b)] = self.find(a)

def main():
	(n, m, x) = map(int, input().split())
	a = list(map(int, input().split()))
	edges = {}
	adj = [[] for _ in range(n)]
	for i in range(m):
		(p, q) = map(int, input().split())
		adj[p - 1].append(q - 1)
		adj[q - 1].append(p - 1)
		edges[p - 1, q - 1] = i
		edges[q - 1, p - 1] = i
	if sum(a) < x * (n - 1):
		print('NO')
	else:
		parent = [-1] * n
		parent[0] = -2
		sonCnt = [0] * n
		queue = [0]
		queueIndex = 0
		while len(queue) > queueIndex:
			cur = queue[queueIndex]
			queueIndex += 1
			for elem in adj[cur]:
				if parent[elem] == -1:
					parent[elem] = cur
					queue.append(elem)
					sonCnt[cur] += 1
		leaf = [i for i in range(n) if sonCnt[i] == 0]
		ans1 = []
		ans2 = []
		while leaf:
			cur = leaf.pop()
			if cur == 0:
				break
			if a[cur] + a[parent[cur]] >= x:
				a[parent[cur]] += a[cur]
				a[parent[cur]] -= x
				ans1.append(edges[parent[cur], cur])
			else:
				ans2.append(edges[parent[cur], cur])
			sonCnt[parent[cur]] -= 1
			if sonCnt[parent[cur]] == 0:
				leaf.append(parent[cur])
		print('YES')
		for elem in ans1:
			print(elem + 1)
		ans2.reverse()
		for elem in ans2:
			print(elem + 1)
main()


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

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

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

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

def AI(n, x):
	return [x] * n

def A2(n, m):
	return [[0] * m for i in range(n)]

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

def GP(it):
	return [[ch, len(list(g))] for (ch, g) in groupby(it)]
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
mod = 10 ** 9 + 7
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
	fact(x, mod)
	ifa.append(pow(farr[-1], mod - 2, mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa.reverse()

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 floorsum(a, b, c, n):
	if a == 0:
		return b // c * (n + 1)
	if a >= c or b >= c:
		return floorsum(a % c, b % c, c, n) + b // c * (n + 1) + a // c * n * (n + 1) // 2
	m = (a * n + b) // c
	return n * m - floorsum(c, c - b - 1, a, m - 1)

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

def lowbit(n):
	return n & -n

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 ST:

	def __init__(self, arr):
		n = len(arr)
		mx = n.bit_length()
		self.st = [[0] * mx for i in range(n)]
		for i in range(n):
			self.st[i][0] = arr[i]
		for j in range(1, mx):
			for i in range(n - (1 << j) + 1):
				self.st[i][j] = max(self.st[i][j - 1], self.st[i + (1 << j - 1)][j - 1])

	def query(self, l, r):
		if l > r:
			return -inf
		s = (r + 1 - l).bit_length() - 1
		return max(self.st[l][s], self.st[r - (1 << s) + 1][s])

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

class UF:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n
		self.size = AI(n, 1)
		self.edge = A(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:
			self.edge[pu] += 1
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			self.edge[pu] += self.edge[pv] + 1
			self.size[pu] += self.size[pv]
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv
			self.edge[pv] += self.edge[pu] + 1
			self.size[pv] += self.size[pu]

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 = AI(n, inf)
	d[s] = 0
	heap = [(0, s)]
	vis = A(n)
	while heap:
		(dis, u) = heappop(heap)
		if vis[u]:
			continue
		vis[u] = 1
		for (v, w) in graph[u]:
			if d[v] > d[u] + w:
				d[v] = d[u] + w
				heappush(heap, (d[v], v))
	return d

def bell(s, g):
	dis = AI(n, inf)
	dis[s] = 0
	for i in range(n - 1):
		for (u, v, w) in edge:
			if dis[v] > dis[u] + w:
				dis[v] = dis[u] + w
	change = A(n)
	for i in range(n):
		for (u, v, w) in edge:
			if dis[v] > dis[u] + w:
				dis[v] = dis[u] + w
				change[v] = 1
	return dis

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

def lis(nums):
	res = []
	for k in nums:
		i = bisect.bisect_left(res, k)
		if i == len(res):
			res.append(k)
		else:
			res[i] = k
	return len(res)

def RP(nums):
	n = len(nums)
	s = set(nums)
	d = {}
	for (i, k) in enumerate(sorted(s), 1):
		d[k] = i
	bi = BIT([0] * (len(s) + 1))
	ans = 0
	for i in range(n - 1, -1, -1):
		ans += bi.query(d[nums[i]] - 1)
		bi.update(d[nums[i]], 1)
	return ans

class DLN:

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

def nb(i, j, n, m):
	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)

def topo(n):
	q = deque()
	res = []
	for i in range(1, n + 1):
		if ind[i] == 0:
			q.append(i)
			res.append(i)
	while q:
		u = q.popleft()
		for v in g[u]:
			ind[v] -= 1
			if ind[v] == 0:
				q.append(v)
				res.append(v)
	return res

@bootstrap
def gdfs(r, p):
	for ch in g[r]:
		if ch != p:
			yield gdfs(ch, r)
	yield None

@bootstrap
def dfs(r, p):
	vis[r] = 1
	par[r] = p
	for ch in g[r]:
		if not vis[ch]:
			g2[r] += 1
			yield dfs(ch, r)
	yield None
t = 1
for i in range(t):
	(n, m, X) = RL()
	a = RLL()
	g = G(n)
	edge = {}
	g = G(n)
	g2 = A(n)
	par = AI(n, -1)
	for i in range(m):
		(x, y) = RL()
		x -= 1
		y -= 1
		if x > y:
			(x, y) = (y, x)
		edge[x, y] = i + 1
		g[x].append(y)
		g[y].append(x)
	if sum(a) < (n - 1) * X:
		print('NO')
		exit()
	vis = A(n)
	dfs(0, -1)
	q = deque()
	ans = []
	back = []
	for i in range(n):
		if not g2[i]:
			q.append(i)
	while q:
		u = q.popleft()
		v = par[u]
		if u > v:
			(x, y) = (v, u)
		else:
			(x, y) = (u, v)
		if v == -1:
			break
		if a[u] + a[v] >= X:
			a[v] = a[u] + a[v] - X
			ans.append(edge[x, y])
		else:
			back.append(edge[x, y])
		g2[v] -= 1
		if g2[v] == 0:
			q.append(v)
	back.reverse()
	ans = ans + back
	print('YES')
	for ind in ans:
		print(ind)


class DisjointSetUnion:

	def __init__(self, n, A):
		self.parent = list(range(n))
		self.size = [1] * n
		self.asp = A[:]
		self.num_sets = n
		self.adj = [[] for i in range(n)]
		self.bad = 0

	def find(self, a):
		acopy = a
		while a != self.parent[a]:
			a = self.parent[a]
		while acopy != a:
			(self.parent[acopy], acopy) = (a, self.parent[acopy])
		return a

	def union(self, a, b):
		(a, b) = (self.find(a), self.find(b))
		if a != b:
			if self.size[a] < self.size[b]:
				(a, b) = (b, a)
			if len(self.adj[a]) < len(self.adj[b]):
				(self.adj[a], self.adj[b]) = (self.adj[b], self.adj[a])
			self.adj[a].extend(self.adj[b])
			self.num_sets -= 1
			self.parent[b] = a
			self.size[a] += self.size[b]
			self.asp[a] += self.asp[b]
			self.asp[a] -= x

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets
import sys
input = sys.stdin.readline
(n, m, x) = map(int, input().split())
x = float(x)
a = list(map(float, input().split()))
if sum(a) < (n - 1) * x:
	print('NO')
	exit()
print('YES')
UF = DisjointSetUnion(n, a)
q = [i for i in range(n) if a[i] >= x]
edges = []
for i in range(m):
	(u, v) = map(int, input().split())
	u -= 1
	v -= 1
	edges.append((u, v))
	UF.adj[u].append(i)
	UF.adj[v].append(i)
out = []
curr = 0
for run in range(n - 1):
	done = False
	while q:
		ind = q.pop()
		if UF.parent[ind] == ind and UF.asp[ind] >= x:
			done = True
			while True:
				e = UF.adj[ind].pop()
				(u, v) = edges[e]
				if UF.find(u) == ind:
					(u, v) = (v, u)
				if UF.find(u) == ind:
					continue
				out.append(e)
				UF.union(u, v)
				w = UF.find(u)
				if UF.asp[w] >= x:
					q.append(w)
				break
		if done:
			break
	if not done:
		while curr < m:
			(u, v) = edges[curr]
			curr += 1
			u = UF.find(u)
			v = UF.find(v)
			if u != v:
				assert UF.asp[u] + UF.asp[v] >= x
				out.append(curr - 1)
				UF.union(u, v)
				w = UF.find(u)
				if UF.asp[w] >= x:
					q.append(w)
				break
print('\n'.join(map(lambda x: str(x + 1), out)))


import sys
from sys import stdin
from collections import deque

def merge(xx, yy):
	if len(xx) > len(yy):
		(xx, yy) = (yy, xx)
	for i in xx:
		yy.append(i)
	xx = yy
	return (xx, xx)

def uf_find(n, p):
	ufl = []
	while p[n] != n:
		ufl.append(n)
		n = p[n]
	for i in ufl:
		p[i] = n
	return n

def uf_union(a, b, p, rank, alis, elis):
	ap = uf_find(a, p)
	bp = uf_find(b, p)
	if ap == bp:
		return True
	else:
		(elis[ap], elis[bp]) = merge(elis[ap], elis[bp])
		if rank[ap] > rank[bp]:
			p[bp] = ap
			alis[ap] += alis[bp] - x
		elif rank[ap] < rank[bp]:
			p[ap] = bp
			alis[bp] += alis[ap] - x
		else:
			p[bp] = ap
			rank[ap] += 1
			alis[ap] += alis[bp] - x
		return False
(n, m, x) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
elis = [[] for i in range(n)]
for i in range(m):
	(u, v) = map(int, stdin.readline().split())
	u -= 1
	v -= 1
	elis[u].append((u, v, i))
	elis[v].append((u, v, i))
p = [i for i in range(n)]
rank = [0] * n
ans = []
q = deque([])
for i in range(n):
	if a[i] >= x:
		q.append(i)
while q:
	v = q.popleft()
	vp = uf_find(v, p)
	while a[vp] >= x and len(elis[vp]) > 0:
		(X, Y, index) = elis[vp][-1]
		del elis[vp][-1]
		if not uf_union(X, Y, p, rank, a, elis):
			ans.append(index + 1)
		vp = uf_find(v, p)
for i in range(n):
	if uf_find(i, p) == i:
		while len(elis[i]) > 0:
			(X, Y, index) = elis[i][-1]
			del elis[i][-1]
			(XP, YP) = (uf_find(X, p), uf_find(Y, p))
			if a[XP] + a[YP] >= x and (not uf_union(X, Y, p, rank, a, elis)):
				ans.append(index + 1)
			i = uf_find(i, p)
if len(ans) != n - 1:
	print('NO')
else:
	print('YES')
	print('\n'.join(map(str, ans)))


import sys

def input_as_list(offset=0):
	return [int(t) + offset for t in sys.stdin.readline().split()]
(n, m, x) = input_as_list()
a = input_as_list()
if sum(a) < (n - 1) * x:
	print('NO')
	exit(0)
g = [set() for _ in range(n)]
for i in range(m):
	(u, v) = input_as_list(offset=-1)
	g[u].add((i, v))
	g[v].add((i, u))
par = list(range(n))

def find(a):
	acopy = a
	while par[a] != a:
		a = par[a]
	while acopy != a:
		(acopy, par[acopy]) = (par[acopy], a)
	return a

def union(a, b):
	(a, b) = (find(a), find(b))
	if len(g[a]) < len(g[b]):
		(a, b) = (b, a)
	g[a].update(g[b])
	par[b] = a
from heapq import heappop, heappush
pq = []

def push(val, ver):
	heappush(pq, (-val, ver))

def pop():
	(val, ver) = heappop(pq)
	return (-val, ver)
for i in range(n):
	push(a[i], i)
ans = []
while len(ans) < n - 1:
	(val, ver) = pop()
	ver = find(ver)
	if val != a[ver]:
		continue
	while True:
		(i, nei) = g[ver].pop()
		if ver != find(nei):
			new_val = val + a[find(nei)] - x
			union(ver, nei)
			ver = find(ver)
			ans.append(i + 1)
			a[ver] = new_val
			push(new_val, ver)
			break
print('YES')
print(*ans, sep='\n')


import sys
f = sys.stdin

def line():
	return f.readline().strip().split()

def dfs(st):
	seen = [-1] * N
	q = [st]
	seen[st] = 0
	parent = [None] * N
	road = [None] * N
	front = []
	back = []
	while q:
		n = q[-1]
		chs = G[n]
		if seen[n] == len(chs):
			m = q.pop()
			if m != st:
				if A[m] + A[parent[m]] >= X:
					front.append(road[m])
					A[parent[m]] += A[m] - X
				else:
					back.append(road[m])
		else:
			(ch, r) = chs[seen[n]]
			if seen[ch] == -1:
				seen[ch] = 0
				q.append(ch)
				parent[ch] = n
				road[ch] = r
			seen[n] += 1
	back.reverse()
	return front + back

def solve():
	s = sum((v for v in A))
	if s < (N - 1) * X:
		return 'NO'
	res = dfs(0)
	return str('YES\n' + '\n'.join((str(v) for v in res)))
T = 1
for test in range(1, T + 1):
	(N, M, X) = map(int, line())
	A = list(map(int, line()))
	G = [[] for _ in range(N)]
	R = []
	for r in range(1, M + 1):
		(i, j) = map(int, line())
		G[i - 1].append((j - 1, r))
		G[j - 1].append((i - 1, r))
	print(solve())
f.close()


import sys
from heapq import heapify, heappop, _heapify_max, heappush, _heappop_max
f = sys.stdin

def line():
	return f.readline().strip().split()

class UnionFind:

	def __init__(self, n):
		self.link = [-1] * n
		self.rank = [0] * n

	def add_link(self, node, parent):
		self.link[node] = parent

	def find(self, x):
		l = []
		node = x
		parent = self.link[node]
		while parent != -1:
			l.append(node)
			node = parent
			parent = self.link[node]
		for element in l:
			self.link[element] = node
		return node

	def union(self, u, v):
		root_u = self.find(u)
		root_v = self.find(v)
		if root_u == root_v:
			return False
		rank_u = self.rank[root_u]
		rank_v = self.rank[root_v]
		if rank_u == rank_v:
			self.link[root_v] = root_u
			self.rank[root_u] += 1
		elif rank_u < rank_v:
			self.link[root_u] = root_v
		else:
			self.link[root_v] = root_u
		return True

def solve():
	s = sum((v for v in A))
	if s < (N - 1) * X:
		return 'NO'
	res = []
	q = [(-a, i) for (i, a) in enumerate(A)]
	heapify(q)
	uf = UnionFind(N)
	rem = [False] * N
	while len(q) > 1:
		(a, comp) = heappop(q)
		if rem[comp]:
			continue
		a = -a
		root_comp = uf.find(comp)
		while G[root_comp]:
			(tgt, r) = G[root_comp].pop()
			root_tgt = uf.find(tgt)
			if root_comp == root_tgt:
				continue
			tot = A[root_comp] + A[root_tgt] - X
			if tot >= 0:
				uf.union(root_comp, root_tgt)
				new_root = uf.find(root_comp)
				A[new_root] = tot
				G[new_root].extend(G[root_tgt] if new_root == root_comp else G[root_comp])
				rem[root_tgt if new_root == root_comp else root_comp] = True
				heappush(q, (-tot, new_root))
				res.append(r)
				break
	return str('YES\n' + '\n'.join((str(v) for v in res)))
T = 1
for test in range(1, T + 1):
	(N, M, X) = map(int, line())
	A = list(map(int, line()))
	G = [[] for _ in range(N)]
	for r in range(1, M + 1):
		(i, j) = map(int, line())
		G[i - 1].append((j - 1, r))
		G[j - 1].append((i - 1, r))
	print(solve())
f.close()


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

class UnionFind:

	def __init__(self, n):
		self.parent = list(range(n))

	def find(self, a):
		acopy = a
		while a != self.parent[a]:
			a = self.parent[a]
		while acopy != a:
			(self.parent[acopy], acopy) = (a, self.parent[acopy])
		return a

	def union(self, a, b):
		self.parent[self.find(b)] = self.find(a)

def main():
	(n, m, x) = map(int, input().split())
	a = list(map(int, input().split()))
	edges = {}
	adj = []
	for _ in range(n):
		adj.append([])
	for i in range(m):
		(p, q) = map(int, input().split())
		adj[p - 1].append(q - 1)
		adj[q - 1].append(p - 1)
		edges[p - 1, q - 1] = i
		edges[q - 1, p - 1] = i
	if sum(a) < x * (n - 1):
		print('NO')
	else:
		parent = [-1] * n
		parent[0] = -2
		sonCnt = [0] * n
		queue = [0]
		queueIndex = 0
		while len(queue) > queueIndex:
			cur = queue[queueIndex]
			queueIndex += 1
			for elem in adj[cur]:
				if parent[elem] == -1:
					parent[elem] = cur
					queue.append(elem)
					sonCnt[cur] += 1
		leaf = []
		for i in range(n):
			if sonCnt[i] == 0:
				leaf.append(i)
		ans1 = []
		ans2 = []
		while leaf:
			cur = leaf.pop()
			if cur == 0:
				break
			if a[cur] + a[parent[cur]] >= x:
				a[parent[cur]] += a[cur]
				a[parent[cur]] -= x
				ans1.append(edges[parent[cur], cur])
			else:
				ans2.append(edges[parent[cur], cur])
			sonCnt[parent[cur]] -= 1
			if sonCnt[parent[cur]] == 0:
				leaf.append(parent[cur])
		print('YES')
		for elem in ans1:
			print(elem + 1)
		ans2.reverse()
		for elem in ans2:
			print(elem + 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()