#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-10;
const int M = 1e9 + 7;
int dcmp(double first) {
  if (fabs(first) < eps) return 0;
  return first < 0 ? -1 : 1;
}
int a[N];
int main() {
  int n, f = 0;
  scanf("%d", &n);
  for (int i = 0; i <= n; i++) {
    scanf("%d", &a[i]);
    if (i && a[i] > 1 && a[i - 1] > 1) f = 1;
  }
  printf("%s\n", f ? "ambiguous" : "perfect");
  for (int l = 0; l < 2 && f; l++) {
    int p = 0, p0 = 0, cnt = 1;
    for (int i = 0; i <= n; i++) {
      int p1 = 0, p2 = 0;
      for (int k = 0; k < a[i]; k++) {
        if (!k) p1 = cnt;
        if (l && k == 1) p2 = cnt;
        if (l && !k && p0)
          printf("%d ", p0);
        else
          printf("%d ", p);
        cnt++;
      }
      p = p1;
      p0 = p2;
    }
    puts("");
  }
  return 0;
}
