#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
int d[N];
int main(void) {
  int n, index;
  cin >> n;
  for (int i = 0; i <= n; i++) scanf("%d", &d[i]);
  int flag = 1;
  for (int i = 1; i <= n; i++) {
    if (d[i] > 1 && d[i - 1] > 1) {
      flag = 0;
      index = i;
      break;
    }
  }
  if (flag == 1)
    cout << "perfect" << endl;
  else {
    cout << "ambiguous" << endl;
    if (flag == 0) {
      int first = 1, last = 1, cur = 1;
      printf("0");
      for (int i = 1; i <= n; i++) {
        if (i == index) {
          for (int j = 1; j <= d[i]; j++) printf(" %d", first);
          first = last + 1;
          last += d[i];
        } else {
          for (int j = 1; j <= d[i]; j++) {
            printf(" %d", last);
          }
          first = last + 1;
          last += d[i];
        }
      }
      puts("");
      first = 1, last = 1, cur = 1;
      printf("0");
      for (int i = 1; i <= n; i++) {
        if (i == index) {
          for (int j = 1; j <= 1; j++) printf(" %d", first);
          for (int j = 2; j <= d[i]; j++) printf(" %d", last);
          first = last + 1;
          last += d[i];
        } else {
          for (int j = 1; j <= d[i]; j++) {
            printf(" %d", last);
          }
          first = last + 1;
          last += d[i];
        }
      }
    }
    if (flag == -1) {
      int first = 1, last = 1, cur = 1;
      printf("0");
      for (int i = 1; i <= n; i++) {
        if (i == index) {
          printf(" %d", first);
          first = last + 1;
          last += d[i];
        } else {
          for (int j = 1; j <= d[i]; j++) {
            printf(" %d", last);
          }
          first = last + 1;
          last += d[i];
        }
      }
      puts("");
      first = 1, last = 1, cur = 1;
      printf("0");
      for (int i = 1; i <= n; i++) {
        if (i == index) {
          for (int j = 1; j <= 1; j++) printf(" %d", first + 1);
          first = last + 1;
          last += d[i];
        } else {
          for (int j = 1; j <= d[i]; j++) {
            printf(" %d", last);
          }
          first = last + 1;
          last += d[i];
        }
      }
    }
  }
  return 0;
}
