#include <bits/stdc++.h>
using namespace std;
int h[200010];
int tata1[200010], tata2[200010];
int main() {
  int n;
  cin >> n;
  n++;
  bool ok = 1;
  for (int i(1); i <= n; i++) {
    cin >> h[i];
    if (h[i] >= 2 && h[i - 1] >= 2) ok = 0;
  }
  if (ok) {
    cout << "perfect\n";
    return 0;
  }
  int last1(1), last2(0), cnt(1);
  for (int i(2); i <= n; i++) {
    int n1(cnt + 1), n2(0);
    for (int j(0); j < h[i]; j++) {
      cnt++;
      tata1[cnt] = tata2[cnt] = last1;
    }
    if (h[i] > 1) {
      n2 = cnt;
      if (last2) tata2[cnt] = last2;
    }
    last1 = n1, last2 = n2;
  }
  cout << "ambiguous\n";
  for (int i(1); i <= cnt; i++) cout << tata1[i] << " \n"[i == cnt];
  for (int i(1); i <= cnt; i++) cout << tata2[i] << " \n"[i == cnt];
  return 0;
}
