#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
int c[MAXN];
int ans1[MAXN], ans2[MAXN];
int main() {
  int h;
  scanf("%d", &h);
  for (int i = 0; i <= h; i++) {
    scanf("%d", &c[i]);
  }
  int amb = -1;
  for (int i = 0; i <= h - 1; i++) {
    if (c[i] > 1 && c[i + 1] > 1) {
      amb = i + 1;
      break;
    }
  }
  if (amb == -1) return 0 * puts("perfect");
  int prev = 0;
  for (int i = 0; i <= h; i++) {
    if (i == amb) {
      ans1[prev + 1] = prev - 1;
      ans2[prev + 1] = prev;
      for (int node = prev + 2; node <= prev + c[i]; node++) {
        ans1[node] = ans2[node] = prev;
      }
    } else {
      for (int node = prev + 1; node <= prev + c[i]; node++) {
        ans1[node] = ans2[node] = prev;
      }
    }
    prev += c[i];
  }
  puts("ambiguous");
  for (int i = 1; i <= prev; i++)
    printf("%d%c", ans1[i], (i == prev) ? '\n' : ' ');
  for (int i = 1; i <= prev; i++)
    printf("%d%c", ans2[i], (i == prev) ? '\n' : ' ');
  return 0;
}
