#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[100010];
int main() {
  int n;
  bool flag = 1;
  a[0] = 1;
  cin >> n;
  for (int i = 0; i <= n; i++) {
    cin >> a[i];
    if (i == 0) {
      continue;
    }
    if (a[i - 1] != 1 && a[i] != 1) {
      flag = 0;
    }
  }
  if (flag) {
    cout << "perfect" << endl;
    return 0;
  }
  cout << "ambiguous" << endl;
  cout << 0;
  int root = a[0];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= a[i]; j++) {
      cout << " " << root;
    }
    root += a[i];
  }
  cout << endl << 0;
  root = a[0];
  for (int i = 1; i <= n; i++) {
    if (i != 0 && a[i - 1] != 1 && a[i] != 1) {
      for (int j = 1; j <= a[i] - 1; j++) {
        cout << " " << root;
      }
      cout << " " << root - 1;
      root += a[i];
      continue;
    }
    for (int j = 1; j <= a[i]; j++) {
      cout << " " << root;
    }
    root += a[i];
  }
}
