#include <bits/stdc++.h>
using namespace std;
int cas = 1;
int dxx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dyy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};
struct node {
  int x, y;
  bool operator<(const node& p) const { return x < p.x; }
};
int a[200005];
int par[200005];
int par1[200005];
int main() {
  int n;
  scanf("%d", &n);
  int c = 0;
  for (int i = 0; i <= n; i++) {
    scanf("%d", &a[i]);
    c += a[i];
  }
  int flag = 1;
  int tg = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] > 1 && a[i + 1] > 1) {
      flag = 0;
      tg = i;
      break;
    }
  }
  if (flag) {
    printf("perfect\n");
    return 0;
  }
  par[1] = 0;
  par1[1] = 0;
  int cnt = 2;
  for (int i = 1; i < tg; i++) {
    int x = cnt - 1;
    for (int j = 1; j <= a[i]; j++) {
      par[cnt] = par1[cnt] = x;
      cnt++;
    }
  }
  int x = cnt - 1;
  int aa = cnt;
  int b = cnt + 1;
  for (int i = 1; i <= a[tg]; i++) {
    par[cnt] = x;
    par1[cnt++] = x;
  }
  int p = cnt;
  for (int i = 1; i <= a[tg + 1]; i++) {
    par[cnt++] = aa;
  }
  for (int i = tg + 2; i <= n; i++) {
    x = cnt - 1;
    for (int j = 1; j <= a[i]; j++) {
      par[cnt++] = x;
    }
  }
  cnt = p;
  for (int i = 1; i <= a[tg + 1]; i++) {
    if (i == 1) {
      par1[cnt++] = aa;
    } else
      par1[cnt++] = b;
  }
  for (int i = tg + 2; i <= n; i++) {
    x = cnt - 1;
    for (int j = 1; j <= a[i]; j++) {
      par1[cnt++] = x;
    }
  }
  printf("ambiguous\n");
  for (int i = 1; i <= c; i++) {
    if (i == 1)
      printf("%d", par[i]);
    else
      printf(" %d", par[i]);
  }
  printf("\n");
  for (int i = 1; i <= c; i++) {
    if (i == 1)
      printf("%d", par1[i]);
    else
      printf(" %d", par1[i]);
  }
  printf("\n");
  return 0;
}
