#include <bits/stdc++.h>
using namespace std;
int N;
int f[200005];
int fa[200005];
int sec[200005];
int main() {
  memset(sec, -1, sizeof(sec));
  int S = 0;
  scanf("%d", &N);
  for (int i = 0; i <= N; i++) {
    scanf("%d", &f[i]);
    S += f[i];
  }
  bool tag = 0;
  int pos = 0;
  for (int i = 0; i <= N; i++) {
    if (f[i] != 1 && tag) {
      pos = i;
      break;
    }
    if (f[i] == 1) tag = 0;
    if (f[i] != 1) tag = 1;
  }
  if (pos == 0) {
    printf("perfect\n");
    return 0;
  }
  int sum = 1;
  for (int i = 1; i <= N; i++) {
    int pl = sum - f[i - 1] + 1;
    for (int j = sum + 1; j <= sum + f[i]; j++) fa[j] = pl;
    if (i == pos) {
      fa[sum + f[i]] = pl + 1;
      sec[sum + f[i]] = pl;
    }
    sum += f[i];
  }
  printf("ambiguous\n");
  printf("0");
  for (int i = 2; i <= S; i++) printf(" %d", fa[i]);
  printf("\n");
  printf("0");
  for (int i = 2; i <= S; i++) {
    if (sec[i] != -1)
      printf(" %d", sec[i]);
    else
      printf(" %d", fa[i]);
  }
  return 0;
}
