#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  n++;
  vector<int> a(n);
  int m = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    m += a[i];
  }
  vector<int> g1, g2, p;
  p.push_back(0);
  int node = 1;
  bool found = false;
  for (int i = 0; i < n; i++) {
    vector<int> foo;
    if ((int)p.size() == 1) {
      for (int j = 0; j < a[i]; j++) {
        g1.push_back(p[0]);
        g2.push_back(p[0]);
        foo.push_back(node++);
      }
    } else {
      if (a[i] == 1) {
        g1.push_back(p[0]);
        g2.push_back(p[0]);
        foo.push_back(node++);
      } else {
        found = true;
        for (int j = 0; j < a[i]; j++) {
          g1.push_back(p[0]);
          foo.push_back(node++);
        }
        for (int j = 0; j < a[i] - 1; j++) {
          g2.push_back(p[0]);
        }
        g2.push_back(p[1]);
      }
    }
    p = foo;
  }
  if (found) {
    cout << "ambiguous" << '\n';
    for (int i = 0; i < (int)g1.size(); i++) {
      cout << g1[i] << " ";
    }
    cout << '\n';
    for (int i = 0; i < (int)g2.size(); i++) {
      cout << g2[i] << " ";
    }
    cout << '\n';
  } else {
    cout << "perfect" << '\n';
  }
  return 0;
}
