#include <bits/stdc++.h>
using namespace std;
int N;
int a[100011];
int b[100011];
int main() {
  cin >> N;
  int c = 0;
  int t = 0;
  for (int(i) = 0; (i) < (int)(N + 1); (i)++) {
    cin >> a[i];
    b[i] = a[i];
    t += a[i];
    if (i != 0 && a[i - 1] != 1 && a[i] != 1) c = i;
  }
  if (c == 0) {
    cout << "perfect" << endl;
  } else {
    cout << "ambiguous" << endl;
    cout << 0;
    int now = 1;
    int cc = 1;
    for (int(i) = 0; (i) < (int)(N); (i)++) {
      for (int(j) = 0; (j) < (int)(a[i + 1]); (j)++) {
        cout << " " << now;
        cc++;
      }
      now = cc;
    }
    cout << endl;
    now = 1;
    cc = 1;
    cout << 0;
    for (int(i) = 0; (i) < (int)(N); (i)++) {
      for (int(j) = 0; (j) < (int)(a[i + 1]); (j)++) {
        cc++;
        if (j == 0) {
          cout << " " << now;
          continue;
        }
        if (a[i] != 1) {
          cout << " " << now - 1;
        } else {
          cout << " " << now;
        }
      }
      now = cc;
    }
    cout << endl;
  }
  return 0;
}
