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