#include <bits/stdc++.h>
using namespace std;
const int MaxN = 100003;
int h, a[MaxN];
int fa[MaxN * 2];
int main() {
  scanf("%d", &h);
  h++;
  for (int i = 1; i <= h; ++i) scanf("%d", a + i);
  for (int I = 1; I < h; ++I)
    if (a[I] > 1 && a[I + 1] > 1) {
      puts("ambiguous");
      int tot = 1;
      for (int i = 2; i <= I; ++i) {
        int t = tot;
        for (int j = 1; j <= a[i]; ++j) fa[++tot] = t;
      }
      int o = tot;
      for (int i = I + 1; i <= h; ++i) {
        int t = tot;
        for (int j = 1; j <= a[i]; ++j) fa[++tot] = t;
      }
      for (int i = 1; i <= tot; ++i) printf("%d ", fa[i]);
      puts("");
      fa[o + 1]--;
      for (int i = 1; i <= tot; ++i) printf("%d ", fa[i]);
      puts("");
      return 0;
    }
  puts("perfect");
  return 0;
}
