#include <bits/stdc++.h>
using namespace std;
template <class T>
struct rge {
  T b, e;
};
template <class T>
rge<T> range(T i, T j) {
  return rge<T>{i, j};
}
struct debug {
  template <class T>
  debug& operator<<(const T&) {
    return *this;
  }
};
using ll = long long;
template <typename T>
void min_self(T& a, T b) {
  a = min(a, b);
}
template <typename T>
void max_self(T& a, T b) {
  a = max(a, b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> want(n), have(n);
  for (int i = 0; i < n; i++) {
    cin >> have[i];
  }
  vector<vector<pair<int, int>>> g(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    ++want[u], ++want[v];
    g[u].emplace_back(v, i + 1);
    g[v].emplace_back(u, i + 1);
  }
  vector<bool> removed(n);
  vector<int> dat(n);
  for (int i = 0; i < n; i++) {
    dat[i] = have[i] - want[i];
  }
  vector<int> ans;
  set<pair<int, int>> s;
  for (int i = 0; i < n; i++) {
    s.emplace(dat[i], i);
  }
  function<void(void)> Rec = [&]() {
    if (s.empty()) {
      return;
    }
    pair<int, int> pp = *s.rbegin();
    debug() << "[ "
            << "pp"
               ": "
            << (pp) << " ] ";
    s.erase(pp);
    if (pp.first < 0) {
      cout << "DEAD\n";
      exit(0);
    }
    int u = pp.second;
    removed[u] = true;
    vector<int> now;
    for (pair<int, int> e : g[u]) {
      int v = e.first;
      int idx = e.second;
      if (!removed[v]) {
        s.erase(make_pair(dat[v], v));
        ++dat[v];
        s.emplace(dat[v], v);
        now.push_back(idx);
      }
    }
    Rec();
    debug() << "[ "
            << "u"
               ": "
            << (u) << " ] "
            << "[ "
            << "now"
               ": "
            << (now) << " ] ";
    for (int x : now) {
      ans.push_back(x);
    }
  };
  Rec();
  debug() << "[ "
          << "ans"
             ": "
          << (ans) << " ] ";
  cout << "ALIVE\n";
  assert((int)ans.size() == m);
  for (int x : ans) {
    cout << x << " ";
  }
  cout << "\n";
}
