#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
    char c=getchar();bool f=0;x=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return x;
}
template<class t> inline void write(t x){
    if(x<0) putchar('-'),write(-x);
    else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=3e5+5;
bool v[N];
int a[N],ans[N],n,m,X,l,r;
vector<pair<int,int>> g[N];

void dfs(int x){
	v[x]=1;
	for(auto e:g[x]){
		int y=e.first,i=e.second;
		if(v[y]) continue;
		dfs(y);
		if(a[x]+a[y]>=X) a[x]+=a[y]-X,ans[++l]=i;
		else ans[--r]=i;
	}
}

signed main(){
	read(n);read(m);read(X);
	for(int i=1;i<=n;i++) read(a[i]);
	if(accumulate(a+1,a+1+n,0ll)<X*(n-1)) return puts("NO"),0;
	puts("YES");
	for(int i=1,x,y;i<=m;i++){
		read(x);read(y);
		g[x].emplace_back(y,i);
		g[y].emplace_back(x,i);
	}
	l=0;r=n;
	dfs(1);
	for(int i=1;i<n;i++) write(ans[i]),puts("");
}