#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int H = 1e5 + 5;
int h;
int arr[H];
int sum[H];
vector<int> tree1, tree2;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> h;
  sum[0] = 1;
  for (int i = 0; i <= h; i++) {
    cin >> arr[i];
    sum[i] = sum[i - 1] + arr[i];
  }
  tree1.push_back(0);
  tree2.push_back(0);
  for (int i = 1; i <= arr[1]; i++) {
    tree1.push_back(1);
    tree2.push_back(1);
  }
  for (int i = 2; i <= h; i++) {
    if (arr[i] == 1 || arr[i - 1] == 1) {
      for (int j = 1; j <= arr[i]; j++) {
        tree1.push_back(sum[i - 2] + 1);
        tree2.push_back(sum[i - 2] + 1);
      }
    } else {
      for (int j = 1; j <= arr[i]; j++) {
        tree1.push_back(sum[i - 2] + 1);
      }
      for (int j = 1; j < arr[i]; j++) {
        tree2.push_back(sum[i - 2] + 1);
      }
      tree2.push_back(sum[i - 1]);
    }
  }
  int ans = 0;
  for (int i = 0; i < tree1.size(); i++) {
    if (tree1[i] == tree2[i]) ans++;
  }
  if (ans == tree1.size()) {
    cout << "perfect";
    return 0;
  }
  cout << "ambiguous\n";
  for (int i = 0; i < tree1.size(); i++) cout << tree1[i] << " ";
  cout << endl;
  for (int i = 0; i < tree2.size(); i++) cout << tree2[i] << " ";
}
