#include <bits/stdc++.h>
using namespace std;
long long int h, arr[210000], temp;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> h;
  for (int i = 0; i <= h; i++) {
    cin >> arr[i];
  }
  int flag = 1, prev = 1;
  for (int i = 0; i <= h; i++) {
    if (prev > 1 and arr[i] > 1) {
      flag = 0;
    }
    prev = arr[i];
  }
  if (flag) {
    cout << "perfect\n";
  } else {
    cout << "ambiguous\n";
    vector<int> ans1, ans2;
    ans1.push_back(0);
    ans2.push_back(0);
    int prev1 = 1, prev2 = 1, curr1 = 2, curr2 = 2;
    for (int i = 1; i <= h; i++) {
      if (arr[i - 1] > 1 and arr[i] > 1) {
        int temp = prev2, org = prev2;
        for (int j = 0; j < arr[i]; j++) {
          ans1.push_back(prev1);
          ans2.push_back(prev2);
          prev2++;
          if (prev2 == curr2) prev2 = org;
        }
      } else {
        for (int j = 0; j < arr[i]; j++) {
          ans1.push_back(prev1);
          ans2.push_back(prev2);
        }
      }
      prev1 = curr1;
      prev2 = curr2;
      curr1 += arr[i];
      curr2 += arr[i];
    }
    for (int i = 0; i < ans1.size(); i++) cout << ans1[i] << " ";
    cout << "\n";
    for (int i = 0; i < ans2.size(); i++) cout << ans2[i] << " ";
    cout << "\n";
  }
}
