#include <bits/stdc++.h>
using namespace std;
unordered_map<long long, long long> kval, degree;
bool isPerfect(int a[], int n) {
  for (int i = 0; i < n - 1; i++) {
    if (a[i] != 1 && a[i + 1] != 1) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int h;
  cin >> h;
  int a[200005];
  for (int i = 0; i <= h; i++) {
    cin >> a[i];
  }
  if (isPerfect(a, h + 1)) {
    cout << "perfect" << endl;
  } else {
    cout << "ambiguous" << endl;
    map<int, vector<int> > m;
    int k = 1;
    for (int i = 0; i <= h; i++) {
      for (int j = 0; j < a[i]; j++) {
        m[i].push_back(k);
        k++;
      }
    }
    cout << 0 << " ";
    for (int i = 1; i <= h; i++) {
      int sz = m[i].size();
      for (int j = 0; j < sz; j++) {
        cout << m[i - 1][0] << " ";
      }
    }
    cout << endl;
    cout << 0 << " ";
    for (int i = 1; i <= h; i++) {
      int sz = m[i].size();
      for (int j = 0; j < sz; j++) {
        if (m[i - 1].size() > 1) {
          if (j & 1)
            cout << m[i - 1][1] << " ";
          else
            cout << m[i - 1][0] << " ";
        } else
          cout << m[i - 1][0] << " ";
      }
    }
    cout << endl;
  }
}
