#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 2;
int num[N], cnt[N];
vector<int> lis[N];
priority_queue<pair<int, int> > pq;
pair<int, int> fr[N];
bool used[N];
vector<int> ans;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, i, j, k, l;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> num[i];
  }
  for (i = 1; i <= m; i++) {
    cin >> j >> k;
    fr[i] = {j, k};
    lis[j].push_back(i);
    lis[k].push_back(i);
  }
  for (i = 1; i <= n; i++) {
    cnt[i] = lis[i].size();
    pq.push({num[i] - cnt[i], i});
  }
  while (pq.size()) {
    j = pq.top().first;
    k = pq.top().second;
    pq.pop();
    if (j != num[k] - cnt[k]) {
      continue;
    }
    if (j < 0) {
      cout << "DEAD";
      return 0;
    }
    for (i = 0; i < lis[k].size(); i++) {
      j = lis[k][i];
      if (!used[j]) {
        used[j] = true;
        if (fr[j].first == k) {
          swap(fr[j].first, fr[j].second);
        }
        l = fr[j].first;
        cnt[l]--;
        pq.push({num[l] - cnt[l], l});
        ans.push_back(j);
      }
    }
    cnt[k] = 0;
  }
  cout << "ALIVE\n";
  for (i = ans.size() - 1; i > -1; i--) {
    cout << ans[i] << ' ';
  }
}
