#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1},
          dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U>
inline bool chmax(T &a, U b) {
  return a < b ? (a = b, true) : false;
}
template <typename T, typename U>
inline bool chmin(T &a, U b) {
  return a > b ? (a = b, true) : false;
}
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> w(n);
  for (int i = (0); i < (n); ++i) cin >> w[i];
  vector<int> x(m), y(m);
  vector<set<int>> g(n);
  for (int i = (0); i < (m); ++i) {
    cin >> x[i] >> y[i], --x[i], --y[i];
    --w[x[i]];
    --w[y[i]];
    g[x[i]].emplace(i);
    g[y[i]].emplace(i);
  }
  set<pair<int, int>> que;
  for (int i = (0); i < (n); ++i) que.emplace(w[i], i);
  vector<int> ans;
  while (!que.empty()) {
    auto [wei, idx] = *que.rbegin();
    que.erase(make_pair(wei, idx));
    if (wei < 0) {
      cout << "DEAD\n";
      return 0;
    }
    for (int e : g[idx]) {
      ans.emplace_back(e);
      int oth = x[e] == idx ? y[e] : x[e];
      g[oth].erase(e);
      que.erase(make_pair(w[oth], oth));
      ++w[oth];
      que.emplace(w[oth], oth);
    }
  }
  cout << "ALIVE\n";
  reverse((ans).begin(), (ans).end());
  for (int i = (0); i < (m); ++i) cout << ans[i] + 1 << " \n"[i + 1 == m];
  return 0;
}
