#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int main() {
  int n, num[maxn], root = 0;
  bool flag = 1;
  num[0] = 1;
  scanf("%d", &n);
  for (int i = 0; i <= n; i++) {
    scanf("%d", &num[i]);
    if (i == 0) continue;
    if (num[i - 1] != 1 && num[i] != 1) {
      flag = 0;
    }
  }
  if (flag) {
    printf("perfect\n");
    return 0;
  }
  printf("ambiguous\n");
  printf("%d", root);
  root += num[0];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= num[i]; j++) {
      printf(" %d", root);
    }
    root += num[i];
  }
  printf("\n");
  root = 0;
  printf("%d", root);
  root += num[0];
  for (int i = 1; i <= n; i++) {
    if (i != 0 && num[i - 1] != 1 && num[i] != 1) {
      for (int j = 1; j <= num[i] - 1; j++) printf(" %d", root);
      printf(" %d", root - 1);
      root += num[i];
      continue;
    }
    for (int j = 1; j <= num[i]; j++) {
      printf(" %d", root);
    }
    root += num[i];
  }
  return 0;
}
