#include <bits/stdc++.h>
using namespace std;
int main() {
  int h;
  cin >> h;
  vector<vector<int> > v(h + 9);
  int l = 0;
  bool p = 1;
  int ls = -1;
  for (int i = 0; i < (h + 1); i++) {
    int x;
    cin >> x;
    if (x > 1 && ls > 1) p = 0;
    for (int o = 0; o < x; o++) {
      v[i].push_back(++l);
    }
    ls = x;
  }
  if (p) {
    cout << "perfect";
    return 0;
  }
  int i = 1;
  vector<int> p1(l + 9);
  vector<int> p2(l + 9);
  p1[1] = 0;
  p2[1] = 0;
  while (v[i].size()) {
    for (int o = 0; o < v[i].size(); o++) {
      p1[v[i][o]] = v[i - 1][0];
      if (v[i - 1].size() == 1) {
        p2[v[i][o]] = v[i - 1][0];
      } else {
        if (o % 2) {
          p2[v[i][o]] = v[i - 1][1];
        } else {
          p2[v[i][o]] = v[i - 1][0];
        }
      }
    }
    i++;
  }
  cout << "ambiguous\n";
  cout << 0 << " ";
  i = 2;
  while (p1[i]) {
    cout << p1[i] << " ";
    i++;
  }
  cout << "\n0 ";
  i = 2;
  while (p2[i]) {
    cout << p2[i] << " ";
    i++;
  }
  return 0;
}
