#include <bits/stdc++.h>
using namespace std;
bool ok;
int h;
int lays[1000005];
int first[1000005];
int second[1000005];
int main() {
  cin >> h;
  for (int i = 0; i <= h; i++) {
    cin >> lays[i];
    if (i > 1 && lays[i] > 1 && lays[i - 1] > 1) {
      ok = true;
    }
  }
  if (ok == false) {
    cout << "perfect";
    return 0;
  }
  int root = 1;
  for (int i = 1; i <= h; i++) {
    for (int j = root + 1; j <= root + lays[i]; j++) {
      first[j] = root;
    }
    root += lays[i];
  }
  root = 1;
  for (int i = 1; i <= h; i++) {
    if (lays[i] == 1 || lays[i - 1] == 1) {
      for (int j = root + 1; j <= root + lays[i]; j++) {
        second[j] = root;
      }
      root += lays[i];
    } else {
      second[root + 1] = root - 1;
      for (int j = root + 2; j <= root + lays[i]; j++) second[j] = root;
      root += lays[i];
    }
  }
  cout << "ambiguous\n";
  for (int i = 1; i <= root; i++) {
    cout << first[i] << " ";
  }
  cout << endl;
  for (int i = 1; i <= root; i++) {
    cout << second[i] << " ";
  }
  return 0;
}
