#include <bits/stdc++.h>
using namespace std;
bool amb = false;
int a[100010], pref[100010], kritican, h;
int main() {
  cin >> h;
  for (int i = 0; i <= h; i++) {
    cin >> a[i];
    if (i != 0)
      pref[i] = pref[i - 1] + a[i];
    else
      pref[i] = a[i];
  }
  for (int i = 0; i < h; i++)
    if ((a[i] > 1) && (a[i + 1] > 1)) {
      amb = true;
      kritican = i + 1;
      break;
    }
  if (!amb)
    cout << "perfect" << endl;
  else {
    cout << "ambiguous" << endl;
    cout << "0 ";
    for (int i = 1; i <= h; i++) {
      for (int j = 1; j <= a[i]; j++) cout << pref[i - 1] << " ";
    }
    cout << endl;
    cout << "0 ";
    for (int i = 1; i <= h; i++) {
      if (i != kritican)
        for (int j = 1; j <= a[i]; j++) cout << pref[i - 1] << " ";
      else {
        for (int j = 1; j < a[i]; j++) cout << pref[i - 1] << " ";
        cout << pref[i - 1] - 1 << " ";
      }
    }
  }
  return 0;
}
