#include <bits/stdc++.h>
using namespace std;
const int N = 112345;
int n;
int a[N], fir[N];
int mark;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n + 1; i++) {
    cin >> a[i];
  }
  bool perf = 1;
  for (int i = 0; i < n; i++) {
    if (a[i] > 1 and a[i + 1] > 1) {
      if (!mark) mark = i;
      perf = 0;
    }
  }
  if (perf) {
    cout << "perfect" << endl;
    return 0;
  }
  cout << "ambiguous" << endl;
  int cnt = 1;
  cout << "0 ";
  cnt++;
  fir[0] = 1;
  for (int i = 1; i < n + 1; i++) {
    for (int j = 0; j < a[i]; j++) {
      if (j == 0) fir[i] = cnt;
      cout << fir[i - 1] << " ";
      cnt++;
    }
  }
  cout << endl;
  int sec;
  cnt = 1;
  cout << "0 ";
  cnt++;
  fir[0] = 1;
  for (int i = 1; i < n + 1; i++) {
    for (int j = 0; j < a[i]; j++) {
      if (mark == i and j == 1) {
        sec = cnt;
      }
      if (j == 0) fir[i] = cnt;
      if (mark == i - 1 and j == 0) {
        cout << sec << " ";
      } else {
        cout << fir[i - 1] << " ";
      }
      cnt++;
    }
  }
  cout << endl;
  return 0;
}
