Problem: Sasha is taking part in a programming competition. In one of the problems she should check if some rooted trees are isomorphic or not. She has never seen this problem before, but, being an experienced participant, she guessed that she should match trees to some sequences and then compare these sequences instead of trees. Sasha wants to match each tree with a sequence a0, a1, ..., ah, where h is the height of the tree, and ai equals to the number of vertices that are at distance of i edges from root. 

Unfortunately, this time Sasha's intuition was wrong, and there could be several trees matching the same sequence. To show it, you need to write a program that, given the sequence ai, builds two non-isomorphic rooted trees that match that sequence, or determines that there is only one such tree.

Two rooted trees are isomorphic, if you can reenumerate the vertices of the first one in such a way, that the index of the root becomes equal the index of the root of the second tree, and these two trees become equal.

The height of a rooted tree is the maximum number of edges on a path from the root to any other vertex.

Input

The first line contains a single integer h (2 ≤ h ≤ 105) — the height of the tree.

The second line contains h + 1 integers — the sequence a0, a1, ..., ah (1 ≤ ai ≤ 2·105). The sum of all ai does not exceed 2·105. It is guaranteed that there is at least one tree matching this sequence.

Output

If there is only one tree matching this sequence, print "perfect".

Otherwise print "ambiguous" in the first line. In the second and in the third line print descriptions of two trees in the following format: in one line print <image> integers, the k-th of them should be the parent of vertex k or be equal to zero, if the k-th vertex is the root.

These treese should be non-isomorphic and should match the given sequence.

Examples

Input

2
1 1 1


Output

perfect


Input

2
1 2 2


Output

ambiguous
0 1 1 3 3
0 1 1 3 2

Note

The only tree in the first example and the two printed trees from the second example are shown on the picture:

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const long long int maxn = 1e5 + 6;
const long long int MOD = 1e9 + 7;
vector<int> prim(1000005, 1);
int fact[maxn];
long long int binomialCoeff(long long int n, long long int k) {
  long long int res = 1;
  if (k > n - k) k = n - k;
  for (long long int i = 0; i < k; ++i) {
    res *= (n - i);
    res /= (i + 1);
  }
  return res;
}
bool isVowel(char ch) {
  if (ch == 'a' || ch == 'i' || ch == 'e' || ch == 'u' || ch == 'o') {
    return true;
  }
  return false;
}
long long int power(long long int x, long long int i, long long int mod) {
  long long int ans = 1;
  while (i > 0) {
    if (i & 1) ans = (ans * x) % mod;
    i >>= 1;
    x = (x * x) % mod;
  }
  return ans;
}
long long int modInverse(long long int x, long long int mod) {
  return power(x, mod - 2, mod);
}
int nCr(int n, int r) {
  if (n < r) {
    return 0;
  }
  return (((fact[n] * modInverse(fact[n - r], MOD)) % MOD) *
          modInverse(fact[r], MOD)) %
         MOD;
}
long long int power(int x, unsigned int y) {
  long long int temp;
  if (y == 0) return 1;
  temp = power(x, y / 2);
  if (y % 2 == 0)
    return temp * temp;
  else
    return x * temp * temp;
}
void erath(int n) {
  prim[1] = 0;
  prim[0] = 0;
  prim[2] = 1;
  for (int i = 2; i * i <= n; i++) {
    if (prim[i]) {
      for (int j = i * i; j <= n; j += i) {
        prim[j] = 0;
      }
    }
  }
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return (a / gcd(a, b)) * b;
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
long long int n, m, k;
int getmid(int l, int r) { return (l + (r - l) / 2); }
struct segtree {
  int siz;
  vector<pair<long long int, long long int> > sums;
  void init(int n) {
    siz = 1;
    while (siz < n) siz *= 2;
    sums.assign(2 * siz, {LONG_MAX, 0});
  }
  void set(int i, int v, int cur, int l, int r) {
    if (r - l == 1) {
      sums[cur].first = v;
      sums[cur].second = 1;
      return;
    }
    int m = getmid(l, r);
    if (i < m) {
      set(i, v, 2 * cur + 1, l, m);
    } else
      set(i, v, 2 * cur + 2, m, r);
    sums[cur].first = min(sums[2 * cur + 1].first, sums[2 * cur + 2].first);
    if (sums[2 * cur + 1].first == sums[cur].first &&
        sums[2 * cur + 2].first == sums[cur].first) {
      sums[cur].second = sums[cur * 2 + 1].second + sums[cur * 2 + 2].second;
    } else if (sums[2 * cur + 1].first == sums[cur].first) {
      sums[cur].second = sums[cur * 2 + 1].second;
    } else {
      sums[cur].second = sums[cur * 2 + 2].second;
    }
  }
  void set(int i, int v) { set(i, v, 0, 0, siz); }
  pair<long long int, long long int> sum(int l, int r, int cur, int lx,
                                         int rx) {
    if (lx >= r || l >= rx) return {LONG_MAX, 0};
    if (lx >= l && rx <= r) return {sums[cur].first, sums[cur].second};
    int mid = getmid(lx, rx);
    pair<long long int, long long int> s1 = sum(l, r, 2 * cur + 1, lx, mid),
                                       s2 = sum(l, r, 2 * cur + 2, mid, rx);
    if (s1.first < s2.first) {
      return s1;
    } else if (s1.first > s2.first)
      return s2;
    else
      return {s1.first, s1.second + s2.second};
  }
  pair<long long int, long long int> sum(int l, int r) {
    return sum(l, r, 0, 0, siz);
  }
};
int nCrModp(int n, int r, int p) {
  if (r > n - r) r = n - r;
  int C[r + 1];
  memset(C, 0, sizeof(C));
  C[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = min(i, r); j > 0; j--) C[j] = (C[j] + C[j - 1]) % p;
  }
  return C[r];
}
void ans(int t) {
  int n;
  cin >> n;
  n++;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 1; i < n; i++) {
    if (v[i - 1] != 1 && v[i] != 1) {
      cout << "ambiguous\n";
      int ve = 0;
      for (int j = 0; j < n; j++) {
        for (int k = 0; k < v[j]; k++) {
          cout << ve << ' ';
        }
        ve += v[j];
      }
      cout << '\n';
      ve = 0;
      bool is = 1;
      for (int j = 0; j < n; j++) {
        for (int k = 0; k < v[j]; k++) {
          if (j == i && is) {
            cout << ve - 1 << ' ';
            is = 0;
          } else
            cout << ve << ' ';
        }
        ve += v[j];
      }
      return;
    }
  }
  cout << "perfect";
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1, co = 1;
  while (t--) {
    ans(co);
    co++;
  }
  return 0;
}