#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, *arr, c = 1;
  bool b = true;
  cin >> n;
  arr = new int[n + 1];
  for (int i = 0; i <= n; i++) cin >> arr[i];
  for (int i = 0; i < n; i++)
    if (arr[i] > 1 && arr[i + 1] > 1) {
      b = false;
      break;
    }
  if (b) {
    cout << "perfect";
    return 0;
  }
  cout << "ambiguous\n";
  vector<vector<int>> x(n + 1);
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j < arr[i]; j++) x[i].push_back(c++);
  }
  cout << "0 ";
  for (int i = 1; i <= n; i++)
    for (auto& v : x[i]) cout << *x[i - 1].begin() << ' ';
  cout << "\n0 ";
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < x[i].size() - 1; j++) cout << *x[i - 1].begin() << ' ';
    cout << *x[i - 1].rbegin() << ' ';
  }
  return 0;
}
