#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long h;
  cin >> h;
  long arr[h + 1];
  for (int i = 0; i <= h; i++) {
    cin >> arr[i];
  }
  int perfect = 1;
  long index = -1;
  if (arr[0] != 1)
    perfect = 0;
  else {
    for (int i = 0; i < h; i++) {
      if (arr[i] != 1 && arr[i + 1] != 1) {
        index = i;
        perfect = 0;
      }
    }
  }
  if (perfect) {
    cout << "perfect" << endl;
    return 0;
  }
  cout << "ambiguous" << endl;
  long parent = 0;
  for (long i = 0; i <= h; i++) {
    for (long j = 0; j < arr[i]; j++) {
      cout << parent << ' ';
    }
    if (i != 0)
      parent += arr[i - 1];
    else
      parent++;
  }
  long temp1, temp2;
  temp1 = parent;
  temp2 = parent + 1;
  cout << endl;
  parent = 0;
  for (long i = 0; i <= index; i++) {
    for (long j = 0; j < arr[i]; j++) {
      cout << parent << ' ';
    }
    if (i != 0)
      parent += arr[i - 1];
    else
      parent++;
  }
  for (long i = 0; i < arr[index + 1] - 1; i++) {
    cout << parent << ' ';
  }
  cout << parent + 1 << ' ';
  parent += arr[index];
  for (long i = index + 2; i <= h; i++) {
    for (long j = 0; j < arr[i]; j++) {
      cout << parent << ' ';
    }
    if (i != 0)
      parent += arr[i - 1];
    else
      parent++;
  }
  cout << endl;
  return 0;
}
