#include <bits/stdc++.h>
using namespace std;
constexpr int MAXH = 100000 + 10;
int a[MAXH];
int h;
int main() {
  cin >> h;
  for (int i = 0; i <= h; ++i) cin >> a[i];
  int xh = -1;
  for (int i = 1; i <= h; ++i) {
    if (a[i] != 1 && a[i - 1] != 1) {
      xh = i;
      break;
    }
  }
  if (xh == -1) {
    cout << "perfect" << endl;
    return 0;
  }
  cout << "ambiguous" << endl;
  int pre = 0;
  for (int i = 0; i <= h; ++i) {
    for (int j = 0; j < a[i]; ++j) cout << pre << ' ';
    pre += a[i];
  }
  cout << endl;
  pre = 0;
  for (int i = 0; i < xh; ++i) {
    for (int j = 0; j < a[i]; ++j) cout << pre << ' ';
    pre += a[i];
  }
  const int ct = a[xh];
  for (int j = 0; j < ct / 2; ++j) cout << pre - 1 << ' ';
  for (int j = ct / 2; j < ct; ++j) cout << pre << ' ';
  pre += ct;
  for (int i = xh + 1; i <= h; ++i) {
    for (int j = 0; j < a[i]; ++j) cout << pre << ' ';
    pre += a[i];
  }
  cout << endl;
}
