#include <bits/stdc++.h>
using namespace std;
const long long OO = (4e18) + 9;
const int MOD = (1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int dX[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dY[] = {0, 1, 0, -1, 1, 1, -1, -1};
string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiou";
int dcmp(long double d1, long double d2) {
  return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1;
}
long long gcd(long long x, long long y) { return !y ? x : gcd(y, x % y); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
int ord(int r, int c, int nCol) { return (nCol * r) + c + 1; }
pair<int, int> rord(int n, int nCol) {
  int r = n % nCol, c = n / nCol;
  if (n % nCol == 0) c--, r = nCol;
  return pair<int, int>(r, c);
}
long long power(long long base, long long exp) {
  long long ans = 1;
  base %= MOD;
  while (exp > 0) {
    if (exp & 1) ans = (ans * base) % MOD;
    exp >>= 1;
    base = (base * base) % MOD;
  }
  return ans;
}
long long modInverse(long long a) { return power(a, MOD - 2); }
const int NN = 2000010;
long long fact[NN];
void init() {
  fact[0] = 1;
  for (int i = 1; i < NN; ++i) fact[i] = (fact[i - 1] * 1LL * i) % MOD;
}
int nCr(int n, int r) {
  return (fact[n] * modInverse(fact[r] * 1LL * fact[n - r])) % MOD;
}
int main() {
  int N = 1e5 + 10;
  int M = 1e6 + 10;
  int n, m;
  cin >> n >> m;
  vector<int> w(n + 1), cnt(N), ans;
  bool done[M];
  for (int i = 0; i < n; i++) cin >> w[i + 1];
  vector<pair<int, int> > v[N];
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    cnt[x]++, cnt[y]++;
    v[x].push_back({y, i + 1});
    v[y].push_back({x, i + 1});
  }
  queue<int> q;
  for (int i = 0; i < n; i++)
    if (cnt[i + 1] <= w[i + 1]) q.push(i + 1);
  while (not q.empty()) {
    int x = q.front();
    q.pop();
    for (auto [y, i] : v[x]) {
      if (done[i]) continue;
      done[i] = true;
      ans.push_back(i);
      cnt[y]--;
      if (cnt[y] == w[y]) q.push(y);
    }
  }
  if ((int)ans.size() != m) return puts("DEAD");
  cout << "ALIVE\n";
  reverse(ans.begin(), ans.end());
  for (int i = 0; i < m; i++) cout << ans[i] << " \n"[i == m - 1];
  return 0;
}
