#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, a[N], ans[N], cnt, x, y;
bool Ok = 0;
int main() {
  cin >> n;
  for (int i = 0; i <= n; i++) {
    cin >> a[i];
    if (i) Ok |= (a[i] > 1 && a[i - 1] > 1);
  }
  if (!Ok) {
    cout << "perfect";
  } else {
    cout << "ambiguous" << endl;
    cnt = 1;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= a[i]; j++) {
        ans[cnt + j] = cnt;
      }
      if (a[i] > 1 && a[i - 1] > 1) {
        x = cnt + a[i];
        y = cnt - 1;
      }
      cnt += a[i];
    }
    for (int i = 1; i <= cnt; i++) {
      cout << ans[i] << " ";
    }
    cout << endl;
    ans[x] = y;
    for (int j = 1; j <= cnt; j++) {
      cout << ans[j] << " ";
    }
  }
  return 0;
}
