#include <bits/stdc++.h>
using namespace std;
using ll = long long;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  while (cin >> n >> m) {
    vector<int> w(n + 1), x(m), y(m);
    vector<set<int>> members(n + 1);
    for (int i = 1; i <= n; ++i) cin >> w[i];
    for (int i = 0; i < m; ++i) {
      cin >> x[i] >> y[i];
      assert(1 <= x[i] && x[i] <= n);
      assert(1 <= y[i] && y[i] <= n);
      members[x[i]].emplace(i);
      members[y[i]].emplace(i);
      w[x[i]]--;
      w[y[i]]--;
    }
    vector<int> res;
    queue<int> que;
    vector<char> man_used(m);
    for (int i = 1; i <= n; ++i) {
      if (w[i] >= 0) {
        que.emplace(i);
      }
    }
    vector<pair<int, int>> to_erase;
    auto remove_member = [&](int dish, int man) {
      if (++w[dish] == 0) {
        que.emplace(dish);
      }
      to_erase.emplace_back(dish, man);
    };
    while (!que.empty()) {
      int v = que.front();
      que.pop();
      to_erase.clear();
      for (auto i : members[v]) {
        if (!man_used[i]) {
          man_used[i] = true;
          res.push_back(i);
          remove_member(x[i], i);
          remove_member(y[i], i);
        }
      }
      for (auto [dish, man] : to_erase) {
        members[dish].erase(man);
      }
    }
    if (res.size() == m) {
      cout << "ALIVE\n";
      for (int i = m - 1; i >= 0; --i) cout << res[i] + 1 << " ";
    } else {
      cout << "DEAD";
    }
    cout << "\n";
  }
}
