#include <bits/stdc++.h>
#define pii pair<int, int>
#define f first
#define s second
#define ll long long
#define oo 1000000000
#define piii pair<pii, int>
#define pb push_back

using namespace std;

struct DSU {
    int components;
    vector<int>par;
    DSU(int n) {
        par.assign(n, -1);
        components = n;
    }
    int Find(int u) {
        if(par[u] < 0) return u;
        else return par[u] = Find(par[u]);
    }
    bool Union(int u, int v) {
        u = Find(u);
        v = Find(v);
        if(u != v) {
            if(par[u] > par[v]) {
                swap(u, v);
            }
            par[u] += par[v];
            par[v] = u;
            --components;
            return true;
        }else {
            return false;
        }
    }
};

int x;
vector<ll>a;
vector<vector<pii>>g;
vector<int>res, wait;
void dfs(int node, pii par) {
    for(pii p : g[node]) {
        int to = p.f;
        if(to != par.f) {
            dfs(to, {node, p.s});
        }
    }
    if(par.f != -1) {
        if(a[node] >= x) {
            res.pb(par.s);
            a[par.f] += (a[node] - x);
        }else {
            wait.pb(par.s);
        }
    }
}
void solve() {
    int n, m;
    cin >> n >> m >> x;
    a.resize(n);
    g.resize(n);
    vector<pii>e(m);
    ll sum = 0;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    for(int i = 0; i < m; ++i) {
        cin >> e[i].f >> e[i].s;
        e[i].f--;
        e[i].s--;
    }
    if(sum < 1ll * (n - 1) * x) {
        cout << "NO\n";
    }else {
        cout << "YES\n";
        vector<int>taken;
        DSU dsu(n);
        for(int i = 0; i < m; ++i) {
            if(dsu.Union(e[i].f, e[i].s)) {
                g[e[i].f].pb({e[i].s, i});
                g[e[i].s].pb({e[i].f, i});
            }
        }
        dfs(0, {-1, -1});
        reverse(wait.begin(), wait.end());
        res.insert(res.end(), wait.begin(), wait.end());
        for(int i : res) {
            cout << i + 1 << '\n';
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}