#include <bits/stdc++.h>
using namespace std;
struct fastIO {
  fastIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  }
};
const int MAXN = 1e6 + 10;
vector<int> ans1, ans2;
int n, a[MAXN], ans, c;
int main() {
  fastIO();
  cin >> n;
  cin >> a[0];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] > 1 && a[i - 1] > 1) ans = i;
  }
  if (ans == 0) {
    cout << "perfect";
    return 0;
  }
  cout << "ambiguous\n0 ";
  c = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < a[i]; j++) {
      cout << c << ' ';
    }
    c += a[i];
  }
  c = 1;
  cout << "\n0 ";
  for (int i = 1; i <= n; i++) {
    if (ans == i) {
      cout << c - 1 << ' ';
      for (int j = 1; j < a[i]; j++) {
        cout << c << ' ';
      }
      c += a[i];
    } else {
      for (int j = 0; j < a[i]; j++) {
        cout << c << ' ';
      }
      c += a[i];
    }
  }
  return 0;
}
