#include <bits/stdc++.h>
using namespace std;
int main() {
  int h;
  cin >> h;
  int A[100005];
  int f = 0;
  cin >> A[0];
  for (int i = 1; i <= h; i++) {
    cin >> A[i];
    if (A[i] > 1 && A[i - 1] > 1) f = 1;
  }
  if (!f)
    cout << "perfect\n";
  else {
    cout << "ambiguous\n";
    int p = 0, t;
    for (int i = 0; i <= h; i++) {
      t = A[i];
      while (t--) cout << p << " ";
      p += A[i];
    }
    cout << endl;
    f = 1;
    p = 1;
    cout << "0 ";
    for (int i = 1; i <= h; i++) {
      t = A[i];
      if (f && A[i - 1] > 1 && A[i] > 1) {
        t = A[i];
        t--;
        cout << p - 1 << " ";
        while (t--) cout << p << " ";
        p += A[i];
        f = 0;
      } else {
        t = A[i];
        while (t--) cout << p << " ";
        p += A[i];
      }
    }
    cout << endl;
  }
  return 0;
}
