#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int a[N], s[N], t[N];
int main() {
  ios::sync_with_stdio(false);
  int h;
  cin >> h;
  int n = 0;
  for (int i = 0; i <= h; i++) {
    cin >> a[i];
    n += a[i];
  }
  assert(a[0] == 1);
  int last = 0;
  int at = 1;
  int nxt;
  int ok = 0;
  int tam_last = 1;
  for (int i = 0; i <= h; i++) {
    nxt = at;
    for (int j = 0; j < a[i]; j++) {
      s[at + j] = last;
    }
    if (tam_last > 1 && !ok && a[i] > 1) {
      for (int j = 0; j < a[i]; j++) {
        t[at + j] = last + (j != 0);
      }
      ok = 1;
    } else {
      for (int j = 0; j < a[i]; j++) {
        t[at + j] = last;
      }
    }
    at += a[i];
    last = nxt;
    tam_last = a[i];
  }
  if (!ok) {
    cout << "perfect\n";
    return 0;
  }
  cout << "ambiguous\n";
  for (int i = 1; i <= n; i++) {
    cout << s[i] << " ";
  }
  cout << endl;
  for (int i = 1; i <= n; i++) {
    cout << t[i] << " ";
  }
  cout << endl;
  return 0;
}
