#include <bits/stdc++.h>
using namespace std;
int n;
int a[200004]{0}, tmp[200004]{0};
void ambi(int h) {
  int j = 0, nhere = 0, jhere = 0, nhere2 = 0;
  for (int i = 0; i < n; i++) {
    int k = a[i];
    if (i == h + 1) jhere = j, nhere2 = nhere;
    while (k--) cout << j << " ", tmp[nhere++] = j;
    j += a[i];
  }
  cout << "\n";
  tmp[nhere2] = jhere - 1;
  for (int i = 0; i < nhere; i++) cout << tmp[i] << " ";
  cout << '\n';
}
int main() {
  cin >> n;
  n += 1;
  for (int i = 0, v; i < n && cin >> v; i++) {
    a[i] = v;
  }
  for (int i = 0; i < n - 1; i++) {
    if (a[i] > 1 && a[i + 1] > 1) {
      cout << "ambiguous\n";
      ambi(i);
      return 0;
    }
  }
  cout << "perfect\n";
  return 0;
}
