#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
int a[100005];
int main() {
  int n;
  scanf("%d", &n);
  bool one = true;
  for (int i = 0; i < n + 1; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i < n + 1; ++i) {
    if (a[i - 1] > 1 && a[i] > 1) {
      one = false;
      break;
    }
  }
  if (one) {
    cout << "perfect";
    return 0;
  }
  cout << "ambiguous\n0 ";
  int c = 2;
  for (int i = 1; i < n + 1; ++i) {
    if (a[i - 1] == 1) {
      for (int j = 0; j < a[i]; ++j) {
        printf("%d ", c - 1);
      }
      c += a[i];
    } else {
      for (int j = 0; j < a[i]; ++j) {
        printf("%d ", c - 1);
      }
      c += a[i];
    }
  }
  cout << "\n0 ";
  c = 2;
  for (int i = 1; i < n + 1; ++i) {
    if (a[i - 1] == 1) {
      for (int j = 0; j < a[i]; ++j) {
        printf("%d ", c - 1);
      }
      c += a[i];
    } else {
      for (int j = 0; j < a[i]; ++j) {
        printf("%d ", c - ((j + 1) % a[i - 1]) - 1);
      }
      c += a[i];
    }
  }
  return 0;
}
