#include <bits/stdc++.h>
using namespace std;
const int N = 3e6 + 6;
int a[N];
int p[N][2];
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i <= n; i++) {
    cin >> a[i];
  }
  int node = 1;
  int lst = 0;
  for (int i = 0; i <= n; i++) {
    int start = node;
    for (int j = 1; j <= a[i]; j++) {
      p[node++][0] = lst;
    }
    lst = start;
  }
  vector<int> lvl;
  lvl.push_back(0);
  node = 1;
  for (int i = 0; i <= n; i++) {
    int sz = lvl.size();
    vector<int> trt;
    for (int j = 0; j < a[i]; j++) {
      p[node][1] = lvl[j % sz];
      trt.push_back(node);
      node++;
    }
    lvl.clear();
    for (int x : trt) lvl.push_back(x);
  }
  bool perfect = true;
  for (int i = 1; i < node; i++) {
    if (p[i][0] != p[i][1]) {
      perfect = false;
    }
  }
  if (perfect) {
    cout << "perfect" << endl;
    return;
  }
  cout << "ambiguous" << endl;
  for (int i = 1; i < node; i++) {
    cout << p[i][0] << " ";
  }
  cout << endl;
  for (int i = 1; i < node; i++) {
    cout << p[i][1] << " ";
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
