#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, i;
  cin >> n;
  n++;
  vector<int> h(n);
  for (i = 0; i < n; i++) cin >> h[i];
  bool perfect = true;
  int idx = 0;
  for (i = 0; i < n - 1; i++) {
    if (h[i] > 1 && h[i + 1] > 1) {
      perfect = false;
      idx = i;
      break;
    }
  }
  if (perfect)
    cout << "perfect" << endl;
  else {
    cout << "ambiguous" << endl;
    vector<int> pos(n);
    int cur = 2;
    pos[0] = 1;
    cout << "0 ";
    for (i = 1; i < n; i++) {
      pos[i] = cur;
      for (int j = 0; j < h[i]; j++) {
        cout << pos[i - 1] << " ";
        cur++;
      }
    }
    cout << endl;
    cur = 2;
    pos[0] = 1;
    cout << "0 ";
    for (i = 1; i < n; i++) {
      pos[i] = cur;
      for (int j = 0; j < h[i]; j++) {
        cout << ((i - 1 == idx && j > 0) ? (pos[i - 1] + 1) : pos[i - 1])
             << " ";
        cur++;
      }
    }
    cout << endl;
  }
  return 0;
}
