#include <bits/stdc++.h>
using namespace std;
int n, a[200005], m[200005], i = 0;
int main() {
  cin >> n;
  while (i <= n) cin >> a[i++];
  for (i = 0; i < n; i++)
    if (a[i] > 1 && a[i + 1] > 1) {
      cout << "ambiguous\n";
      int l = 0, k = 0, t;
      for (int j = 0; j <= n; j++) {
        while (a[j]--) m[k++] = l;
        l = k;
        if (j == i) t = k;
      }
      l = 2;
      while (l--) {
        for (int j = 0; j < k; j++)
          cout << ((j) ? " " : "") << ((j == t && l) ? m[j] - 1 : m[j]);
        cout << "\n";
      }
      return 0;
    }
  cout << "perfect\n";
}
