#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
const long long oo = 1e18;
const long long N = 2e5 + 100;
const long long M = 7776;
long long n, m;
long long w[N], deg[N];
pair<long long, long long> request[N];
vector<long long> result, cand;
vector<pair<long long, long long> > vi[N];
set<pair<long long, long long> > st;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 1; i <= n; ++i) cin >> w[i];
  for (long long i = 1; i <= m; ++i) {
    long long u, v;
    cin >> u >> v;
    vi[u].push_back({v, i});
    vi[v].push_back({u, i});
  }
  long long cnt = 0;
  for (long long i = 1; i <= n; ++i) deg[i] = (long long)(vi[i].size());
  for (long long i = 1; i <= n; ++i)
    if (deg[i] <= w[i]) {
      cand.push_back(i);
    }
  while (!cand.empty()) {
    auto unext = cand.back();
    cand.pop_back();
    if (!deg[unext]) continue;
    for (auto v : vi[unext])
      if (deg[v.first] > 0) {
        deg[v.first] -= 1;
        result.push_back(v.second);
        cnt += 1;
      }
    deg[unext] = 0;
    for (auto v : vi[unext])
      if (deg[v.first] > 0 && deg[v.first] <= w[v.first])
        cand.push_back(v.first);
  }
  if (cnt < m) return cout << "DEAD", 0;
  cout << "ALIVE\n";
  for (long long i = m; i >= 1; --i) cout << result[i - 1] << ' ';
  return 0;
}
