#include <bits/stdc++.h>
using namespace std;
int n;
int a[200005];
int main() {
  scanf("%d", &n);
  ++n;
  for (int i = 0; i < (int)(n); ++i) scanf("%d", a + i);
  int sum = 0;
  for (int i = 0; i < (int)(n); ++i) sum += a[i];
  bool ok = true;
  for (int i = 0; i < (int)(n - 1); ++i)
    if (a[i] > 1 && a[i + 1] > 1) {
      ok = false;
      break;
    }
  if (ok) {
    cout << "perfect" << endl;
    return 0;
  }
  cout << "ambiguous" << endl;
  printf("0");
  int pre = 1;
  int num = 2;
  for (int i = 1; i < n; ++i) {
    int npre = num;
    for (int j = 0; j < (int)(a[i]); ++j) printf(" %d", pre), num++;
    pre = npre;
  }
  printf("\n0");
  pre = 1;
  int lst = 1;
  num = 2;
  for (int i = 1; i < n; ++i) {
    int npre = num;
    for (int j = 0; j < (int)(a[i]); ++j) {
      printf(" %d", pre);
      if (pre < lst) {
        ++pre;
      }
      num++;
    }
    pre = npre;
    lst = num - 1;
  }
  puts("");
  return 0;
}
