#include <bits/stdc++.h>
using namespace std;
int n;
int a[100020];
int main() {
  scanf("%d", &n);
  for (int i = 0; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  bool same = true;
  for (int i = 0; i <= n; i++) {
    if (a[i] > 1 && a[i + 1] > 1) {
      same = false;
    }
  }
  if (same) {
    printf("perfect\n");
  } else {
    printf("ambiguous\n");
    int cur = 1, p = 1;
    printf("0");
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < a[i]; j++) {
        printf(" %d", p);
        if (p < cur) {
          p++;
        }
      }
      p = cur + 1;
      cur += a[i];
    }
    printf("\n");
    cur = 1;
    p = 1;
    printf("0");
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < a[i]; j++) {
        printf(" %d", p);
      }
      p = cur + 1;
      cur += a[i];
    }
    printf("\n");
  }
  return 0;
}
