    #include<cstdio>
    #include<map>
    #include<algorithm>
    #include<queue>
    #include<stack>
    using namespace std;
    const int maxn = 3e5+7;
    long long n,m,X,a[maxn],head[maxn],top,vis[maxn];
    long long tot;
    pair<int,int> r;
    map<pair<int,int>,int> M;
    queue<int> ans;
    stack<int> ans2;
    struct node
    {
        int to,next;
    }edge[maxn<<1];
    void addedge(int fr,int to)
    {
        edge[++top].next = head[fr];
        head[fr] = top;
        edge[top].to = to;
        return;
    }
    void dfs(int x,int fa)
    {
        vis[x] = 1;
        for(int i=head[x];i;i=edge[i].next)
            if(!vis[edge[i].to])dfs(edge[i].to,x);
        if(~fa)
            if(a[x] + a[fa] >=X)
            {
                ans.emplace(M[{x,fa}]);
                a[fa] = a[fa]+a[x] -X,a[x] = 0;
            }
            else ans2.emplace(M[{x,fa}]);
        return;
    }
    int main()
    {
        scanf("%d%d%d",&n,&m,&X);
        for(int i=1;i<=n;++i)
        {
            scanf("%d",&a[i]),tot+=a[i];
        }
        if(tot<(n-1ll)*X){puts("NO");return 0;}
        else puts("YES");
        for(int i=1;i<=m;++i)
        {
            scanf("%d%d",&r.first,&r.second);
            M[{r.first,r.second}] = i;
            M[{r.second,r.first}] = i;
            addedge(r.first,r.second);
            addedge(r.second,r.first);
        }
        dfs(1,-1);
        while(ans.size())printf("%d\n",ans.front()),ans.pop();
        while(ans2.size())printf("%d\n",ans2.top()),ans2.pop();
        return 0;
    }