#include <bits/stdc++.h>
using namespace std;
int h, p[200009], l2[200009], l[200009], k = 1, a[200009], c = 0;
int main() {
  cin >> h;
  for (int i = 0; i <= h; i++) {
    cin >> a[i];
    if (i == 0) {
      l[0] = 1;
      k++;
      p[1] = 0;
      continue;
    }
    if (a[i] > 1 && a[i - 1] > 1) {
      c++;
    }
    for (int j = 0; j < a[i]; k++, j++) {
      if (j == 0)
        l[i] = k;
      else if (j == 1)
        l2[i] = k;
      p[k] = l[i - 1];
    }
  }
  if (c == 0)
    cout << "perfect\n";
  else
    cout << "ambiguous\n";
  if (c != 0)
    for (int i = 1; i < k; i++) cout << p[i] << " ";
  cout << "\n";
  if (c != 0) {
    k = 2;
    for (int i = 0; i <= h; i++) {
      if (i == 0) {
        l[i] = l2[i] = 1;
        p[1] = 0;
        continue;
      }
      for (int j = 0; j < a[i]; j++, k++) {
        if (j % 2 == 0)
          p[k] = l[i - 1];
        else
          p[k] = l2[i - 1];
        if (j == 0)
          l[i] = k;
        else
          l2[i] = k;
      }
      if (a[i] == 1) l2[i] = l[i];
    }
    for (int i = 1; i < k; i++) cout << p[i] << " ";
  }
  return 0;
}
