#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
int h[maxn] = {0};
int v[maxn];
int main() {
  int n;
  scanf("%d", &n);
  int sum = 0;
  for (int i = 0; i <= n; i++) {
    scanf("%d", h + i);
    sum += h[i];
  }
  int count = 0;
  for (int i = 0; i <= n; i++) {
    if (h[i] == 1) {
      count++;
    } else {
      if (h[i + 1] > 1) break;
      count++;
    }
  }
  if (count == n + 1 || count == n) {
    printf("perfect");
  } else {
    printf("ambiguous\n");
    int res = 0;
    for (int i = 0; i < count; i++) {
      for (int j = 0; j < h[i]; j++) cout << res << " ";
      res += h[i];
    }
    for (int i = count; i <= n; i++) {
      for (int j = 0; j < h[i]; j++) {
        cout << res << " ";
      }
      res += h[i];
    }
    cout << endl;
    res = 0;
    for (int i = 0; i < count; i++) {
      for (int j = 0; j < h[i]; j++) cout << res << " ";
      res += h[i];
    }
    for (int i = count; i <= n; i++) {
      for (int j = 0; j < h[i]; j++) {
        if (h[i - 1] == 1) {
          cout << res << " ";
        } else {
          if (j == 0)
            cout << res << " ";
          else
            cout << res - 1 << " ";
        }
      }
      res += h[i];
    }
  }
  return 0;
}
