#include <bits/stdc++.h>
using namespace std;
int n, i, j, k, m, a, c, w;
int l[100005];
int t[200005], s[200005], dp[200005];
int main() {
  scanf("%d", &n);
  c = a = 0;
  for (i = 0; i <= n; i++) {
    scanf("%d", l + i);
    dp[i] = c;
    c += l[i];
    if (l[i] > 1) a++;
    if (l[i] == 1) {
      a = a == 1 ? 0 : a;
    }
  }
  if (a <= 1) {
    puts("perfect");
    return 0;
  }
  puts("ambiguous");
  t[0] = s[0] = 0;
  if (l[0] > 1)
    j = 0, w = 1;
  else
    j = 1, w = 0;
  printf("0 ");
  for (i = 1; i < c; i++) {
    if (l[j]) {
      s[i] = dp[j];
      w++;
    }
    if (l[j] == w) {
      j += 1;
      w = 0;
    }
    printf("%d ", s[i]);
  }
  puts("");
  printf("0 ");
  if (l[0] > 1)
    j = 0, w = 1;
  else
    j = 1, w = 0;
  for (i = 1; i < c; i++) {
    if (l[j]) {
      t[i] = dp[j];
      if (j && w && dp[j] - dp[j - 1] > 1) t[i]--;
      w++;
    }
    if (l[j] == w) {
      j++;
      w = 0;
    }
    printf("%d ", t[i]);
  }
  puts("");
  return 0;
}
