#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int height;
  cin >> height;
  vector<int> edge(height + 1);
  for (int i = 0; i <= height; ++i) cin >> edge[i];
  bool perfect = true;
  for (int i = 0; i <= height; ++i) {
    if (i) {
      if (edge[i - 1] > 1 && edge[i] > 1) {
        perfect = false;
      }
    }
  }
  if (perfect) {
    cout << "perfect";
  } else {
    cout << "ambiguous\n";
    int parent = 0;
    for (int i = 0; i <= height; ++i) {
      for (int j = 0; j < edge[i]; ++j) {
        cout << parent << " ";
      }
      parent += edge[i];
    }
    cout << endl;
    bool check = false;
    parent = 0;
    for (int i = 0; i <= height; ++i) {
      for (int j = 0; j < edge[i]; ++j) {
        if (i && edge[i - 1] > 1 && edge[i] > 1 && !check) {
          cout << parent - 1 << " ";
          check = true;
        } else {
          cout << parent << " ";
        }
      }
      parent += edge[i];
      check = false;
    }
  }
  return 0;
}
