#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 2;
const long long inf = 1e18 + 43;
const long long mod = 1e9 + 7;
const int maxlog = 20;
int par1[maxn], par2[maxn];
int a[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.precision(20);
  int n;
  cin >> n;
  int cur = 1;
  bool tof = false;
  for (int i = 0; i <= n; i++) {
    cin >> a[i];
    int x = a[i];
    if (a[i] == 1) {
      par1[cur] = cur - 1;
      par2[cur] = cur - 1;
      cur++;
      continue;
    }
    if (a[i - 1] == 1) {
      int pre = cur - 1;
      for (int j = 0; j < x; j++) {
        par1[cur] = pre;
        par2[cur] = pre;
        cur++;
      }
      continue;
    }
    tof = true;
    par1[cur] = cur - 2;
    par2[cur] = cur - 1;
    int pre = cur - 1;
    cur++;
    x--;
    for (int j = 0; j < x; j++) {
      par1[cur] = pre;
      par2[cur] = pre;
      cur++;
    }
  }
  if (!tof) {
    cout << "perfect";
    return 0;
  }
  cout << "ambiguous" << endl;
  for (int i = 1; i < cur; i++) cout << par1[i] << " ";
  cout << endl;
  for (int i = 1; i < cur; i++) cout << par2[i] << " ";
  return 0;
}
