#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int h;
  cin >> h;
  vector<long long int> a(h + 1);
  long long int sum = 0;
  for (long long int i = 0; i < h + 1; i++) {
    cin >> a[i];
  }
  bool perfect = true;
  for (long long int i = 0; i < h; i++) {
    if (a[i] != 1 && a[i + 1] != 1) {
      perfect = false;
    }
  }
  if (perfect) {
    cout << "perfect" << endl;
  } else {
    cout << "ambiguous" << endl;
    cout << 0 << " ";
    long long int parent = 1;
    for (long long int i = 1; i < h + 1; i++) {
      long long int parentNext = 0;
      for (long long int j = 0; j < a[i]; j++) {
        parentNext = parent + j + 1;
        cout << parent << " ";
      }
      parent = parentNext;
    }
    cout << endl;
    cout << 0 << " ";
    parent = 1;
    for (long long int i = 1; i < h + 1; i++) {
      long long int parentNext = 0;
      for (long long int j = 0; j < a[i]; j++) {
        parentNext = parent + j + 1;
        cout << parent - min(j, a[i - 1] - 1) << " ";
      }
      parent = parentNext;
    }
    cout << endl;
  }
  return 0;
}
