#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N];
int main() {
  int h;
  long long sum = 0;
  scanf("%d", &h);
  bool ok = 1;
  for (int i = 1; i <= h + 1; i++) {
    scanf("%d", a + i);
    sum += a[i];
  }
  for (int i = 1; i <= h + 1 && ok; i++)
    if (a[i] >= 2 && a[i - 1] >= 2) ok = 0;
  if (ok)
    printf("perfect");
  else {
    printf("ambiguous\n0");
    long long cnt = 1;
    for (int i = 2; i <= h + 1; i++) {
      for (int j = 0; j < a[i]; j++) printf(" %d", cnt);
      cnt += a[i];
    }
    printf("\n0");
    cnt = 1;
    bool flag = 0;
    for (int i = 2; i <= h + 1; i++) {
      if (a[i] >= 2 && a[i - 1] >= 2 && !flag) {
        printf(" %d", cnt - 1);
        for (int j = 1; j < a[i]; j++) {
          printf(" %d", cnt);
        }
        flag = 1;
      } else
        for (int j = 0; j < a[i]; j++) {
          printf(" %d", cnt);
        }
      cnt += a[i];
    }
  }
  return 0;
}
