#include <bits/stdc++.h>
using namespace std;
int A[100010];
int main() {
  int n, a;
  cin >> n;
  for (int i = 0; i <= n; ++i) {
    cin >> A[i];
  }
  bool flag = true;
  int i;
  for (i = 1; i <= n && flag; ++i) {
    if (A[i] > 1 && A[i - 1] > 1) {
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << "perfect";
    return 0;
  }
  int tot = 0;
  cout << "ambiguous\n";
  for (int j = 0; j <= n; ++j) {
    if (j == 0) {
      cout << "0 ";
    } else if (j == i) {
      for (int k = 0; k < A[j] - 1; ++k) cout << tot + 1 << " ";
      cout << tot + 2 << " ";
    } else {
      for (int k = 0; k < A[j]; ++k) cout << tot + 1 << " ";
    }
    if (j != 0) tot += A[j - 1];
  }
  cout << "\n";
  tot = 0;
  for (int j = 0; j <= n; ++j) {
    if (j == 0) {
      cout << "0 ";
    } else if (j == i) {
      for (int k = 0; k < A[j]; ++k) cout << tot + 1 << " ";
    } else {
      for (int k = 0; k < A[j]; ++k) cout << tot + 1 << " ";
    }
    if (j != 0) tot += A[j - 1];
  }
}
