#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int a[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int pos = -1;
  for (int i = 1; i < n; i++) {
    if (a[i] > 1 && a[i + 1] > 1) {
      pos = i;
      break;
    }
  }
  if (pos == -1 || pos == n) {
    printf("perfect\n");
    return 0;
  }
  printf("ambiguous\n");
  for (int i = 0, j = 0; i <= n; i++) {
    for (int k = 1; k <= a[i]; k++) {
      printf("%d ", j);
    }
    j += a[i];
  }
  printf("\n");
  int sum = 0;
  for (int i = 0, j = 0; i <= pos; i++) {
    for (int k = 1; k <= a[i]; k++) printf("%d ", j);
    j += a[i];
    sum += a[i];
  }
  for (int j = 1; j <= a[pos + 1]; j++) {
    if (j & 1)
      printf("%d ", sum);
    else
      printf("%d ", sum - a[pos] + 1);
  }
  sum += a[pos + 1];
  for (int i = pos + 2; i <= n; i++) {
    for (int k = 1; k <= a[i]; k++) printf("%d ", sum);
    sum += a[i];
  }
  printf("\n");
  return 0;
}
