#include <bits/stdc++.h>

using namespace std;

int a[200006], n, arr1[200006], arr2[200006];

int main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(0);

    int sum = 0;
    cin >> n;
    for(int j = 0; j < n+1; j++){
        cin >> a[j];
        sum += a[j];
    }
    sum -= a[n];
    if(sum == n || (n == 1 && a[1] == 2)){
        cout << "perfect\n";
        return 0;
    }

    arr1[1] = arr2[1] = 0;
    int k = 2, flag = 0, par = 1, adj = 0;
    for(int j = 1; j < n+1; j++){
        int temp = k;
        for(int i = 0; i < a[j]; i++)
            arr1[k] = arr2[k] = par, k++;
        par = temp;

        if(flag == 1){
            flag = 2;
            arr2[temp] = adj;
        }
        if(a[j] > 1) flag++, adj = temp + 1;
    }

    cout << "ambiguous\n";
    for(int j = 1; j < k; j++)
        cout << arr1[j] << " ";
    cout << endl;
    for(int j = 1; j < k; j++)
        cout << arr2[j] << " ";
    cout << endl;
    return 0;
}
