#include <bits/stdc++.h>
using namespace std;
int n, h;
int height[200001];
int main() {
  cin >> h;
  for (int i = 0; i <= h; i++) {
    cin >> height[i];
    n += height[i];
  }
  bool flag = true;
  int chk = 0;
  for (int i = 1; i <= h; i++) {
    if (height[i - 1] > 1 && height[i] > 1) {
      flag = false;
      chk = i;
      break;
    }
  }
  if (flag)
    cout << "perfect" << endl;
  else {
    cout << "ambiguous" << endl;
    int root = 0;
    int start = 1;
    for (int i = 0; i <= h; i++) {
      for (int j = 0; j < height[i]; j++) {
        cout << root << ' ';
      }
      root += height[i];
    }
    cout << endl;
    root = 0;
    start = 1;
    for (int i = 0; i <= h; i++) {
      for (int j = 0; j < height[i]; j++) {
        if (i == chk && j == (height[i] - 1)) {
          cout << root - 1 << ' ';
        } else {
          cout << root << ' ';
        }
      }
      root += height[i];
    }
    cout << endl;
  }
}
