#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i <= n; i++) scanf("%d", &a[i]);
  int flag = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] > 1 && a[i - 1] > 1) {
      flag = i;
      break;
    }
  }
  if (flag == 0) {
    puts("perfect");
    return 0;
  }
  puts("ambiguous");
  int head = 0;
  for (int i = 0; i <= n; i++) {
    if (i == flag) {
      for (int j = 0; j < a[i] - 1; j++) printf("%d ", head - 1);
      printf("%d ", head);
    } else {
      for (int j = 0; j < a[i]; j++) printf("%d ", head);
    }
    head += a[i];
  }
  puts("");
  head = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j < a[i]; j++) printf("%d ", head);
    head += a[i];
  }
  return 0;
}
