#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int H, sum = 0;
  cin >> H;
  vector<int> t1, t2;
  vector<int> counts(H + 1);
  for (int i = 0; i < H + 1; ++i) {
    cin >> counts[i];
    sum += counts[i];
  }
  t1 = vector<int>(sum, -1);
  t2 = vector<int>(sum, -1);
  bool fault = false, last1 = true;
  int curt = -1;
  for (int i = 0; i < H + 1; ++i) {
    if (fault) {
      for (int j = 0; j < counts[i]; ++j) {
        t1[curt + j + 1] = curt;
        t2[curt + j + 1] = curt;
      }
    } else {
      if (counts[i] > 1) {
        if (last1) {
          for (int j = 0; j < counts[i]; ++j) {
            t1[curt + j + 1] = curt;
            t2[curt + j + 1] = curt;
          }
        } else {
          fault = true;
          t1[curt + 1] = curt;
          t2[curt + 1] = curt - 1;
          for (int j = 1; j < counts[i]; ++j) {
            t1[curt + j + 1] = curt;
            t2[curt + j + 1] = curt;
          }
        }
        last1 = false;
      } else {
        t1[curt + 1] = curt;
        t2[curt + 1] = curt;
        last1 = true;
      }
    }
    curt = curt + counts[i];
  }
  if (fault) {
    cout << "ambiguous" << endl;
    for (int a : t1) {
      cout << a + 1 << " ";
    }
    cout << endl;
    for (int a : t2) {
      cout << a + 1 << " ";
    }
    cout << endl;
  } else {
    cout << "perfect" << endl;
  }
  return 0;
}
