#include <bits/stdc++.h>
using namespace std;
int n, a[100010];
int main() {
  cin >> n;
  for (int i = 0; i <= n; i++) {
    cin >> a[i];
  }
  bool pp = true;
  for (int I = 1; I <= n; I++)
    if (a[I - 1] > 1 && a[I] > 1) {
      puts("ambiguous");
      int p = 0;
      for (int i = 0; i <= n; i++) {
        for (int j = 1; j <= a[i]; j++) printf("%d ", p);
        p = p + a[i];
      }
      putchar('\n');
      p = 0;
      for (int i = 0; i <= I - 1; i++) {
        for (int j = 1; j <= a[i]; j++) printf("%d ", p);
        p = p + a[i];
      }
      for (int j = 1; j <= a[I] - 1; j++) printf("%d ", p);
      printf("%d ", p - 1);
      p = p + a[I];
      for (int i = I + 1; i <= n; i++) {
        for (int j = 1; j <= a[i]; j++) printf("%d ", p);
        p = p + a[i];
      }
      putchar('\n');
      pp = false;
      break;
    }
  if (pp) puts("perfect");
}
