#include <bits/stdc++.h>
using namespace std;
int h, a[200005];
vector<int> p1, p2;
void solve() {
  bool flag = false;
  for (int i = 0; i < h - 1; i++) {
    if (a[i] > 1 && a[i + 1] > 1) flag = true;
  }
  if (!flag) {
    puts("perfect");
  } else {
    int sum = 0;
    int mark = 0;
    p1.push_back(0);
    p2.push_back(0);
    sum++;
    for (int i = 1; i < h; i++) {
      for (int j = 0; j < a[i]; j++) {
        if (a[i - 1] > 1 && a[i] > 1 && !mark) {
          mark = 1;
          p1.push_back(sum);
          p2.push_back(sum - 1);
        } else {
          p1.push_back(sum);
          p2.push_back(sum);
        }
      }
      sum += a[i];
    }
    puts("ambiguous");
    for (int i = 0; i < p1.size(); i++) {
      cout << p1[i] << ' ';
    }
    puts("");
    for (int i = 0; i < p2.size(); i++) {
      cout << p2[i] << ' ';
    }
    puts("");
  }
}
int main() {
  cin >> h;
  h++;
  for (int i = 0; i < h; i++) {
    scanf("%d", &a[i]);
  }
  solve();
  return 0;
}
