#include <bits/stdc++.h>
using namespace std;
const int N = 110000;
int a[N], h, n;
int main() {
  scanf("%d", &h);
  for (int i = (int)0; i <= (int)h; i++) scanf("%d", &a[i]);
  bool flg = 0;
  int t = 0;
  for (int i = (int)1; i <= (int)h - 1; i++)
    if (a[i] > 1 && a[i + 1] > 1) {
      flg = 1;
      t = i;
      break;
    }
  if (!flg) {
    printf("perfect\n");
    return 0;
  }
  printf("ambiguous\n");
  int rt = 1;
  printf("0 ");
  n = 1;
  for (int i = (int)1; i <= (int)h; i++) {
    int pv = n;
    for (int j = (int)1; j <= (int)a[i]; j++) {
      ++n;
      printf("%d ", pv);
    }
  }
  rt = 1;
  puts("");
  printf("0 ");
  n = 1;
  for (int i = (int)1; i <= (int)h; i++) {
    int pv = n;
    for (int j = (int)1; j <= (int)a[i]; j++) {
      ++n;
      if (j == a[i] && i == t + 1)
        printf("%d ", pv - 1);
      else
        printf("%d ", pv);
    }
  }
  puts("");
  return 0;
}
