#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 17;
int n, a[maxn];
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  int cer = -1;
  for (int i = 0; i < n + 1; i++) {
    cin >> a[i];
    if (i && a[i] > 1 && a[i - 1] > 1) cer = i - 1;
  }
  if (cer == -1) return cout << "perfect\n", 0;
  cout << "ambiguous" << '\n';
  int k = 0;
  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < a[i]; j++) cout << k << ' ';
    k += a[i];
  }
  cout << '\n';
  k = 0;
  for (int i = 0; i < n + 1; i++) {
    k += a[i];
    for (int j = 0; j < a[i]; j++)
      if (i == cer + 1 && j == 1)
        cout << k - a[i] - 1 << ' ';
      else
        cout << k - a[i] << ' ';
  }
  cout << '\n';
}
