#include <bits/stdc++.h>
using namespace std;
int main() {
  long h;
  cin >> h;
  long temp, prevtemp = -1;
  int ambi = 0;
  long* arr = new long[h];
  for (int i = 0; i <= h; i++) {
    cin >> temp;
    arr[i] = temp;
    if (temp > 1 && prevtemp > 1) ambi = 1;
    prevtemp = temp;
  }
  if (ambi) {
    cout << "ambiguous\n";
    long index = 0, prev;
    for (long i = 0; i <= h; i++) {
      for (long j = 0; j < arr[i]; j++) {
        cout << index << " ";
      }
      prev = arr[i];
      index += arr[i];
    }
    cout << endl;
    prev = -1;
    index = 0;
    for (long i = 0; i <= h; i++) {
      int j = 0;
      if (prev > 1 && arr[i] > 1) {
        cout << index - 1 << " ";
        j++;
      }
      for (; j < arr[i]; j++) {
        cout << index << " ";
      }
      prev = arr[i];
      index += arr[i];
    }
  } else {
    cout << "perfect\n";
  }
}
