#include <bits/stdc++.h>
using namespace std;
const int mx = 1e5 + 5;
int a[mx];
int main() {
  int n, m;
  scanf("%d", &n);
  int ok = 1;
  int sum = 0;
  for (int i = 0; i <= n; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  for (int i = 1; i <= n; i++)
    if (a[i] >= 2 && a[i - 1] >= 2) ok = 0;
  if (ok)
    puts("perfect");
  else {
    puts("ambiguous");
    int pre = 0;
    int len = 1;
    for (int i = 0; i <= n; i++) {
      for (int j = 1; j <= a[i]; j++) {
        printf("%d%c", pre, len == sum ? '\n' : ' ');
        len++;
      }
      pre = len - 1;
    }
    pre = 0;
    len = 1;
    int s = 0;
    for (int i = 0; i <= n; i++) {
      for (int j = 1; j <= a[i]; j++) {
        printf("%d%c", j % 2 == 0 ? s : pre, len == sum ? '\n' : ' ');
        len++;
      }
      pre = len - 1;
      s = len - a[i];
    }
  }
  return 0;
}
