#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  n++;
  int a[n], sum = 0, cnti = 0, final = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] > 1) {
      if (a[i - 1] > 1) {
        cnti = 1;
        final = i - 1;
      }
    }
    sum += a[i];
  }
  if (cnti < 1) {
    cout << "perfect\n";
    return 0;
  }
  int b[sum], c[sum], j = 1, last = 1, temp;
  b[0] = c[0] = 0;
  for (int i = 1; i < n; ++i) {
    for (int k = 0; k < a[i]; ++k) {
      b[j++] = last;
    }
    last = j;
  }
  j = 1;
  last = 1;
  int prelast = last;
  for (int i = 1; i < n; ++i) {
    for (int k = 0; k < a[i]; ++k) {
      if (k)
        c[j++] = last;
      else
        c[j++] = prelast;
    }
    last = j;
    if (i == final)
      prelast = j - 1;
    else
      prelast = last;
  }
  cout << "ambiguous\n";
  for (int i = 0; i < sum; ++i) cout << b[i] << " ";
  cout << endl;
  for (int i = 0; i < sum; ++i) cout << c[i] << " ";
  cout << endl;
  return 0;
}
