#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> A(N + 1);
  vector<long long> B(N + 1, -1);
  vector<long long> C(N + 1, -1);
  long long res = 0;
  long long M = 0;
  for (long long i = 0; i < N + 1; i++) {
    cin >> A[i];
    if (A[i] == 1) {
      B[i] = M;
    } else {
      B[i] = M;
      C[i] = M + 1;
    }
    M += A[i];
  }
  bool f = false;
  for (long long i = 0; i < N; i++) {
    if (A[i] != 1 && A[i + 1] != 1) {
      f = true;
    }
  }
  if (f) {
    cout << "ambiguous" << endl;
    cout << 0;
    for (long long i = 1; i < N + 1; i++) {
      for (long long j = 0; j < A[i]; j++) {
        cout << " " << B[i - 1] + 1;
      }
    }
    cout << endl;
    cout << 0;
    for (long long i = 1; i < N + 1; i++) {
      for (long long j = 0; j < A[i]; j++) {
        if (j == 0 || A[i - 1] == 1) {
          cout << " " << B[i - 1] + 1;
        } else {
          cout << " " << C[i - 1] + 1;
        }
      }
    }
    cout << endl;
  } else {
    cout << "perfect" << endl;
  }
}
