#include <bits/stdc++.h>
using namespace std;
const int INF = 2034567891;
const long long int INF64 = 4234567890123456789ll;
long long nc3(long long v) { return (v * (v - 1ll) * (v - 2ll)) / 6ll; }
long long nc2(long long v) { return (v * (v - 1ll)) / 2ll; }
long long int gcd(long long int a, long long int b) {
  return (b == 0 ? a : gcd(b, a % b));
}
long long int lcm(long long int a, long long int b) {
  return (a * (b / gcd(a, b)));
}
const int N = 10 + 2e6;
bool isprime(long long int n) {
  if (n < 2) return 0;
  if (n == 2) return 1;
  if (n % 2 == 0) return 0;
  for (long long int i = 3; i * i <= n; i++)
    if (n % i == 0) return 0;
  return 1;
}
double dist(pair<long long int, long long int> p1,
            pair<long long int, long long int> p2) {
  return (p1.first - p2.first) * (p1.first - p2.first) +
         (p1.second - p2.second) * (p1.second - p2.second);
}
int main() {
  long long int n;
  cin >> n;
  long long int a[n + 1], b[n + 1];
  long long int f = 0, idx = -1, cnt = 0;
  for (long long int i = 0; i < n + 1; i++) {
    cin >> a[i];
    if (i == 0) {
      if (a[i] > 1) cnt++;
    } else {
      if (a[i] > 1)
        cnt++;
      else
        cnt = 0;
    }
    if (cnt >= 2) {
      f = 1;
      idx = i;
    }
  }
  if (!f) {
    cout << "perfect";
    return 0;
  }
  cout << "ambiguous" << endl;
  cout << "0"
       << " ";
  vector<long long int> v;
  v.push_back(0);
  long long int par = 1;
  for (long long int i = 1; i <= n; i++) {
    if (a[i] <= 1) {
      cout << par << " ";
      v.push_back(par);
      par++;
    } else if (idx == i) {
      cout << par << " ";
      v.push_back(par - 1);
      for (long long int j = 1; j <= a[i] - 1; j++) {
        cout << par << " ";
        v.push_back(par);
      }
      par += a[i];
    } else {
      for (long long int j = 1; j <= a[i]; j++) {
        cout << par << " ";
        v.push_back(par);
      }
      par += a[i];
    }
  }
  cout << endl;
  for (long long int i = 0; i < v.size(); i++) cout << v[i] << " ";
}
