#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int, int>
#define vi vector<int>
const int mod = 1e9 + 7;
// const int mod = 998244353;
const int inf = 1e9;

struct edge {
    int to, id;
};

vector<edge> eg[300005];
int ans[300005];
int vis[300005];
ll a[300005], xx;
int st = 1, ed;

void dfs(int x) {
    vis[x] = 1;
    for (auto i : eg[x]) {
        if (vis[i.to]) continue;
        dfs(i.to);
        if (a[x] + a[i.to] >= xx) {
            a[x] += a[i.to] - xx;
            ans[st++] = i.id;
        } else {
            ans[ed--] = i.id;
        }
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n, m;
    cin >> n >> m >> xx;
    ed = n - 1;
    ll s = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        s += a[i];
        vis[i] = 0;
    }
    if (1ll * xx * (n - 1) > s) {
        cout << "NO\n";
    } else {
        for (int i = 1; i <= m; i++) {
            int x, y;
            cin >> x >> y;
            eg[x].push_back({y, i});
            eg[y].push_back({x, i});
        }
        dfs(1);
        cout << "YES\n";
        for (int i = 1; i < n; i++) {
            cout << ans[i] << '\n';
        }
    }
    // cout << endl;
    // system("pause");
}