#include <bits/stdc++.h>
using namespace std;
bool perfect(int *a, int n) {
  for (int i = 1; i < n; i++) {
    if (a[i] - 1 && a[i - 1] - 1) {
      return false;
    }
  }
  return true;
}
int main() {
  int h, sum = 1, n;
  cin >> h;
  int a[h + 1];
  for (int i = 0; i <= h; i++) {
    cin >> a[i];
  }
  if (perfect(a, h + 1)) {
    cout << "perfect";
  } else {
    cout << "ambiguous\n0 ";
    for (int i = 1; i <= h; sum += a[i++]) {
      for (int j = 0; j < a[i]; j++) {
        cout << sum << ' ';
      }
    }
    cout << "\n0 ";
    sum = 1;
    for (int i = 1; i <= h; sum += a[i++]) {
      if (a[i - 1] - 1) {
        cout << sum - 1 << ' ';
        for (int j = 1; j < a[i]; j++) {
          cout << sum << ' ';
        }
      } else {
        for (int j = 0; j < a[i]; j++) {
          cout << sum << ' ';
        }
      }
    }
  }
}
