#include <bits/stdc++.h>
using namespace std;
long long n, h, a[211111], s;
int main() {
  cin >> h;
  for (long long i = 0; i <= h; i++) scanf("%lld", &a[i]), n += a[i];
  long long ch = 0;
  for (long long i = 1; i <= h; i++)
    if (a[i] > 1 && a[i - 1] > 1) ch++;
  if (ch == 0) {
    cout << "perfect";
    return 0;
  }
  cout << "ambiguous\n";
  for (long long i = 0; i <= h; i++) {
    for (long long j = 1; j <= a[i]; j++) printf("%lld ", s);
    s += a[i];
  }
  cout << endl;
  s = 0;
  for (long long i = 0; i <= h; i++) {
    for (long long j = 1; j <= a[i]; j++) {
      if (i > 0 && a[i - 1] > 1)
        printf("%lld ", s - (j & 1));
      else
        printf("%lld ", s);
    }
    s += a[i];
  }
}
