#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long r[n];
  for (long long i = 0; i < n + 1; i++) cin >> r[i];
  bool b = true;
  for (long long i = 0; i < n; i++) {
    if (r[i] != 1 && r[i + 1] != 1) b = false;
  }
  if (b == true) {
    cout << "perfect";
  } else {
    cout << "ambiguous" << '\n';
    cout << "0 ";
    long long a = 1;
    for (long long i = 1; i <= n; i++) {
      long long b = a;
      for (long long j = 0; j < r[i]; j++) {
        cout << b << " ";
        a++;
      }
    }
    cout << '\n';
    cout << "0 ";
    a = 1;
    bool ui = false;
    for (long long i = 1; i < n + 1; i++) {
      if (r[i] != 1 && r[i - 1] != 1 && !ui) {
        long long b = a;
        ui = true;
        cout << (b - 1) << " ";
        a++;
        for (long long j = 0; j < r[i] - 1; j++) {
          cout << b << " ";
          a++;
        }
      } else {
        long long b = a;
        for (long long j = 0; j < r[i]; j++) {
          cout << b << " ";
          a++;
        }
      }
    }
  }
}
