#include <bits/stdc++.h>
using namespace std;
int main() {
  int h;
  cin >> h;
  bool ambi = false;
  int a[h + 1];
  int nodes = 0;
  int in = 0;
  for (int i = 0; i < h + 1; i++) {
    cin >> a[i];
    nodes += a[i];
    if (i != 0 && a[i] > 1 && a[i - 1] > 1) {
      ambi = true;
      in = i;
    }
  }
  if (ambi == false) {
    cout << "perfect\n";
    return 0;
  }
  cout << "ambiguous\n0 ";
  int curr_node = 1;
  int next_node = 2;
  for (int i = 1; i < h + 1; i++) {
    curr_node = next_node - 1;
    for (int x = 0; x < a[i]; x++) {
      cout << curr_node << " ";
      next_node++;
    }
  }
  curr_node = 1;
  next_node = 2;
  cout << "\n0 ";
  for (int i = 1; i < h + 1; i++) {
    curr_node = next_node - 1;
    if (in == i) {
      for (int x = 0; x < a[i] - 1; x++) {
        cout << curr_node << " ";
        next_node++;
      }
      cout << curr_node - 1 << " ";
      next_node++;
      continue;
    }
    for (int x = 0; x < a[i]; x++) {
      cout << curr_node << " ";
      next_node++;
    }
  }
  return 0;
}
