#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int h;
int a[N];
int sum[N];
int main() {
  scanf("%d", &h);
  for (int i = 0; i <= h; i++) {
    scanf("%d", &a[i]);
    sum[i] += sum[i - 1] + a[i];
  }
  bool check = false;
  int pre = 1;
  for (int i = 0; i <= h; i++) {
    if (a[i] == 1) {
      pre = 1;
      continue;
    } else {
      if (pre == 1) {
        pre = a[i];
        continue;
      } else {
        check = true;
      }
    }
  }
  if (check == false) {
    cout << "perfect";
    return 0;
  }
  cout << "ambiguous" << endl;
  cout << "0 ";
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= a[i]; j++) {
      cout << sum[i - 2] + 1 << " ";
    }
  }
  cout << endl;
  cout << "0 ";
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= a[i]; j++) {
      if (sum[i - 2] + j <= sum[i - 1])
        cout << sum[i - 2] + j << " ";
      else {
        cout << sum[i - 2] + 1 << " ";
      }
    }
  }
  cout << endl;
  return 0;
}
