#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
template <typename T> inline void read(T &FF) {
	int RR = 1; FF = 0; char CH = getchar();
	for(; !isdigit(CH); CH = getchar()) if(CH == '-') RR = -RR;
	for(; isdigit(CH); CH = getchar()) FF = FF * 10 + CH - 48;
	FF *= RR;
}
inline void file(string str) {
	freopen((str + ".in").c_str(), "r", stdin);
	freopen((str + ".out").c_str(), "w", stdout);
}
const int N = 3e5 + 10;
stack<int> yi; vector<int> xi; LL ai[N]; int n, m, xx;
int now, fst[N], nxt[N << 1], num[N << 1], wi[N << 1], fa[N], vis[N];
void add(int u, int v, int w) {
	nxt[++now] = fst[u], fst[u] = now, num[now] = v, wi[now] = w;
	nxt[++now] = fst[v], fst[v] = now, num[now] = u, wi[now] = w;
}
int get_fa(int x) {
	return fa[x] == x ? x : fa[x] = get_fa(fa[x]);
}
void merge(int x, int y) {
	if(get_fa(x) == get_fa(y)) return;
	fa[get_fa(x)] = fa[y];
}
void dfs(int x) {
	vis[x] = 1;
	for(int i = fst[x]; i; i = nxt[i])
		if(!vis[num[i]]) {
			dfs(num[i]);
			if(ai[x] + ai[num[i]] >= xx)
				xi.push_back(wi[i]), ai[x] = ai[x] + ai[num[i]] - xx;
			else yi.push(wi[i]);
		}
}
int main() {
	//file("");
	int u, v; LL sum = 0;
	read(n), read(m), read(xx);
	for(int i = 1; i <= n; i++)
		fa[i] = i, read(ai[i]), sum += ai[i];
	for(int i = 1; i <= m; i++)
		read(u), read(v), add(u, v, i), merge(u, v);
	if(sum < (n - 1) * 1LL * xx) {
		puts("NO"); return 0;
	}
	for(int i = 1; i <= n; i++)
		if(get_fa(i) != get_fa(1)) {
			puts("NO");
			return 0;
		}
	dfs(1); puts("YES");
	//while(!xi.empty()) printf("%d\n", xi.top()), xi.pop();
	for(auto p : xi) printf("%d\n", p);
	while(!yi.empty()) printf("%d\n", yi.top()), yi.pop();
	return 0;
}