#include <bits/stdc++.h>
using namespace std;
int N, H, arr[200011], p[200011];
bool possible;
int main() {
  if (fopen("data.in", "r")) freopen("data.in", "r", stdin);
  scanf("%d", &H);
  for (int i = 0; i <= H; i++) {
    scanf("%d", &arr[i]);
    N += arr[i];
    possible |= (i && (arr[i] > 1 && arr[i - 1] > 1));
  }
  if (!possible) {
    printf("perfect\n");
    return 0;
  }
  printf("ambiguous\n");
  int cur = 0, lvl = 1;
  printf("0 ");
  for (int i = 1; i < N; i++) {
    if (arr[lvl]) {
      arr[lvl]--;
      p[i] = cur;
    }
    if (!arr[lvl]) {
      cur = i;
      lvl++;
    }
    printf("%d ", p[i] + 1);
  }
  printf("\n");
  printf("0 ");
  cur = 0;
  int prv = 1;
  for (int i = 1; i < N; i++) {
    if (p[i] != p[i - 1]) {
      prv = cur;
      cur = 0;
    }
    if ((++cur) > 1 && prv > 1)
      printf("%d ", i - cur);
    else
      printf("%d ", p[i] + 1);
  }
  printf("\n");
  return 0;
}
