#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]);
  }
  bool ok = 1;
  for (int i = 0; i <= n - 1; i++) {
    if (a[i] > 1 && a[i + 1] > 1) {
      ok = 0;
      break;
    }
  }
  if (ok)
    printf("perfect\n");
  else {
    printf("ambiguous\n");
    printf("0 ");
    int fi = 1, la = 1;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= a[i]; j++) {
        printf("%d ", fi);
      }
      fi += a[i - 1];
      la = fi + a[i] - 1;
    }
    printf("\n");
    printf("0 ");
    fi = 1, la = 1;
    int idx = 1;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= a[i]; j++) {
        printf("%d ", fi);
      }
      fi += a[i - 1];
      la = fi + a[i] - 1;
      if (a[i] > 1 && a[i + 1] > 1) {
        idx = i;
        break;
      }
    }
    int mid = a[idx + 1] / 2;
    for (int i = 1; i <= mid; i++) {
      printf("%d ", fi);
    }
    for (int i = mid + 1; i <= a[idx + 1]; i++) {
      printf("%d ", la);
    }
    fi += a[idx];
    la = fi + a[idx + 1] - 1;
    for (int i = idx + 2; i <= n; i++) {
      for (int j = 1; j <= a[i]; j++) {
        printf("%d ", fi);
      }
      fi += a[i - 1];
      la = fi + a[i] - 1;
    }
    printf("\n");
  }
}
