#include <bits/stdc++.h>
using namespace std;
int main() {
  int j, p = 0, a[500020], i, v[500020], y1, k, h, sum = 0, v1[500020];
  cin >> h;
  h++;
  a[0] = 1;
  for (i = 1; i <= h; i++) {
    cin >> a[i];
    if (a[i] > 1) {
      if (a[i - 1] > 1) p = 2;
    }
    sum += a[i];
  }
  if (p != 2) {
    cout << "perfect";
    cin >> i;
    return 0;
  } else {
    y1 = 1;
    k = 1;
    for (i = 2; i <= h; i++) {
      for (j = 1; j <= a[i]; j++) {
        v[y1 + j] = y1;
      }
      y1 = y1 + a[i];
    }
    y1 = 1;
    p = 0;
    for (i = 2; i <= h; i++) {
      for (j = 1; j <= a[i]; j++) {
        if (a[i] > 1 && a[i - 1] > 1 && p == 0) {
          v1[y1 + 1] = y1 - 1;
          v1[y1 + 2] = y1;
          j++;
          p = 1;
        } else
          v1[y1 + j] = y1;
      }
      y1 = y1 + a[i];
    }
  }
  v[1] = 0;
  v1[1] = 0;
  cout << "ambiguous" << endl;
  for (i = 1; i <= sum; i++) cout << v[i] << " ";
  cout << endl;
  for (i = 1; i <= sum; i++) cout << v1[i] << " ";
  cin >> i;
}
