#include <bits/stdc++.h>
using namespace std;
vector<int> ans1, ans2;
int main() {
  int n;
  cin >> n;
  int p1 = 0, p2 = 0;
  bool f = 0;
  int c = 0;
  for (int i = 0; i <= n; i++) {
    int k;
    cin >> k;
    int pp = c + 1;
    for (int j = 0; j < k; j++) {
      ans1.push_back(p1);
      ans2.push_back(p1);
      c++;
    }
    if (!f && k > 1 && p1 != p2) {
      ans2[c - 1] = p2;
      f = 1;
    }
    p1 = pp;
    p2 = c;
  }
  if (!f) {
    cout << "perfect";
  } else {
    cout << "ambiguous\n";
    for (auto i : ans1) {
      cout << i << ' ';
    }
    cout << '\n';
    for (auto i : ans2) {
      cout << i << ' ';
    }
  }
}
