#include <bits/stdc++.h>
using namespace std;
int many;
int t[100010];
int s = -1;
bool flag;
int A;
int now;
int x[200010];
int y[200010];
int main() {
  cin >> many;
  for (int i = 0; i <= many; i++) cin >> t[i];
  for (int i = 1; i <= many; i++) {
    if (t[i] > 1 && flag) s = i;
    if (t[i] > 1)
      flag = true;
    else
      flag = false;
  }
  if (s == -1) {
    cout << "perfect";
    return 0;
  }
  cout << "ambiguous" << endl;
  for (int i = 0; i <= many; i++) {
    if (i == s) {
      A++;
      x[A] = now - 1;
      y[A] = now;
    } else {
      A++;
      x[A] = now;
      y[A] = now;
    }
    for (int j = 2; j <= t[i]; j++) {
      A++;
      x[A] = now;
      y[A] = now;
    }
    now += t[i];
  }
  for (int i = 1; i <= A; i++) cout << x[i] << " ";
  cout << endl;
  for (int i = 1; i <= A; i++) cout << y[i] << " ";
  return 0;
}
