#include <bits/stdc++.h>
using namespace std;
int INF = 1100000;
int a[100010];
int main() {
  int n;
  cin >> n;
  bool ok = 0;
  for (int i = 0; i <= n; i++) {
    cin >> a[i];
    if (i > 0 && a[i] != 1 && a[i - 1] != 1) ok = 1;
  }
  if (n < 2 || ok == 0) {
    cout << "perfect";
    return 0;
  }
  cout << "ambiguous\n";
  int k = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = k; j < k + a[i]; j++) {
      cout << k << " ";
    }
    k += a[i];
  }
  cout << "\n";
  k = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = k; j < k + (a[i] + 1) / 2; j++) {
      cout << k << " ";
    }
    int l;
    if (i == 0)
      l = k;
    else if (a[i - 1] == 1)
      l = k;
    else
      l = k - 1;
    for (int j = k + (a[i] + 1) / 2; j < k + a[i]; j++) {
      cout << l << " ";
    }
    k += a[i];
  }
  return 0;
}
