#include <bits/stdc++.h>   using namespace std;   long long int pwr(long long int base, long long int p, long long int mod) {     long long int ans = 1;     while (p) {       if (p & 1) ans = (ans * base) % mod;       base = (base * base) % mod;       p /= 2;     }     return ans;   }   long long int gcd(long long int a, long long int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int main() {     int n;     scanf( %d , &n);     int a[n + 1];     int par[300005];     int cnt = 0;     int lvl = 0, flag = 0, p = -1;     vector<int> g[n + 2];     for (int i = 0; i <= n; i++) {       scanf( %d , &a[i]);       for (int j = 1; j <= a[i]; j++) {         g[i].push_back(++cnt);         par[cnt] = lvl;       }       lvl = cnt;       if (i >= 1) {         if (a[i] > 1 && a[i - 1] > 1) flag = i;       }     }     if (flag == 0) {       printf( perfect n );       return 0;     }     printf( ambiguous n );     for (int i = 1; i <= cnt; i++) {       printf( %d  , par[i]);     }     printf(  n );     par[g[flag][0]] = g[flag - 1][0];     for (int i = 1; i <= cnt; i++) {       printf( %d  , par[i]);     }     return 0;   }   