#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int arr1[n];
  for (int i = 0; i <= n; ++i) {
    cin >> arr1[i];
  }
  long long int st = 0;
  long long int ind = -1;
  for (int i = 0; i < n; ++i) {
    if (arr1[i] > 1 && arr1[i + 1] > 1) {
      st = 1;
      ind = i;
      break;
    }
  }
  if (st == 0) {
    cout << "perfect\n";
  } else {
    cout << "ambiguous\n";
    cout << "0 ";
    long long int co = 1;
    for (int i = 1; i <= n; ++i) {
      for (int j = 0; j < arr1[i]; ++j) {
        cout << co << " ";
      }
      co += arr1[i - 1];
    }
    cout << endl;
    cout << "0 ";
    co = 1;
    for (int i = 1; i <= n; ++i) {
      if (i == ind + 1) {
        for (int j = 0; j < arr1[i] - 1; ++j) {
          cout << co << " ";
        }
        cout << co + 1 << " ";
        co += arr1[i - 1];
      } else {
        for (int j = 0; j < arr1[i]; ++j) {
          cout << co << " ";
        }
        co += arr1[i - 1];
      }
    }
    cout << endl;
  }
  return 0;
}
