//INJA IRAN AST!
#include <bits/stdc++.h>

using namespace std ;
 
typedef long long ll ;
typedef long double ld ;
typedef pair<ld ,int> pfi ;
typedef pair<int ,int> pii ; 
typedef pair<ll ,pii> pip ;

#define fast_io                ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define debug(x)               cerr << #x << " : " << x << endl
#define debugP(x ,y)           cerr << #x << "," << #y << " : " << x << "," << y << endl
#define def(arr ,x ,y)         cerr << arr << "[" << x << "] = " << y << endl 
#define here                   cerr << "here\n"
#define MP                     make_pair
#define F                      first
#define S                      second
 
constexpr int MAXN = 3e5 + 2 ;
constexpr int MOD = 1e9 + 9 ;
constexpr int INF = 1e9 + 9 ;
constexpr int LOG = 2e1 + 9 ;

struct edge {
	int u ,v ; 
	void get(){
		cin >> u >> v ; 
	}
};

ll n ,m ,x ,a[MAXN] ,sum[MAXN] ,par[MAXN] ,p[MAXN] ; 
vector <int> G[MAXN] ,G2[MAXN] ; 
edge e[MAXN] ; 
bool vis[MAXN] ; 
deque <int> st ,ed ; 

void dfs(int u){
	vis[u] = true ; 
	for (auto i: G[u]){
		int v = u ^ e[i].u ^ e[i].v ; 
		if (!vis[v]){
			G2[u].push_back(i) ; 
			G2[v].push_back(i) ; 
			par[v] = i ; 
			p[v] = u ; 
			dfs(v) ; 
		}
	}
}

void dfs1(int u){
	for (auto i : G2[u]){
		if (i != par[u]){
			int v = e[i].u ^ e[i].v ^ u ; 
			dfs1(v) ; 
		}
	}
	if (u - 1){
		if (a[p[u]] + a[u] >= x) {
			st.push_back(par[u])  ; 
			a[p[u]] += a[u] - x ; 
		}
		else {
			ed.push_front(par[u]) ; 
		}
	}
}

int main (){
	fast_io ;
	cin >> n >> m >> x ;  
	ll s = 0 ; 
	for (int i = 1; i <= n; i++){
		cin >> a[i] ; 
		s += a[i] ; 
	}
	if (s < (n - 1) * x){
		return cout << "NO\n" ,0 ; 
	}
	cout << "YES\n" ; 
	for (int i = 1; i <= m; i++){
		e[i].get() ; 
		G[e[i].u].push_back(i) ; 
		G[e[i].v].push_back(i) ;
	}
	dfs(1) ;
	dfs1(1) ; 
	while (!st.empty()){
		int u = st.front() ; 
		cout << u << "\n" ; 
		st.pop_front() ; 
	}
	while (!ed.empty()){
		int u = ed.front() ; 
		cout << u << "\n" ; 
		ed.pop_front() ;
	}
	return 0 ;
}
 
