#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 3e5 + 6;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long pow(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a);
    a = (a * a);
    b >>= 1;
  }
  return ans;
}
long long readn() {
  long long sum = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    sum = sum * 10 + (ch - '0');
    ch = getchar();
  }
  return sum * f;
}
long long n, num[N], rt = 0, f = 1;
int main() {
  cin >> n;
  for (long long i = 0; i <= n; i++) {
    cin >> num[i];
    if (i == 0) continue;
    if (num[i - 1] != 1 && num[i] != 1) f = 0;
  }
  if (f) {
    puts("perfect");
    return 0;
  }
  printf("ambiguous\n%lld\n", rt);
  rt += num[0];
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= num[i]; j++) {
      cout << rt << endl;
    }
    rt += num[i];
  }
  rt = num[0];
  puts("0");
  for (long long i = 1; i <= n; i++) {
    if (num[i - 1] != 1 && num[i] != 1) {
      for (long long j = 2; j <= num[i]; j++) cout << rt << endl;
      cout << rt - 1 << endl;
      rt += num[i];
      continue;
    }
    for (long long j = 1; j <= num[i]; j++) {
      cout << rt << endl;
    }
    rt += num[i];
  }
}
