#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1e6;
ll n;
ll a[N];
vector<ll> id[N];
ll ptr = 0;
ll p1[N];
ll p2[N];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (ll i = 0; i <= n; ++i) {
    cin >> a[i];
    while (a[i]--) {
      id[i].push_back(++ptr);
    }
  }
  bool f = false;
  for (ll i = 0; i < n; ++i) {
    for (ll v : id[i + 1]) {
      p1[v] = id[i][0];
      p2[v] = id[i][0];
    }
    if (id[i].size() >= 2 && id[i + 1].size() >= 2) {
      f = true;
      p2[id[i + 1][0]] = id[i][1];
    }
  }
  if (!f) {
    cout << "perfect" << endl;
    return 0;
  }
  cout << "ambiguous" << endl;
  for (ll i = 1; i <= ptr; ++i) {
    cout << p1[i] << " ";
  }
  cout << "\n";
  for (ll i = 1; i <= ptr; ++i) {
    cout << p2[i] << " ";
  }
  cout << "\n";
  return 0;
}
