#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
using namespace std;

const int MAX = 3e5 + 5;
ll x, summ;
ll city[MAX];
int bio[MAX];
vector<pair<int, int>> edges[MAX];
vector<int> sol1, sol2;


ll dfs (int a, int prev) {
    bio[a] = 1;
    for (auto e : edges[a]) {
        if (e.first == prev) continue;
        if (bio[e.fi]) continue;
        ll z = dfs(e.fi, a);
        if (z + city[a] >= x) {
            sol1.push_back(e.se);
            city[a] += z - x;
        }
        else {
            sol2.push_back(e.se);
        }
    }
    return city[a];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, a, b;
    cin >> n >> m >> x;

    for (int i = 1; i <= n; i++) cin >> city[i];
    for (int i = 1; i <= n; i++) summ += city[i];

    for (int i = 1; i <= m; i++) {
        cin >> a >> b;
        edges[a].push_back({b, i});
        edges[b].push_back({a, i});
    }

    if ((n - 1) * x > summ) {
        cout << "NO\n";
        return 0;
    }

    cout << "YES\n";

    dfs(1, 0);

    for (auto e : sol1) cout << e << "\n";
    reverse(sol2.begin(), sol2.end());
    for (auto e : sol2) cout << e << "\n";

    return 0;
}

