#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;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IGFbMjAwMDA2XSwgbiwgYXJyMVsyMDAwMDZdLCBhcnIyWzIwMDAwNl07CgppbnQgbWFpbigpewogICAgaW9zX2Jhc2UgOjogc3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgIGNpbi50aWUoMCk7CgogICAgaW50IHN1bSA9IDA7CiAgICBjaW4gPj4gbjsKICAgIGZvcihpbnQgaiA9IDA7IGogPCBuKzE7IGorKyl7CiAgICAgICAgY2luID4+IGFbal07CiAgICAgICAgc3VtICs9IGFbal07CiAgICB9CiAgICBzdW0gLT0gYVtuXTsKICAgIGlmKHN1bSA9PSBuIHx8IChuID09IDEgJiYgYVsxXSA9PSAyKSl7CiAgICAgICAgY291dCA8PCAicGVyZmVjdFxuIjsKICAgICAgICByZXR1cm4gMDsKICAgIH0KCiAgICBhcnIxWzFdID0gYXJyMlsxXSA9IDA7CiAgICBpbnQgayA9IDIsIGZsYWcgPSAwLCBwYXIgPSAxLCBhZGogPSAwOwogICAgZm9yKGludCBqID0gMTsgaiA8IG4rMTsgaisrKXsKICAgICAgICBpbnQgdGVtcCA9IGs7CiAgICAgICAgZm9yKGludCBpID0gMDsgaSA8IGFbal07IGkrKykKICAgICAgICAgICAgYXJyMVtrXSA9IGFycjJba10gPSBwYXIsIGsrKzsKICAgICAgICBwYXIgPSB0ZW1wOwoKICAgICAgICBpZihmbGFnID09IDEpewogICAgICAgICAgICBmbGFnID0gMjsKICAgICAgICAgICAgYXJyMlt0ZW1wXSA9IGFkajsKICAgICAgICB9CiAgICAgICAgaWYoYVtqXSA+IDEpIGZsYWcrKywgYWRqID0gdGVtcCArIDE7CiAgICB9CgogICAgY291dCA8PCAiYW1iaWd1b3VzXG4iOwogICAgZm9yKGludCBqID0gMTsgaiA8IGs7IGorKykKICAgICAgICBjb3V0IDw8IGFycjFbal0gPDwgIiAiOwogICAgY291dCA8PCBlbmRsOwogICAgZm9yKGludCBqID0gMTsgaiA8IGs7IGorKykKICAgICAgICBjb3V0IDw8IGFycjJbal0gPDwgIiAiOwogICAgY291dCA8PCBlbmRsOwogICAgcmV0dXJuIDA7Cn0K