#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int h, n, a[N];
vector<int> gen(int mod) {
  int sz = 0;
  vector<int> pre = {-1}, npre, ans(n);
  for (int l = 0; l < (int)(h + 1); l++) {
    npre.clear();
    for (int _ = 0; _ < (int)(a[l]); _++) {
      if (((int)(pre).size()) >= mod)
        ans[sz] = pre[sz % mod];
      else
        ans[sz] = pre[0];
      npre.push_back(sz++);
    }
    pre = npre;
  }
  return ans;
}
void print(const vector<int> &a) {
  for (auto x : a) cout << x + 1 << ' ';
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> h;
  bool big = 0, ok = 0;
  for (int i = 0; i < (int)(h + 1); i++) {
    cin >> a[i];
    n += a[i];
    ok |= a[i] > 1 && big;
    big = a[i] > 1;
  }
  if (ok) {
    cout << "ambiguous" << endl;
    print(gen(1));
    print(gen(2));
  } else
    cout << "perfect" << endl;
  return 0;
}
