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