#include <bits/stdc++.h>
using namespace std;
int h, a[200005];
vector<int> vec[200005];
int main() {
  scanf("%d", &h);
  int flag = 1;
  for (int i = 0; i <= h; i++) {
    scanf("%d", &a[i]);
    if (i != 0 && a[i] > 1 && a[i - 1] > 1) flag = 0;
  }
  if (flag)
    cout << "perfect\n";
  else {
    cout << "ambiguous\n";
    int cnt = 0;
    for (int i = 0; i <= h; i++) {
      if (i == 0) {
        cout << 0;
        cnt = 1;
        continue;
      }
      for (int j = 0; j < a[i]; j++) {
        cout << ' ';
        cout << cnt;
      }
      cnt += a[i];
    }
    cout << endl;
    cnt = 0;
    int num = 0;
    for (int i = 0; i <= h; i++) {
      if (i == 0) {
        cout << 0;
        cnt = 1;
        vec[0].push_back(1);
        num = 1;
        continue;
      }
      for (int j = 0; j < a[i]; j++) {
        cnt++;
        cout << ' ';
        cout << vec[i - 1][j % num];
        vec[i].push_back(cnt);
      }
      num = a[i];
    }
    cout << endl;
  }
  return 0;
}
