#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  n++;
  int t[n];
  bool test = true;
  cin >> t[0];
  int sum = t[0];
  for (int i = 1; i < n; i++) {
    cin >> t[i];
    sum += t[i];
    if (t[i - 1] != 1 && t[i] != 1) test = false;
  }
  if (test) {
    cout << "perfect" << endl;
    return 0;
  }
  vector<vector<int> > v;
  v.resize(n);
  int cursum = 0;
  for (int i = 0; i < n; i++) {
    if (i) cursum += t[i - 1];
    for (int j = 1; j <= t[i]; j++) v[i].push_back(cursum + j - 1);
  }
  cout << "ambiguous" << endl;
  int ans1[sum];
  int ans2[sum];
  int x = 1;
  for (int i = 0; i < n; i++) {
    if (!i)
      for (int j = 0; j < v[i].size(); j++) {
        ans1[v[i][j]] = v[i][j];
        ans2[v[i][j]] = v[i][j];
      }
    else if (t[i - 1] != 1) {
      for (int j = 0; j < v[i].size(); j++) {
        ans1[v[i][j]] = v[i - 1][x] + 1;
        ans2[v[i][j]] = v[i - 1][0] + 1;
        x = (x + 1) % 2;
      }
    } else {
      for (int j = 0; j < v[i].size(); j++) {
        ans1[v[i][j]] = v[i - 1][0] + 1;
        ans2[v[i][j]] = v[i - 1][0] + 1;
      }
    }
  }
  for (int i = 0; i < sum; i++) cout << ans1[i] << " ";
  cout << endl;
  for (int i = 0; i < sum; i++) cout << ans2[i] << " ";
  cout << endl;
  return 0;
}
