#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int lvl[N], n;
vector<int> sv[N];
int par1[N], par2[N];
int main() {
  scanf("%d", &n);
  int cur = 0;
  bool f = 0;
  for (int i = 0; i <= n; i++) {
    scanf("%d", lvl + i), f |= (i && (lvl[i] > 1 && lvl[i - 1] > 1));
    for (int j = 0; j < lvl[i]; j++, cur++) {
      sv[i].push_back(cur + 1);
      if (i) par1[cur + 1] = sv[i - 1][0];
      par2[cur + 1] = par1[cur + 1];
    }
  }
  if (!f) return puts("perfect");
  puts("ambiguous");
  for (int i = 1; i <= n; i++)
    if (lvl[i] > 1 && lvl[i - 1] > 1) {
      par2[sv[i][0]] = sv[i - 1][1];
      break;
    }
  for (int i = 1; i <= cur; i++) printf("%d ", par1[i]);
  puts("");
  for (int i = 1; i <= cur; i++) printf("%d ", par2[i]);
  return 0;
}
