#include <bits/stdc++.h>
using namespace std;
int n, a[200010];
int fa[200010];
int main() {
  cin >> n;
  for (int i = 0; i <= n; i++) cin >> a[i];
  bool flag = false;
  int mark;
  for (int i = 0; i <= n; i++) {
    if (a[i - 1] > 1 && a[i] > 1) {
      flag = true;
      mark = i;
      break;
    }
  }
  int u, v;
  if (!flag)
    cout << "perfect" << endl;
  else {
    cout << "ambiguous" << endl;
    int pre = 1, cur = 1;
    printf("0");
    for (int h = 1; h <= n; h++) {
      cur += a[h];
      for (int i = pre + 1; i <= cur; i++) fa[i] = pre;
      if (h == mark) {
        u = pre + 1;
        v = pre - 1;
      }
      pre = cur;
    }
    for (int i = 2; i <= cur; i++) printf(" %d", fa[i]);
    printf("\n0");
    fa[u] = v;
    for (int i = 2; i <= cur; i++) printf(" %d", fa[i]);
  }
  return 0;
}
