#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 2;
int h, a[maxn], ans1[maxn], ans2[maxn];
int main() {
  cin >> h;
  int v = 2;
  int sum = 0;
  for (int i = 0; i <= h; i++) {
    scanf("%i", &a[i]);
    sum += a[i];
  }
  ans1[1] = 0, ans2[1] = 0;
  int flag = 0;
  for (int i = 0; i < h; i++) {
    int par;
    if (a[i] == 1) {
      par = v - 1;
      for (int j = 1; j <= a[i + 1]; j++) ans1[v] = par, ans2[v] = par, v++;
    } else if (a[i + 1] == 1) {
      par = v - 1;
      ans1[v] = par, ans2[v] = par, v++;
    } else {
      if (flag) {
        par = v - 1;
        for (int j = 1; j <= a[i + 1]; j++) ans1[v] = par, ans2[v] = par, v++;
      } else {
        flag = 1;
        par = v - a[i];
        for (int j = 1; j <= a[i + 1]; j++) ans1[v] = par, v++;
        v = par + a[i];
        ans2[v] = par, v++;
        par++;
        for (int j = 2; j <= a[i + 1]; j++) ans2[v] = par, v++;
      }
    }
  }
  if (flag) {
    cout << "ambiguous" << endl;
    for (int i = 1; i <= sum; i++) printf("%i ", ans1[i]);
    cout << endl;
    for (int i = 1; i <= sum; i++) printf("%i ", ans2[i]);
  } else {
    cout << "perfect";
  }
  return 0;
}
