#include <bits/stdc++.h>
using namespace std;
int main() {
  int h;
  cin >> h;
  vector<int> a(h + 1);
  for (int i = 0; i <= h; i++) cin >> a[i];
  int st = 0;
  for (int i = 0; i < h; i++)
    if ((a[i] - 1) && (a[i + 1] - 1)) st = 1;
  if (st == 0) {
    cout << "perfect\n";
    return 0;
  } else
    cout << "ambiguous\n";
  vector<vector<int> > lvl(h + 1, vector<int>(0));
  int curr = 0;
  for (int i = 0; i <= h; i++) {
    for (int j = 0; j < a[i]; j++, curr++) lvl[i].push_back(curr);
  }
  cout << "0 ";
  for (int i = 1; i <= h; i++)
    for (int j = 0; j < lvl[i].size(); j++) cout << lvl[i - 1][0] + 1 << " ";
  cout << endl;
  cout << "0 ";
  int x = 0;
  for (int i = 1; i <= h; i++) {
    for (int j = 0; j < lvl[i].size(); j++) {
      if (lvl[i].size() >= 2 && lvl[i - 1].size() >= 2 && x == 0) {
        cout << lvl[i - 1][1] + 1 << " ";
        x = 1;
      } else
        cout << lvl[i - 1][0] + 1 << " ";
    }
  }
  cout << endl;
  return 0;
}
