#include <bits/stdc++.h>
using namespace std;
const int max_h = (2e5) + 5;
int h;
int a[max_h + 1];
int r, p;
int main() {
  cin >> h;
  p = h + 1;
  for (int i = 0; i <= h; ++i) {
    cin >> a[i];
    if (i > 0 and p > h) {
      if (a[i] > 1 and a[i - 1] > 1) {
        p = i;
        cout << "ambiguous\n";
      }
    }
  }
  if (p > h) {
    cout << "perfect\n";
    return 0;
  }
  r = 1;
  cout << "0 ";
  for (int i = 1; i <= h; ++i) {
    if (i == p) {
      cout << r + 1 << " ";
      for (int j = 1; j < a[i]; ++j) cout << r << " ";
    } else {
      for (int j = 0; j < a[i]; ++j) cout << r << " ";
    }
    r += a[i - 1];
  }
  cout << endl;
  r = 1;
  cout << "0 ";
  for (int i = 1; i <= h; ++i) {
    for (int j = 0; j < a[i]; ++j) cout << r << " ";
    r += a[i - 1];
  }
  cout << endl;
  return 0;
}
