#include <bits/stdc++.h>
int h;
int a[200005];
int mult = 0;
void ambig(int level) {
  int x = 0;
  int y = 0;
  for (int i = 0; i <= h; ++i) {
    int j = 0;
    while (j < a[i]) {
      printf("%d ", x);
      j++;
    }
    x += a[i];
  }
  printf("\n");
  x = 0;
  y = 0;
  for (int i = 0; i <= h; ++i) {
    if (i != level) {
      int j = 0;
      while (j < a[i]) {
        printf("%d ", x);
        j++;
      }
    } else {
      int count = a[i];
      while (count) {
        for (int z = y; z <= x; ++z) {
          printf("%d ", z);
          count--;
          if (count == 0) break;
        }
      }
    }
    y = x + 1;
    x += a[i];
  }
}
int main() {
  scanf("%d", &h);
  for (int i = 0; i <= h; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i <= h; ++i) {
    if (a[i - 1] > 1 && a[i] > 1) {
      printf("ambiguous\n");
      ambig(i);
      return 0;
    }
  }
  printf("perfect");
  return 0;
}
