#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int h;
vector<int> hs;
bool perfect() {
  for (int i = 1; i <= h; i++) {
    if (hs[i - 1] > 1 && hs[i] > 1) return false;
  }
  return true;
}
vector<int> first, second;
bool splitted = false;
void solve(int cur_h) {
  if (cur_h > h) return;
  if (cur_h == 0) {
    first.push_back(0);
    second.push_back(0);
  } else if (splitted || hs[cur_h - 1] <= 1) {
    int last = first.size() - 1;
    for (int i = 0; i < hs[cur_h]; i++) first.push_back(last);
    last = second.size() - 1;
    for (int i = 0; i < hs[cur_h]; i++) second.push_back(last);
  } else if (hs[cur_h] >= 1) {
    if (hs[cur_h] > 1) splitted = true;
    int last = first.size() - 1;
    first.push_back(last);
    for (int i = 0; i < hs[cur_h] - 1; i++) first.push_back(last);
    last = second.size() - 1;
    second.push_back(last - 1);
    for (int i = 0; i < hs[cur_h] - 1; i++) second.push_back(last);
  }
  solve(cur_h + 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> h;
  hs.resize(h + 1, 0);
  for (int i = 0; i <= h; i++) cin >> hs[i];
  if (perfect())
    cout << "perfect" << endl;
  else {
    cout << "ambiguous" << endl;
    solve(0);
    cout << first[0];
    for (int i = 1; i < first.size(); i++) cout << ' ' << first[i] + 1;
    cout << endl;
    cout << second[0];
    for (int i = 1; i < second.size(); i++) cout << ' ' << second[i] + 1;
    cout << endl;
  }
  return 0;
}
