#include <bits/stdc++.h>
using namespace std;
void READ() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
}
const int N = 5 + 2e5;
int n, m;
int a[N], ma, sum, ans;
void prt(int k) {
  cout << "ambiguous" << endl;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j < a[i]; j++) {
      cout << sum << " ";
    }
    sum += a[i];
  }
  cout << endl;
  sum = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j < a[i]; j++) {
      if (i == k && j == 0)
        cout << sum - 1 << " ";
      else
        cout << sum << " ";
    }
    sum += a[i];
  }
}
int main() {
  READ();
  cin >> n;
  for (int i = 0; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    if (a[i - 1] != 1 && a[i] != 1) {
      prt(i);
      return 0;
    }
  }
  cout << "perfect";
  return 0;
}
