#include <bits/stdc++.h>
using namespace std;
int main() {
  int h;
  scanf("%d", &(h));
  vector<int> tab(h + 1);
  for (int i = (0); i < (h + 1); i++) scanf("%d", &(tab[i]));
  bool perfect = true;
  int diffindex;
  for (int i = (1); i < (h); i++) {
    if (tab[i] > 1 && tab[i + 1] > 1) {
      diffindex = i + 1;
      puts("ambiguous");
      perfect = false;
      break;
    }
  }
  if (perfect) {
    puts("perfect");
    return 0;
  }
  int vertexam = 0;
  for (int i = (0); i < (h + 1); i++) vertexam += tab[i];
  vector<int> p1(vertexam + 1), p2(vertexam + 1), depth(vertexam + 1);
  p1[1] = 0;
  p2[1] = 0;
  int cur = 2;
  int last = 1;
  for (int i = (1); i < (h + 1); i++) {
    for (int j = (0); j < (tab[i]); j++) {
      depth[cur] = i;
      p1[cur] = last;
      cur++;
    }
    last = cur - 1;
  }
  cur = 2;
  pair<int, int> twolast;
  last = 1;
  for (int i = (1); i < (h + 1); i++) {
    for (int j = (0); j < (tab[i]); j++) {
      if (i == diffindex) {
        p2[cur++] = last;
        p2[cur++] = last - 1;
        for (int k = (2); k < (tab[i]); k++) {
          p2[cur] = last;
          cur++;
        }
        break;
      } else {
        p2[cur] = last;
        cur++;
      }
    }
    last = cur - 1;
  }
  for (int i = (0); i < (vertexam); i++) printf("%d ", p1[i + 1]);
  cout << endl;
  for (int i = (0); i < (vertexam); i++) printf("%d ", p2[i + 1]);
  cout << endl;
  return 0;
}
