#include <bits/stdc++.h>
inline void _RD(int &x) { scanf("%d", &x); }
inline void _RD(long long &x) { scanf("%lld", &x); }
inline void _RD(double &x) { scanf("%lf", &x); }
inline void _RD(long double &x) { scanf("%Lf", &x); }
inline void _RD(char &x) { scanf(" %c", &x); }
inline void RD() {}
template <class T, class... U>
inline void RD(T &head, U &...tail) {
  _RD(head);
  RD(tail...);
}
using namespace std;
using LL = long long;
using VI = vector<int>;
using VLL = vector<LL>;
using VVI = vector<VI>;
int main() {
  int h, j;
  RD(h);
  VI a(h + 1);
  for (int i = (0); i <= (h); ++i) {
    RD(j);
    a[i] = j;
  }
  VI s = {0}, t = s;
  int l = 1, r = 1;
  for (int i = (1); i <= (h); ++i) {
    int now = l;
    for (int j = (r + 1); j <= (r + a[i]); ++j) {
      s.push_back(now);
      if (++now > r) now = l;
      t.push_back(l);
    }
    l = r + 1;
    r += a[i];
  }
  if (s == t)
    printf("perfect\n");
  else {
    printf("ambiguous\n");
    for (auto x : (s)) printf("%d ", x);
    printf("\n");
    for (auto x : (t)) printf("%d ", x);
    printf("\n");
  }
  return 0;
}
