#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1e5 + 5;
inline int R() {
  char c;
  int res, sign = 1;
  while ((c = getchar()) > '9' || c < '0')
    if (c == '-') sign = -1;
  res = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') res = res * 10 + c - '0';
  return res * sign;
}
int n, m, a[Maxn], p, s, S[Maxn];
int main() {
  n = R();
  bool _ = 0, ans = 0;
  for (int i = 1; i <= n + 1; i++) {
    a[i] = R();
    s += a[i];
    S[i] = S[i - 1] + a[i];
    if (a[i] != 1 && _) ans = 1;
    if (a[i] != 1)
      _ = 1;
    else
      _ = 0;
  }
  S[0] = -1;
  if (!ans) {
    return 0 * puts("perfect");
  } else {
    puts("ambiguous");
    int now = 1;
    for (int i = 1; i <= s; i++) {
      if (i > S[now]) now++;
      printf("%d ", S[now - 1] - a[now - 1] + 1);
    }
    puts("");
    now = 1;
    bool __ = 1;
    for (int i = 1; i <= s; i++) {
      if (i > S[now]) now++;
      if (a[now - 1] > 1 && a[now] > 1 && __) {
        __ = 0;
        printf("%d ", S[now - 1] - a[now - 1] + 2);
      } else {
        printf("%d ", S[now - 1] - a[now - 1] + 1);
        __ = 1;
      }
    }
  }
  return 0;
}
