#include <bits/stdc++.h>
using namespace std;
const long long int N = 2e5 + 5;
long long int a[N], ans1[N], ans2[N];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int h;
  cin >> h;
  long long int point = -1;
  for (long long int i = 0; i <= h; i++) cin >> a[i];
  for (long long int i = 1; i <= h; i++) {
    if (a[i] >= 2 && a[i - 1] >= 2) point = i;
  }
  if (point == -1) {
    cout << "perfect";
    return 0;
  }
  cout << "ambiguous\n";
  long long int currp = 1, child = 2;
  for (long long int i = 1; i <= h; i++) {
    long long int temp = child;
    while (a[i] != 0) {
      ans1[child] = currp;
      ans2[child] = currp;
      a[i]--;
      child++;
    }
    if (i == point) {
      ans2[child - 1] = currp + 1;
    }
    currp = temp;
  }
  for (long long int i = 1; i < child; i++) cout << ans1[i] << " ";
  cout << endl;
  for (long long int i = 1; i < child; i++) cout << ans2[i] << " ";
  return 0;
}
