#include <bits/stdc++.h>
using namespace std;
const double pi = 3.141592653589793238463;
int a[100009], p[200009];
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  int h;
  cin >> h;
  for (int i = (0); i <= (h); i++) cin >> a[i];
  bool perfect = true;
  for (int i = 0; i < (h); i++)
    if (a[i] > 1 && a[i + 1] > 1) perfect = false;
  if (perfect) {
    cout << "perfect" << '\n';
    return 0;
  }
  cout << "ambiguous" << '\n';
  int idx = 1;
  p[0] = 0;
  for (int i = (0); i <= (h); i++) {
    p[i + 1] = idx;
    for (int j = (0); j < (a[i]); j++) cout << p[i] << " ";
    idx += a[i];
  }
  cout << '\n';
  idx = 1;
  p[0] = 0;
  for (int i = (0); i <= (h); i++) {
    p[i + 1] = idx;
    if (i > 0 && a[i] > 1 && a[i - 1] > 1) {
      cout << p[i] << " ";
      for (int j = (0); j < (a[i] - 1); j++) cout << p[i] + 1 << " ";
    } else
      for (int j = (0); j < (a[i]); j++) cout << p[i] << " ";
    idx += a[i];
  }
  cout << '\n';
  return 0;
}
