#include <bits/stdc++.h>
using namespace std;
const int H_MAX = 100100;
const int N_MAX = 200100;
int H, N;
int layers[H_MAX];
int tree1[N_MAX];
int tree2[N_MAX];
int main() {
  N = 0;
  cin >> H;
  for (int i = 0; i <= H; i++) {
    cin >> layers[i];
    N += layers[i];
  }
  assert(layers[0] == 1);
  tree1[0] = tree2[0] = -1;
  bool ambiguous = false;
  int cur = 1;
  for (int i = 1; i <= H; i++) {
    for (int j = 0; j < layers[i]; j++)
      tree1[cur + j] = tree2[cur + j] = cur - 1;
    if (layers[i - 1] > 1 && layers[i] > 1) {
      ambiguous = true;
      tree2[cur + layers[i] - 1] = cur - 2;
    }
    cur += layers[i];
  }
  if (ambiguous) {
    cout << "ambiguous\n";
    for (int i = 0; i < N; i++)
      cout << tree1[i] + 1 << (i < N - 1 ? " " : "\n");
    for (int i = 0; i < N; i++)
      cout << tree2[i] + 1 << (i < N - 1 ? " " : "\n");
  } else {
    cout << "perfect\n";
  }
}
