#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i <= n; i++) cin >> arr[i];
  bool perfect = true;
  for (int i = 0; i < n; i++)
    if (arr[i] > 1 && arr[i + 1] > 1) {
      perfect = false;
      break;
    }
  if (perfect) return cout << "perfect\n", 0;
  cout << "ambiguous\n";
  for (int i = 0; i <= n; i++) cout << i << " ";
  for (int i = 1; i <= n; i++)
    for (int j = 1; j < arr[i]; j++) cout << i << " ";
  cout << "\n";
  for (int i = 0; i <= n; i++) cout << i << " ";
  int prev = -1, cnt = n + 1;
  for (int i = 1; i <= n; i++) {
    if ((arr[i] > 1 && arr[i + 1] > 1)) {
      for (int j = 1; j < arr[i]; j++)
        cout << ((prev != -1) ? prev : i) << " ", cnt++;
      prev = cnt;
    } else if (arr[i] > 1) {
      for (int j = 1; j < arr[i]; j++)
        cout << ((prev != -1) ? prev : i) << " ", cnt++;
      prev = -1;
    }
  }
  cout << "\n";
  return 0;
}
