#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5, MOD = 1e9 + 7;
long long p[N], a[N];
vector<long long> ans[N], g[N];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 0; i <= n; i++) {
    cin >> a[i];
  }
  long long cc = 0, kto = 1;
  g[cc].push_back(kto);
  kto++;
  cc++;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= a[i]; j++) {
      long long to = g[cc - 1][0];
      p[kto] = g[cc - 1][0];
      g[cc].push_back(kto);
      ans[to].push_back(kto);
      kto++;
    }
    cc++;
  }
  bool log = false;
  long long parent, son;
  for (long long i = 1; i <= n; i++) {
    if (a[i] > 1 && a[i - 1] > 1) {
      log = true;
      parent = i - 1;
      son = i;
    }
  }
  if (!log) {
    cout << "perfect";
    return 0;
  }
  cout << "ambiguous\n";
  cout << 0 << ' ';
  for (long long i = 2; i < kto; i++) {
    cout << p[i] << ' ';
  }
  cout << "\n";
  long long kek = g[son][0];
  p[kek] = g[parent][1];
  cout << 0 << ' ';
  for (long long i = 2; i < kto; i++) {
    cout << p[i] << ' ';
  }
}
