#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N], sum[N];
int ans1[N], ans2[N];
int main() {
  int h;
  scanf("%d", &h), ++h;
  for (int i = 1; i <= h; ++i) scanf("%d", &a[i]);
  int flg = 1;
  for (int i = 1; i < h; ++i)
    if (a[i] > 1 && a[i + 1] > 1) {
      flg = 0;
      break;
    }
  if (flg) return puts("perfect"), 0;
  puts("ambiguous");
  for (int i = 1; i <= h; ++i) sum[i] = sum[i - 1] + a[i];
  ans1[1] = 0;
  for (int i = 2; i <= h; ++i)
    for (int k = sum[i - 1] + 1; k <= sum[i]; ++k) ans1[k] = sum[i - 2] + 1;
  ans2[1] = 0;
  for (int i = 2; i <= h; ++i) {
    ans2[sum[i - 1] + 1] = sum[i - 2] + 1;
    for (int k = sum[i - 1] + 2; k <= sum[i]; ++k) ans2[k] = sum[i - 1];
  }
  int n = sum[h];
  for (int i = 1; i <= n; ++i) printf("%d%c", ans1[i], i == n ? '\n' : ' ');
  for (int i = 1; i <= n; ++i) printf("%d%c", ans2[i], i == n ? '\n' : ' ');
  return 0;
}
