#include <bits/stdc++.h>
using namespace std;
int A[100005];
int main() {
  int h;
  cin >> h;
  for (int i = 0; i <= h; i++) cin >> A[i];
  bool err = true;
  for (int i = 1; i < h; i++)
    if (A[i] > 1 && A[i + 1] > 1) {
      err = false;
      break;
    }
  if (err) {
    cout << "perfect\n";
    return (0);
  }
  cout << "ambiguous\n";
  int lp = 0;
  for (int i = 0; i <= h; i++) {
    if (A[i] > 1 && A[i - 1] > 1)
      cout << lp - 1 << ' ';
    else
      cout << lp << ' ';
    for (int j = 1; j < A[i]; j++) cout << lp << ' ';
    lp += A[i];
  }
  cout << '\n';
  lp = 0;
  for (int i = 0; i <= h; i++) {
    for (int j = 0; j < A[i]; j++) cout << lp << ' ';
    lp += A[i];
  }
  cout << '\n';
  return (0);
}
