#include <bits/stdc++.h>
using namespace std;
template <typename T>
using V = vector<T>;
const long long MOD = 1e9 + 7, INF = 0x3F3F3F3F3F3F3F3F;
const int inf = 0x3F3F3F3F;
V<int> h;
int a[212345];
int pn = 0;
int cur = 0;
int tot = 0;
void assign(int p, int l, int r) {
  for (int j = l; j <= r; j++) {
    int x = h[j];
    for (int i = 0; i < x; i++) {
      cur++;
      a[cur] = p;
    }
    p = cur + 1;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int hs;
  cin >> hs;
  h.resize(hs + 1);
  for (int i = 0; i < hs + 1; i++) {
    cin >> h[i];
    tot += h[i];
    if (i && h[i]) {
      if (h[i] != 1 && h[i - 1] != 1) {
        pn = i;
      }
    }
  }
  if (!pn) {
    cout << "perfect";
    return 0;
  }
  cout << "ambiguous\n";
  cur = 0;
  a[0] = 0;
  assign(1, 1, hs);
  for (int i = 0; i < tot; i++) cout << a[i] << " ";
  cur = 0;
  assign(1, 1, pn - 1);
  h[pn]--;
  a[cur + 1] = cur;
  cur++;
  assign(cur, pn, hs);
  cout << "\n";
  for (int i = 0; i < tot; i++) cout << a[i] << " ";
  return 0;
}
