#include <bits/stdc++.h>
using namespace std;
int h;
int a[1121345];
vector<int> g1[200005];
vector<int> g2[200005];
void add(vector<int>& x, vector<int>& y) {
  for (int i = 0; i < y.size(); i++) {
    g1[y[i]].push_back(x[0]);
    g1[x[0]].push_back(y[i]);
  }
}
void add2(vector<int>& x, vector<int>& y) {
  if (x.size() > 1) {
    for (int i = 0; i < y.size() - 1; i++) {
      g2[y[i]].push_back(x[0]);
      g2[x[0]].push_back(y[i]);
    }
    g2[y[y.size() - 1]].push_back(x[1]);
    g2[x[1]].push_back(y[y.size() - 1]);
    return;
  }
  for (int i = 0; i < y.size(); i++) {
    g2[y[i]].push_back(x[0]);
    g2[x[0]].push_back(y[i]);
  }
}
int parent[212345];
int parent2[212345];
void dfs(int u, int par) {
  for (int i = 0; i < g1[u].size(); i++) {
    int v = g1[u][i];
    if (v == par) continue;
    parent[v] = u;
    dfs(v, u);
  }
}
void dfs2(int u, int par) {
  for (int i = 0; i < g2[u].size(); i++) {
    int v = g2[u][i];
    if (v == par) continue;
    parent2[v] = u;
    dfs2(v, u);
  }
}
int main() {
  cin >> h;
  for (int i = 0; i <= h; i++) {
    cin >> a[i];
  }
  int ok = 1;
  for (int i = 0; i < h; i++) {
    ok &= (!(a[i] > 1 && a[i + 1] > 1));
  }
  if (ok) {
    cout << "perfect" << endl;
    return 0;
  }
  cout << "ambiguous" << endl;
  int root = 1;
  int nodes = 2;
  vector<int> prv(1, 1);
  for (int i = 1; i <= h; i++) {
    int p = a[i];
    vector<int> v;
    while (p--) {
      v.push_back(nodes++);
    }
    add(prv, v);
    add2(prv, v);
    prv = v;
  }
  dfs(1, 1);
  dfs2(1, 1);
  for (int i = 1; i < nodes; i++) {
    cout << parent[i] << " ";
  }
  cout << endl;
  for (int i = 1; i < nodes; i++) {
    cout << parent2[i] << " ";
  }
}
