#include <bits/stdc++.h>
using namespace std;
long long int modularPower(long long int x, unsigned long long int y,
                           long long int mod) {
  long long int res = 1;
  x %= mod;
  while (y > 0) {
    if (y & 1) res = (res * x) % mod;
    y >>= 1;
    x = (x * x) % mod;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cerr.tie(NULL);
  cout.tie(NULL);
  ;
  int height;
  cin >> height;
  vector<int> v(height + 5);
  vector<int> sum(height + 5);
  int posOfChange = 0;
  for (int i = 0; i <= height; ++i) {
    int foo;
    cin >> foo;
    v[i] = foo;
  }
  while (posOfChange < height and
         (v[posOfChange] == 1 or v[posOfChange + 1] == 1))
    posOfChange++;
  if (posOfChange == height) {
    cout << "perfect";
    return 0;
  }
  sum[0] = 1;
  for (int i = 1; i < v.size(); ++i) {
    sum[i] = sum[i - 1] + v[i - 1];
  }
  cout << "ambiguous"
       << "\n";
  cout << 0 << " ";
  for (int i = 1; i <= height; ++i) {
    for (int j = 0; j < v[i]; ++j) {
      cout << sum[i - 1] << " ";
    }
  }
  cout << "\n" << 0 << " ";
  for (int i = 1; i <= height; ++i) {
    if (i == posOfChange + 1) {
      cout << sum[i - 1] + 1 << " ";
      for (int j = 1; j < v[i]; ++j) {
        cout << sum[i - 1] << " ";
      }
    } else {
      for (int j = 0; j < v[i]; ++j) {
        cout << sum[i - 1] << " ";
      }
    }
  }
  return 0;
}
