#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, p;
  cin >> n >> p;
  vector<long long int> w(n);
  for (long long int i = 0; i < n; i++) cin >> w[i];
  vector<vector<long long int> > cnt(p);
  vector<vector<long long int> > tree(n);
  vector<long long int> used(p);
  for (long long int i = 0; i < p; i++) {
    long long int x, y;
    cin >> x >> y;
    x--, y--;
    tree[x].push_back(i);
    tree[y].push_back(i);
    cnt[i].push_back(x);
    cnt[i].push_back(y);
  }
  queue<long long int> q;
  for (long long int x = 0; x < n; x++) {
    if (w[x] >= (long long int)tree[x].size()) {
      q.push(x);
    }
  }
  vector<long long int> ans;
  while (!q.empty()) {
    long long int nd = q.front();
    q.pop();
    for (long long int i = 0; i < (long long int)tree[nd].size(); i++) {
      long long int pers = tree[nd][i];
      if (!used[pers]) {
        used[pers] = true;
        ans.push_back(pers);
        w[cnt[pers][0]]++;
        w[cnt[pers][1]]++;
        if (w[cnt[pers][0]] >= (long long int)tree[cnt[pers][0]].size())
          q.push(cnt[pers][0]);
        if (w[cnt[pers][1]] >= (long long int)tree[cnt[pers][1]].size())
          q.push(cnt[pers][1]);
      }
    }
  }
  if ((long long int)ans.size() == p) {
    cout << "ALIVE\n";
    reverse(ans.begin(), ans.end());
    for (long long int i = 0; i < p; i++) cout << ans[i] + 1 << " ";
  } else
    cout << "DEAD";
}
