#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  ++n;
  vector<int> level(n);
  for (int i = 0; i < n; ++i) {
    cin >> level[i];
  }
  bool perfect = true;
  vector<int> parent1, parent2;
  for (int i = 0; i < n - 1; ++i) {
    if (level[i] > 1 and level[i + 1] > 1) {
      cout << "ambiguous\n";
      int curr = 0;
      for (int j = 0; j < n; ++j) {
        if (level[j] == 1) {
          parent1.push_back(curr);
          parent2.push_back(curr++);
        } else if (level[j] > 1 and j != i) {
          for (int l = 0; l < level[j]; ++l) {
            parent1.push_back(curr);
            parent2.push_back(curr);
          }
          curr += level[j];
        } else {
          for (int l = 0; l < level[i]; ++l) {
            parent1.push_back(curr);
            parent2.push_back(curr);
          }
          for (int l = 0; l < level[i + 1]; ++l) {
            parent1.push_back(curr + 1);
          }
          parent2.push_back(curr + 1);
          for (int l = 0; l < level[i + 1] - 1; ++l) {
            parent2.push_back(curr + 2);
          }
          curr += level[i] + level[i + 1];
          ++j;
        }
      }
      for (int p : parent1) {
        cout << p << " ";
      }
      cout << endl;
      for (int p : parent2) {
        cout << p << " ";
      }
      cout << endl;
      perfect = false;
      break;
    }
  }
  if (perfect) {
    cout << "perfect\n";
  }
  return 0;
}
