#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> v(n + 1);
  int sum = 0;
  for (int i = 0; i < n + 1; i += 1) {
    cin >> v[i];
    sum += v[i];
  }
  int fl = 0;
  for (int i = 1; i < n + 1; i += 1) {
    if (v[i - 1] > 1 && v[i] > 1) {
      fl = 1;
      break;
    }
  }
  if (fl == 0) {
    cout << "perfect";
    return 0;
  }
  cout << "ambiguous\n";
  vector<int> ans(1, 0);
  int cnt = 1;
  for (int i = 1; i < n + 1; i += 1) {
    int temp = v[i], nd = cnt;
    while (temp--) {
      ans.emplace_back(nd);
      cnt++;
    }
  }
  vector<int> ans2 = ans;
  int s = v[0];
  for (int i = 1; i < n + 1; i += 1) {
    if (v[i - 1] > 1 && v[i] > 1) {
      ans2[s]--;
      break;
    }
    s += v[i];
  }
  for (int x : ans) cout << x << ' ';
  cout << '\n';
  for (int x : ans2) cout << x << ' ';
}
