#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int h;
  cin >> h;
  int a[h + 1];
  bool good = true;
  int s = 0;
  cin >> a[0];
  for (int i = 1; i < h + 1; ++i) {
    cin >> a[i];
    s += a[i];
    if (a[i] != 1 && a[i - 1] != 1) {
      good = false;
    }
  }
  if (good) {
    cout << "perfect";
    return 0;
  }
  cout << "ambiguous" << endl;
  int p = 0;
  for (int i = 0; i < h + 1; ++i) {
    for (int j = 0; j < a[i]; ++j) {
      cout << p << " ";
    }
    p += a[i];
  }
  cout << endl;
  p = 1;
  int done = 0;
  int m;
  cout << 0 << " ";
  for (int i = 1; i < h + 1; ++i) {
    if (a[i] > 1 && a[i - 1] > 1 && done == 0) {
      ++done;
    }
    for (int j = 0; j < a[i]; ++j) {
      if (done != 1) {
        cout << p << " ";
      } else {
        cout << p - a[i - 1] + 1 << " ";
        ++done;
      }
    }
    p += a[i];
  }
}
