#include <bits/stdc++.h>
using namespace std;
const int NMAX = 500 + 8, INF = 1e9 + 7, MOD = 1e9 + 7, CMAX = 'z' - 'a' + 1;
const long long LINF = 1e18;
const double EPS = 1e-7;
int main() {
  ios::sync_with_stdio(0);
  int h;
  cin >> h;
  ++h;
  vector<int> arr(h);
  for (int i = 0; i < h; ++i) {
    cin >> arr[i];
  }
  bool is = 0;
  for (int i = 0; i < h; ++i) {
    if (is && arr[i] > 1) {
      cout << "ambiguous\n";
      int last = 0, c = 0;
      for (int j = 0; j < h; ++j) {
        int f = 0;
        for (int k = 0; k < arr[j]; ++k) {
          cout << last << ' ';
          ++c;
          if (k == 0) {
            f = c;
          }
        }
        last = f;
      }
      cout << '\n';
      c = 0, last = 0;
      int last2 = 0;
      for (int j = 0; j < h; ++j) {
        int f = 0, s = 0;
        for (int k = 0; k < arr[j]; ++k) {
          if (j == i && k == arr[j] - 1) {
            cout << last2 << ' ';
          } else {
            cout << last << ' ';
          }
          ++c;
          if (k == 0) {
            f = c;
          } else if (k == 1) {
            s = c;
          }
        }
        last = f;
        last2 = s;
      }
      return 0;
    }
    if (arr[i] > 1) {
      is = 1;
    } else {
      is = 0;
    }
  }
  cout << "perfect";
}
