#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 3;
long long int x[maxn], y[maxn];
long long int w[maxn];
int ct[maxn];
vector<int> v[maxn];
int ans[maxn];
int done_per[maxn];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> w[i];
  }
  memset(ct, 0, sizeof(ct));
  for (int i = 0; i < m; ++i) {
    cin >> x[i] >> y[i];
    ct[x[i] - 1]++;
    ct[y[i] - 1]++;
    x[i]--;
    y[i]--;
    v[x[i]].push_back(i);
    v[y[i]].push_back(i);
  }
  memset(done_per, 0, sizeof(done_per));
  vector<int> in;
  int last = m - 1;
  for (int i = 0; i < n; i++) {
    if (ct[i] <= w[i]) {
      in.push_back(i);
    }
  }
  if (in.size() == 0) {
    cout << "DEAD"
         << "\n";
    exit(0);
  }
  while (1) {
    vector<int> in1;
    for (int j = 0; j < (int)in.size(); j++) {
      int t1 = in[j];
      for (int i = 0; i < (int)v[t1].size(); i++) {
        if (!done_per[v[t1][i]]) {
          ans[last--] = v[t1][i];
          done_per[v[t1][i]] = 1;
          int temp = v[t1][i];
          if (x[temp] != t1) {
            ct[x[temp]]--;
            if (ct[x[temp]] <= w[x[temp]]) in1.push_back(x[temp]);
          } else {
            ct[y[temp]]--;
            if (ct[y[temp]] <= w[y[temp]]) in1.push_back(y[temp]);
          }
        }
      }
    }
    if (last == -1) break;
    if (in1.size() == 0) {
      cout << "DEAD"
           << "\n";
      exit(0);
    }
    in.clear();
    for (int t4 : in1) in.push_back(t4);
  }
  cout << "ALIVE"
       << "\n";
  for (int i = 0; i < m; i++) {
    cout << ans[i] + 1 << " ";
  }
  cout << endl;
}
