#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int a[N];
int main() {
  int n;
  cin >> n;
  int ok = 1;
  for (int i = 0; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] != 1 && a[i - 1] != 1) ok = 0;
  }
  if (ok == 1)
    cout << "perfect";
  else {
    cout << "ambiguous" << endl;
    int u = 0, luu = 0;
    for (int i = 0; i <= n; i++) {
      for (int j = 0; j < a[i]; j++) {
        printf("%d ", luu);
        u++;
      }
      luu = u;
    }
    cout << endl;
    u = 0, luu = 0;
    for (int i = 0; i <= n; i++) {
      if (a[i - 1] == 1) {
        for (int j = 0; j < a[i]; j++) {
          printf("%d ", luu);
          u++;
        }
        luu = u;
      } else {
        printf("%d ", luu);
        u++;
        for (int j = 1; j < a[i]; j++) {
          printf("%d ", luu - 1);
          u++;
        }
        luu = u;
      }
    }
  }
}
