#include <bits/stdc++.h>
using namespace std;
const int MAX_H = 2e5 + 10;
int h, a[MAX_H];
void solve(int x) {
  printf("ambiguous\n");
  for (int i = 1; i <= h; i++)
    for (int j = 1; j <= a[i] - a[i - 1]; j++) printf("%d ", a[i - 1]);
  printf("\n");
  for (int i = 1; i <= x; i++)
    for (int j = 1; j <= a[i] - a[i - 1]; j++) printf("%d ", a[i - 1]);
  printf("%d ", a[x] - 1);
  for (int j = 2; j <= a[x + 1] - a[x]; j++) printf("%d ", a[x]);
  for (int i = x + 2; i <= h; i++)
    for (int j = 1; j <= a[i] - a[i - 1]; j++) printf("%d ", a[i - 1]);
  printf("\n");
}
int main() {
  scanf("%d", &h);
  h++;
  for (int i = 1; i <= h; i++) {
    scanf("%d", &a[i]);
    a[i] += a[i - 1];
  }
  for (int i = 1; i < h; i++) {
    if (a[i] - a[i - 1] > 1 && a[i + 1] - a[i] > 1) {
      solve(i);
      return 0;
    }
  }
  printf("perfect\n");
}
