#include <bits/stdc++.h>
using namespace std;
const int N = 200003;
int n, a[N], sum[N];
int main() {
  bool flag = false;
  scanf("%d", &n);
  ++n;
  for (register int i = 1; i <= n; i++)
    scanf("%d", a + i), flag |= (a[i] >= 2 && a[i - 1] >= 2),
        sum[i] = sum[i - 1] + a[i];
  if (flag) {
    puts("ambiguous");
    printf("0");
    for (register int i = 2; i <= n; i++)
      for (register int j = 1; j <= a[i]; j++) printf(" %d", sum[i - 1]);
    printf("\n0");
    for (register int i = 2; i <= n; i++)
      for (register int j = 0; j < a[i]; j++)
        if (a[i] >= 2 && a[i - 1] >= 2)
          printf(" %d", max(sum[i - 1] - j, sum[i - 2] + 1));
        else
          printf(" %d", sum[i - 1]);
  } else
    puts("perfect");
}
