#include <bits/stdc++.h>
using namespace std;
int wys[100007];
vector<int> V;
vector<int> R;
int main() {
  int h;
  cin >> h;
  for (int i = 1; i <= h + 1; i++) {
    cin >> wys[i];
  }
  bool logic = 0;
  int licz = 0;
  int kto = 0;
  for (int i = 1; i <= wys[1]; i++) {
    V.push_back(kto);
    R.push_back(kto);
    licz++;
  }
  kto = licz;
  for (int i = 2; i <= h + 1; i++) {
    if (wys[i - 1] > 1 and wys[i] > 1) {
      logic = 1;
      V.push_back(kto);
      R.push_back(kto - 1);
      licz++;
      for (int j = 2; j <= wys[i]; j++) {
        V.push_back(kto);
        R.push_back(kto);
        licz++;
      }
    } else {
      for (int j = 1; j <= wys[i]; j++) {
        V.push_back(kto);
        R.push_back(kto);
        licz++;
      }
    }
    kto = licz;
  }
  if (logic == 0) {
    cout << "perfect";
    return 0;
  } else {
    cout << "ambiguous\n";
    for (int i = 0; i < V.size(); i++) {
      cout << V[i] << " ";
    }
    cout << "\n";
    for (int i = 0; i < R.size(); i++) {
      cout << R[i] << " ";
    }
  }
}
