#include <bits/stdc++.h>
using namespace std;
vector<int> number;
int main() {
  int h;
  cin >> h;
  number.resize(h + 1);
  int size = 0;
  for (int i = 0; i <= h; i++) {
    cin >> number[i];
    size += number[i];
  }
  bool perfect = true;
  vector<int> parent(size, -1);
  int diff = -1;
  int second = -1;
  int count_last = 0;
  int mover = 1;
  for (int i = 1; i <= h; i++) {
    if (perfect && number[i - 1] > 1 && number[i] > 1) {
      perfect = false;
      parent[count_last + 1] = count_last;
      diff = count_last + 1;
      second = count_last - 1;
      for (int j = 1; j < number[i]; j++)
        parent[count_last + 1 + j] = count_last;
      count_last += number[i];
      continue;
    }
    for (int j = 0; j < number[i]; j++) {
      parent[count_last + 1 + j] = count_last;
    }
    count_last += number[i];
  }
  if (perfect) {
    cout << "perfect" << endl;
    return 0;
  }
  cout << "ambiguous" << endl;
  for (int i = 0; i < parent.size(); i++) {
    cout << parent[i] + 1 << ' ';
  }
  cout << endl;
  for (int i = 0; i < parent.size(); i++) {
    if (i == diff) {
      cout << second + 1 << ' ';
    } else
      cout << parent[i] + 1 << ' ';
  }
  cout << endl;
  return 0;
}
