#include <bits/stdc++.h>
using namespace std;
int main() {
  int h;
  cin >> h;
  int a[h + 1], kelintas;
  bool perfect = true;
  cin >> a[0];
  for (int i = 1; i <= h; i++) {
    cin >> a[i];
    if (a[i] > 1 && a[i - 1] > 1) {
      perfect = false;
      kelintas = i;
    }
  }
  if (perfect)
    cout << "perfect";
  else {
    int numeris = 1;
    cout << "ambiguous" << endl;
    cout << "0 ";
    for (int i = 1; i <= h; i++) {
      for (int k = 0; k < a[i]; k++) cout << numeris << " ";
      numeris += a[i];
    }
    cout << endl;
    numeris = 1;
    cout << "0 ";
    for (int i = 1; i <= h; i++) {
      if (i == kelintas)
        cout << numeris - 1 << " ";
      else
        cout << numeris << " ";
      for (int k = 1; k < a[i]; k++) cout << numeris << " ";
      numeris += a[i];
    }
  }
  return 0;
}
