#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
const long long xx = 2e5;
vector<long long> g1[xx + 10];
vector<long long> g2[xx + 10];
long long v[xx + 10];
long long p1[xx], p2[xx];
void make_first(long long h) {
  long long node = 1;
  p1[1] = 0;
  for (long long i = 1; i < h + 1; i++) {
    if (v[i - 1] == 1) {
      long long root = node;
      for (long long j = 0; j < v[i]; j++) {
        ++node;
        p1[node] = root;
      }
    } else {
      long long r2 = node;
      long long r1 = node - 1;
      ++node;
      p1[node] = r1;
      for (long long j = 0; j < v[i] - 1; j++) {
        ++node;
        p1[node] = r2;
      }
    }
  }
}
long long mx_node = 0;
void make_second(long long h) {
  long long node = 1;
  for (long long i = 1; i < h + 1; i++) {
    long long root = node;
    for (long long j = 0; j < v[i]; j++) {
      ++node;
      p2[node] = root;
      mx_node = max(mx_node, node);
    }
  }
}
void dfs1(long long r, long long p) {
  for (auto i : g2[r]) {
    if (i != p) {
      p1[i] = r;
      dfs1(i, r);
    }
  }
}
void dfs2(long long r, long long p) {
  for (auto i : g1[r]) {
    if (i != p) {
      p2[i] = r;
      dfs2(i, r);
    }
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long h;
  cin >> h;
  for (long long i = 0; i < h + 1; i++) {
    cin >> v[i];
  }
  bool per = true;
  if (h >= 2) {
    for (long long i = 2; i < h + 1; i++) {
      if (v[i] > 1 && v[i - 1] > 1) {
        per = false;
        break;
      }
    }
  }
  if (per) {
    cout << "perfect" << '\n';
    return 0;
  }
  make_first(h);
  make_second(h);
  cout << "ambiguous" << '\n';
  for (long long i = 1; i <= mx_node; i++) cout << p1[i] << " ";
  cout << '\n';
  for (long long i = 1; i <= mx_node; i++) cout << p2[i] << " ";
  cout << '\n';
}
