#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(register int i=(a);i>=(b);--i)
#define int long long
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 300005
int n,m,ff[maxn],x;
int a[maxn],val[maxn],sz[maxn];
inline int getf(int x){
	while(x!=ff[x])x=ff[x]=ff[ff[x]];
	return x;
}
vector<pii>e[maxn];

void dfs(int u,int pa){
	sz[u]=1,val[u]=a[u];
	for(auto it:e[u]){
		int v=it.fi;
		if(v!=pa) dfs(v,u),sz[u]+=sz[v],val[u]+=val[v];
	}
}

vector<int>res;

void work(int u,int pa)
{
	sort(e[u].begin(),e[u].end(),[&](pii a,pii b){
			int A=a.fi,B=b.fi;
			return val[A]-(sz[A]-1)*x > val[B]-(sz[B]-1)*x;
		}
	);
	for(auto it:e[u]){
		int v=it.fi,w=it.se;
		if(v==pa)continue;
		if(a[u]+a[v]>=x){
			res.pb(w);
			a[v]+=a[u]-x,work(v,u),a[u]=a[v];
		}else{
			work(v,u),res.pb(w);
			a[u]+=a[v]-x;
		}
	}
}

signed main()
{
	n=read(),m=read(),x=read();
	For(i,1,n)a[i]=read(),ff[i]=i;
	For(i,1,m){
		int u=read(),v=read();
		if(getf(u)!=getf(v)){
			ff[getf(u)]=getf(v);
			e[u].pb(mkp(v,i));
			e[v].pb(mkp(u,i));
		}
	}
	
	dfs(1,0);
	if(val[1] < (n-1)*x) return puts("NO")&0;
	puts("YES");
	work(1,0);
	
	for(auto x:res)cout<<x<<'\n';
	return 0;
}