#include <bits/stdc++.h>
using namespace std;
int a[100010];
int tree1[1000010], tree2[1000010], arr[1000010];
int main() {
  int h;
  cin >> h;
  for (int i = 0; i <= h; i++) cin >> a[i];
  int alt = 1, c = 1, cnt = 1;
  arr[0] = 1;
  bool ok = false;
  while (alt <= h) {
    arr[alt] = cnt + 1;
    if (c == 1) {
      for (int i = 0; i < a[alt]; i++) {
        tree1[cnt] = arr[alt - 1];
        tree2[cnt++] = arr[alt - 1];
      }
    } else {
      if (ok) {
        for (int i = 0; i < a[alt]; i++) {
          tree1[cnt] = arr[alt - 1];
          tree2[cnt++] = arr[alt - 1];
        }
      } else {
        if (a[alt] > 1) {
          ok = true;
          for (int i = 0; i < a[alt]; i++) {
            tree1[cnt] = arr[alt - 1];
            if (i == a[alt] - 1) {
              tree2[cnt++] = arr[alt - 1] + 1;
            } else
              tree2[cnt++] = arr[alt - 1];
          }
        } else {
          for (int i = 0; i < a[alt]; i++) {
            tree1[cnt] = arr[alt - 1];
            tree2[cnt++] = arr[alt - 1];
          }
        }
      }
    }
    c = a[alt++];
  }
  if (!ok)
    cout << "perfect" << endl;
  else {
    cout << "ambiguous" << endl;
    for (int i = 0; i < cnt; i++) {
      if (!i)
        cout << "0 ";
      else
        cout << tree1[i] << " ";
    }
    cout << endl;
    for (int i = 0; i < cnt; i++) {
      if (!i)
        cout << "0 ";
      else
        cout << tree2[i] << " ";
    }
  }
}
