#include <bits/stdc++.h>
using namespace std;
int h, s[200002], a[200002], p[200002], q[200002];
int main() {
  scanf("%d\n", &h);
  s[0] = 0;
  for (int i = 0; i <= h; ++i) scanf("%d", a + i), s[i] = s[i - 1] + a[i];
  bool anc = 0;
  for (int i = h - 1; i >= 0; --i) {
    if (a[i] == 1) {
      for (int j = s[i] + 1; j <= s[i + 1]; ++j) p[j] = q[j] = s[i];
      continue;
    } else if (a[i + 1] == 1) {
      p[s[i] + 1] = q[s[i] + 1] = s[i];
      continue;
    }
    anc = 1;
    for (int j = s[i] + 1; j < s[i + 1]; ++j) p[j] = q[j] = s[i];
    p[s[i + 1]] = s[i];
    q[s[i + 1]] = s[i] - 1;
  }
  if (!anc)
    printf("perfect");
  else {
    printf("ambiguous\n");
    for (int j = 1; j <= s[h]; ++j) printf("%d ", p[j]);
    printf("\n");
    for (int j = 1; j <= s[h]; ++j) printf("%d ", q[j]);
  }
  return 0;
}
