#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n, a[maxn];
struct node {
  int pre;
  bool flag;
  int other;
} num[2 * maxn];
int main(int argc, char const *argv[]) {
  while (cin >> n) {
    bool flag = true;
    for (int i = 0; i <= n; i++) {
      cin >> a[i];
      if (a[i] != 1) flag = false;
    }
    if (flag == true) {
      cout << "perfect" << endl;
      continue;
    }
    bool temp = false;
    bool ans = false;
    int cnt = 1;
    for (int i = 0; i <= n; i++) {
      if (i > 0 && a[i] > 1 && a[i - 1] > 1 && ans == false) {
        ans = true;
        int par = cnt - 1;
        int k = a[i];
        k--;
        while (k--) {
          num[cnt].pre = par;
          num[cnt].other = par - 1;
          num[cnt].flag = true;
          cnt++;
        }
        num[cnt].pre = num[cnt].other = par;
        num[cnt].flag = true;
        cnt++;
      } else {
        int par = cnt - 1;
        int k = a[i];
        while (k--) {
          num[cnt].pre = par;
          num[cnt].flag = false;
          cnt++;
        }
      }
    }
    if (ans == false) {
      cout << "perfect" << endl;
      continue;
    }
    cout << "ambiguous" << endl;
    for (int i = 1; i < cnt; i++) cout << num[i].pre << " ";
    cout << endl;
    for (int i = 1; i < cnt; i++) {
      if (num[i].flag == false)
        cout << num[i].pre;
      else
        cout << num[i].other;
      cout << " ";
    }
    cout << endl;
  }
  return 0;
}
