#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  n++;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  bool f = 0;
  for (int i = 1; i < n; i++)
    if (a[i - 1] > 1 && a[i] > 1) f = 1;
  if (!f) {
    cout << "perfect";
    return 0;
  }
  cout << "ambiguous\n";
  int p = 1, c = 1;
  cout << "0 ";
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < a[i]; j++) {
      cout << p << ' ';
      c++;
    }
    p = c;
  }
  p = 1, c = 1;
  cout << "\n0 ";
  for (int i = 1; i < n; i++) {
    int be = 0;
    if (a[i - 1] > 1 && a[i] > 1) {
      be = 1;
      cout << p - 1 << ' ';
      c++;
    }
    for (int j = be; j < a[i]; j++) {
      cout << p << ' ';
      c++;
    }
    p = c;
  }
  return 0;
}
