#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 10;
int p[M], a[M], q[M], n, c = 1;
bool nper, ex;
int main() {
  cin >> n;
  n++;
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i < n; i++)
    if (a[i] > 1 && a[i + 1] > 1) nper = true;
  if (!nper) return cout << "perfect" << endl, 0;
  for (int i = 2; i <= n; i++)
    if (a[i] > 1 && a[i - 1] > 1 && !ex) {
      ex = true;
      for (int j = 1; j <= a[i]; j++) p[c + j] = c;
      for (int j = 1; j < a[i]; j++) q[c + j] = c;
      q[c + a[i]] = c - 1;
      c += a[i];
    } else {
      for (int j = 1; j <= a[i]; j++) {
        p[c + j] = c;
        q[c + j] = c;
      }
      c += a[i];
    }
  cout << "ambiguous\n";
  for (int i = 1; i <= c; i++) printf("%d ", p[i]);
  cout << endl;
  for (int i = 1; i <= c; i++) printf("%d ", q[i]);
  cout << endl;
  return 0;
}
