#include <bits/stdc++.h>
using namespace std;
const long double PI =
    3.14159265358979323846264338327950288419716939937510582097494459230;
const long long MOD = 1000000007LL;
const long long INF = 1e9;
const long long LINF = 1e18;
const long double EPS = 1e-9;
const long double GOLD = ((1 + sqrt(5)) / 2);
template <class T>
int getbit(T s, int i) {
  return (s >> 1) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcount(s);
}
long long h, nodeCount = 0;
vector<long long> a, firstNode;
void VarInput() {
  cin >> h;
  a.resize(h + 1);
  firstNode.resize(h + 1);
  for (long long i = 0; i <= h; i++) {
    cin >> a[i];
    nodeCount += a[i];
  }
  firstNode[0] = 1;
}
void ProSolve() {
  for (long long x = 1; x <= h; x++) {
    if (a[x] > 1 && a[x - 1] > 1) {
      cout << "ambiguous\n";
      for (long long i = 1; i <= h; i++) {
        firstNode[i] = firstNode[i - 1] + a[i - 1];
      }
      long long level = 0;
      for (long long i = 1; i <= nodeCount; i++) {
        if (i == 1)
          cout << "0";
        else
          cout << " " << firstNode[level - 1];
        if (i == firstNode[level + 1] - 1) level++;
      }
      cout << '\n';
      level = 0;
      for (long long i = 1; i <= nodeCount; i++) {
        if (i == 1)
          cout << "0";
        else if (i == firstNode[x] + 1)
          cout << " " << firstNode[x - 1] + 1;
        else
          cout << " " << firstNode[level - 1];
        if (i == firstNode[level + 1] - 1) level++;
      }
      return;
    }
  }
  cout << "perfect";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  VarInput();
  ProSolve();
  return 0;
}
