#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
vector<int> g[N];
void eadd(int u, int v) {
  g[u].push_back(v);
  g[v].push_back(u);
}
vector<int> A[N];
int pt1[N], pt2[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int h;
  cin >> h;
  int vcount = 0;
  bool perf = true;
  for (int i = 0; i <= h; ++i) {
    int x;
    cin >> x;
    for (int j = 1; j <= x; ++j) A[i].push_back(++vcount);
    if (i && A[i].size() > 1 && A[i - 1].size() > 1) perf = false;
  }
  if (perf) {
    cout << "perfect\n";
    return 0;
  }
  pt1[1] = pt2[1] = 0;
  for (int i = 1; i <= h; ++i) {
    for (int u : A[i]) pt1[u] = A[i - 1][0];
    if (A[i - 1].size() > 1 && A[i].size() > 1) {
      for (int u : A[i]) pt2[u] = A[i - 1][0];
      pt2[A[i][0]] = A[i - 1][1];
    } else
      for (int u : A[i]) pt2[u] = A[i - 1][0];
  }
  cout << "ambiguous\n";
  for (int i = 1; i <= vcount; ++i) cout << pt1[i] << " \n"[i == vcount];
  for (int i = 1; i <= vcount; ++i) cout << pt2[i] << " \n"[i == vcount];
  return 0;
}
