#include <bits/stdc++.h>
using namespace std;
int main() {
  int h;
  cin >> h;
  vector<int> a(h + 1);
  int n = 0;
  for (int i = 0; i < h + 1; i++) {
    cin >> a[i];
    n += a[i];
  }
  bool flag = 0;
  int ind = -1;
  for (int i = 1; i < h + 1; i++) {
    if (a[i] > 1 && a[i - 1] > 1) {
      if (!flag) {
        ind = i;
        flag = 1;
      }
    }
  }
  if (flag) {
    cout << "ambiguous" << endl;
  } else {
    cout << "perfect" << endl;
    return 0;
  }
  int last = 0, cnt = 0;
  for (int i = 0; i < h + 1; i++) {
    for (int j = 0; j < a[i]; j++) {
      cout << last << ' ';
      cnt++;
    }
    last = cnt;
  }
  cout << endl;
  cnt = 0;
  last = 0;
  flag = 0;
  for (int i = 0; i < h + 1; i++) {
    for (int j = 0; j < a[i]; j++) {
      if (!flag && i == ind) {
        cout << last - 1 << ' ';
        flag = 1;
        cnt++;
        continue;
      }
      cout << last << ' ';
      cnt++;
    }
    last = cnt;
  }
  cout << endl;
}
