#include <bits/stdc++.h>
using namespace std;
int n;
int a[100010];
bool flag;
int main() {
  cin >> n;
  flag = true;
  for (int i = 0; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i <= n; i++) {
    if (a[i] > 1 && a[i + 1] > 1) flag = false;
  }
  if (flag) {
    cout << "perfect" << endl;
  } else {
    cout << "ambiguous" << endl;
    int p = 1, t = 1;
    cout << 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < a[i]; j++) {
        cout << ' ' << p;
        if (p < t) p++;
      }
      p = t + 1;
      t += a[i];
    }
    cout << endl;
    cout << 0;
    p = 1, t = 1;
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < a[i]; j++) cout << ' ' << p;
      p = t + 1;
      t += a[i];
    }
    cout << endl;
  }
  return 0;
}
