#include <bits/stdc++.h>
#define RI register int

using namespace std;

int const MAXN = 2e5 + 5;
struct Edges { int to, next; } e[MAXN];
int head[MAXN], tot;
int vis[MAXN], Ring[MAXN], stk[MAXN], top, a[MAXN], cnt, dfn[MAXN];
int ok[MAXN][21], b[MAXN];

inline void addedge(int from, int to) {
  e[++tot] = (Edges){to, head[from]};
  head[from] = to;
}

void Dfs(int now) {
  if (vis[now]) {
    while (stk[top] != now) a[++cnt] = stk[top--];
    a[++cnt] = stk[top--];
    return;
  }
  stk[++top] = now;
  vis[now] = 1;
  for (RI i = head[now]; i; i = e[i].next)
    if (!dfn[e[i].to]) Dfs(e[i].to);
  dfn[now] = 1;
  --top;
}

void Work(int now) {
  for (RI i = head[now]; i; i = e[i].next)
    if (!Ring[e[i].to])
      Work(e[i].to), ok[now][b[e[i].to]] = 1;
  for (RI i = 0; i < 20; ++i)
    if (!ok[now][i])
      return b[now] = i, void();
}

int main() {
 // freopen("a.in", "r", stdin);
  ios :: sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n; cin >> n;
  for (RI i = 1, x; i <= n; ++i)
    cin >> x, addedge(x, i);
  for (RI i = 1; i <= n; ++i)
    if (!dfn[i]) Dfs(i);
  if (cnt % 2 == 0) return puts("POSSIBLE"), 0;
  for (RI i = 1; i <= cnt; ++i) Ring[a[i]] = 1;
  for (RI i = 1; i <= cnt; ++i)
    Work(a[i]);
  for (RI i = 2; i <= cnt; ++i)
    if (b[a[i]] != b[a[1]]) return puts("POSSIBLE"), 0;
  puts("IMPOSSIBLE");
  return 0;
}

### Prompt

Please formulate a cpp solution to the following problem:

There is a directed graph with N vertices and N edges. The vertices are numbered 1, 2, ..., N.

The graph has the following N edges: (p_1, 1), (p_2, 2), ..., (p_N, N), and the graph is weakly connected. Here, an edge from Vertex u to Vertex v is denoted by (u, v), and a weakly connected graph is a graph which would be connected if each edge was bidirectional.

We would like to assign a value to each of the vertices in this graph so that the following conditions are satisfied. Here, a_i is the value assigned to Vertex i.

* Each a_i is a non-negative integer.
* For each edge (i, j), a_i \neq a_j holds.
* For each i and each integer x(0 ≤ x < a_i), there exists a vertex j such that the edge (i, j) exists and x = a_j holds.



Determine whether there exists such an assignment.

Constraints

* 2 ≤ N ≤ 200 000
* 1 ≤ p_i ≤ N
* p_i \neq i
* The graph is weakly connected.

Input

Input is given from Standard Input in the following format:


N
p_1 p_2 ... p_N


Output

If the assignment is possible, print `POSSIBLE`; otherwise, print `IMPOSSIBLE`.

Examples

Input

4
2 3 4 1


Output

POSSIBLE


Input

3
2 3 1


Output

IMPOSSIBLE


Input

4
2 3 1 1


Output

POSSIBLE


Input

6
4 5 6 5 6 4


Output

IMPOSSIBLE

### Response

```cpp
#include <bits/stdc++.h>
#define RI register int

using namespace std;

int const MAXN = 2e5 + 5;
struct Edges { int to, next; } e[MAXN];
int head[MAXN], tot;
int vis[MAXN], Ring[MAXN], stk[MAXN], top, a[MAXN], cnt, dfn[MAXN];
int ok[MAXN][21], b[MAXN];

inline void addedge(int from, int to) {
  e[++tot] = (Edges){to, head[from]};
  head[from] = to;
}

void Dfs(int now) {
  if (vis[now]) {
    while (stk[top] != now) a[++cnt] = stk[top--];
    a[++cnt] = stk[top--];
    return;
  }
  stk[++top] = now;
  vis[now] = 1;
  for (RI i = head[now]; i; i = e[i].next)
    if (!dfn[e[i].to]) Dfs(e[i].to);
  dfn[now] = 1;
  --top;
}

void Work(int now) {
  for (RI i = head[now]; i; i = e[i].next)
    if (!Ring[e[i].to])
      Work(e[i].to), ok[now][b[e[i].to]] = 1;
  for (RI i = 0; i < 20; ++i)
    if (!ok[now][i])
      return b[now] = i, void();
}

int main() {
 // freopen("a.in", "r", stdin);
  ios :: sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n; cin >> n;
  for (RI i = 1, x; i <= n; ++i)
    cin >> x, addedge(x, i);
  for (RI i = 1; i <= n; ++i)
    if (!dfn[i]) Dfs(i);
  if (cnt % 2 == 0) return puts("POSSIBLE"), 0;
  for (RI i = 1; i <= cnt; ++i) Ring[a[i]] = 1;
  for (RI i = 1; i <= cnt; ++i)
    Work(a[i]);
  for (RI i = 2; i <= cnt; ++i)
    if (b[a[i]] != b[a[1]]) return puts("POSSIBLE"), 0;
  puts("IMPOSSIBLE");
  return 0;
}

```