#include <bits/stdc++.h>
int a[100001];
int sum[100001];
int p[2][200001];
int main(void) {
  int h;
  scanf("%d", &h);
  for (int i = 0; i <= h; i++) {
    scanf("%d", &a[i]);
    if (i) sum[i] = sum[i - 1];
    sum[i] += a[i];
  }
  int cur = 1;
  bool flag = true;
  p[0][1] = p[1][1] = 0;
  for (int i = 1; i <= h; i++) {
    for (int j = 0; j < a[i]; j++) {
      cur++;
      p[0][cur] = p[1][cur] = sum[i - 1];
    }
    if (a[i] > 1 && a[i - 1] > 1) {
      flag = false;
      p[1][cur]--;
    }
  }
  if (flag)
    printf("perfect\n");
  else {
    printf("ambiguous\n");
    for (int i = 0; i < 2; i++) {
      for (int j = 1; j <= sum[h]; j++) printf("%d ", p[i][j]);
      printf("\n");
    }
  }
  return 0;
}
