#include <bits/stdc++.h>
using namespace std;
long long h;
long long arr[100005];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> h;
  bool cont = 1;
  for (int i = 0; i <= h; i++) {
    cin >> arr[i];
    if (i && arr[i] > 1 && arr[i - 1] > 1) cont = 0;
  }
  if (cont) {
    cout << "perfect\n";
    return 0;
  }
  cout << "ambiguous\n";
  cont = 1;
  long long pa = 0, pb = 0;
  string a = "", b = "";
  long long w = 0;
  for (int i = 0; i <= h; i++) {
    if (i < h && arr[i] > 1 && arr[i + 1] > 1 && w == 0) {
      w = 1;
    }
    for (long long j = 0; j < arr[i]; j++) {
      a += to_string(pa) + " ";
      if (w == 2) {
        b += to_string(pa - 1) + " ";
        w = 3;
      } else {
        b += to_string(pa) + " ";
      }
    }
    if (w == 1) w = 2;
    pa += arr[i];
  }
  cout << a << '\n';
  cout << b << '\n';
  return 0;
}
