#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.tie(0);
  int h;
  cin >> h;
  int a[h + 1];
  int v = 0;
  for (long long i = 0; i < (long long)h + 1; i++) {
    cin >> a[i];
    v += a[i];
  }
  int flag = 0;
  for (long long i = 1; i < (long long)h + 1; i++) {
    if (a[i] > 1 && a[i - 1] > 1) flag = 1;
  }
  if (flag == 0) {
    cout << "perfect\n";
    return 0;
  }
  cout << "ambiguous\n" << 0 << " ";
  int val = 1;
  for (int i = 1; i < h + 1; i++) {
    int f = val;
    for (int j = 0; j < a[i]; j++) {
      cout << f - a[i - 1] + 1 << " ";
      val++;
    }
  }
  cout << endl << 0 << " ";
  val = 1;
  for (int i = 1; i < h + 1; i++) {
    int f = val;
    if (a[i - 1] > 1) {
      for (int j = 0; j < a[i] - 1; j++) {
        cout << f << " ";
        val++;
      }
      cout << f - 1 << " ";
      val++;
    } else {
      for (int j = 0; j < a[i]; j++) {
        cout << f << " ";
        val++;
      }
    }
  }
  return 0;
}
