#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=300010;
int n,m,u,v,eg,fa[MAXN],hd[MAXN],ver[2*MAXN],nx[2*MAXN],edge[2*MAXN];
ll sum,x,a[MAXN];
stack <int> ans2;
queue <int> ans1;
int findr (int x) {return (fa[x]==x?x:fa[x]=findr(fa[x]));}
void add_edge (int x,int y,int z) {
	ver[++eg]=y;
	nx[eg]=hd[x],edge[eg]=z;
	hd[x]=eg;
	return;
}
void dfs (int p,int fa,int bh) {
	for (int i=hd[p];i;i=nx[i]) {
		if (ver[i]==fa) {continue;}
		dfs(ver[i],p,edge[i]);
	}
	if (p==1) {return;}
	if (a[p]<x) {ans2.push(bh);}
	else {
		ans1.push(bh);
		a[fa]=a[fa]+a[p]-x;
	}
	return;
}
int main () {
	scanf("%d%d%lld",&n,&m,&x);
	for (int i=1;i<=n;i++) {
		fa[i]=i;
		scanf("%lld",&a[i]);
		sum+=a[i];
	}
	if (sum<1ll*(n-1)*x) {
		printf("NO\n");
		return 0;
	}
	for (int i=1;i<=m;i++) {
		scanf("%d%d",&u,&v);
		int fx=findr(u),fy=findr(v);
		if (fx!=fy) {
			add_edge(u,v,i),add_edge(v,u,i);
			fa[fx]=fy;
		}
	}
	if (eg!=2*(n-1)) {
		printf("NO\n");
		return 0;
	} 
	dfs(1,0,0);
	printf("YES\n");
	while (!ans1.empty()) {
		printf("%d\n",ans1.front());
		ans1.pop();
	}
	while (!ans2.empty()) {
		printf("%d\n",ans2.top());
		ans2.pop();
	}
	return 0;
}