#include<bits/stdc++.h>
using namespace std;
#define Re register int
typedef long long ll;

const int N = 300005;
int n, m, cnt, res, hea[N], nxt[N << 1], to[N << 1], id[N << 1], f[N], d[N];
ll t, a[N], sum;

inline int read()
{
	char c = getchar();
	int ans = 0;
	while (c < 48 || c > 57) c = getchar();
	while (c >= 48 && c <= 57) ans = (ans << 3) + (ans << 1) + (c ^ 48), c = getchar();
	return ans;
}

inline void write(int x)
{
	int num = 0;
	char sc[15];
	while (x) sc[++num] = x % 10 + 48, x /= 10;
	while (num) putchar(sc[num--]);
	putchar('\n');
}

inline int find_fa(int x)
{
	return f[x] ^ x ? f[x] = find_fa(f[x]) : x;
}

inline void add(int x, int y, int z)
{
	nxt[++cnt] = hea[x], to[cnt] = y, id[cnt] = z, hea[x] = cnt;
}

inline void dfs(int x)
{
	for (Re i = hea[x]; i; i = nxt[i])
	{
		int u = to[i];
		if (u == f[x]) continue;
		f[u] = x;
		dfs(u);
		if (a[u] + a[x] >= t) write(id[i]), a[x] += a[u] - t;
		else d[++res] = id[i];
	}
}

int main()
{
	n = read(), m = read(), t = read();
	for (Re i = 1; i <= n; ++i) a[i] = read(), sum += a[i], f[i] = i;
	if (sum < t * (n - 1))
	{
		puts("NO");
		return 0;
	}
	for (Re i = 1; i <= m; ++i)
	{
		int u = read(), v = read();
		if (find_fa(u) == find_fa(v)) continue;
		f[f[u]] = f[v], add(u, v, i), add(v, u, i);
	}
	f[1] = find_fa(1);
	for (Re i = 2; i <= n; ++i)
		if (find_fa(i) ^ f[1])
		{
			puts("NO");
			return 0;
		}
	puts("YES");
	for (Re i = 1; i <= n; ++i) f[i] = 0;
	dfs(1);
	while (res) write(d[res--]);
	return 0;
}