#include <bits/stdc++.h>
using namespace std;
int co[10005];
bool vis[10005];
int cnt = 0;
vector<int> graph[10005];
void dfs(int i, int c) {
  vis[i] = 1;
  if (co[i] != c) cnt++;
  for (auto j : graph[i]) {
    if (!vis[j]) dfs(j, co[i]);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, in;
  cin >> n;
  vector<int> h(n + 1);
  for (int i = 0; i < n + 1; i++) cin >> h[i];
  int f = 1;
  for (int i = 0; i < n + 1; i++) {
    if (h[i] != 1) {
      if (h[i - 1] != 1) {
        f = 0;
        in = i;
      }
    }
  }
  if (f)
    cout << "perfect";
  else {
    cout << "ambiguous\n";
    int a = 0, b = 0;
    for (int i = 0; i < n + 1; i++) {
      for (int j = 0; j < h[i]; j++) {
        cout << a << " ";
        b++;
      }
      a += b;
      b = 0;
    }
    cout << endl;
    a = 0;
    for (int i = 0; i < n + 1; i++) {
      for (int j = 0; j < h[i]; j++) {
        int c = 0;
        if (i == in && j == 1) c = 1;
        cout << a - c << " ";
        b++;
      }
      a += b;
      b = 0;
    }
  }
  return 0;
}
