#include <bits/stdc++.h>
using namespace std;

const int maxn = 2e5 + 6;
const int lm = 23;

typedef struct mex {
	bool occ[lm];

	void init() {
		for (int i = 0; i < lm; i++) occ[i] = false;
	}
	int get() {
		for (int i = 0; i < lm; i++) if (!occ[i]) return i;
		return lm;
	}
	void add(int x) {
		if (x >= lm) return;
		occ[x] = true;
	}
} mex;


int out[maxn];
int p[maxn];
mex S[maxn];
mex T[maxn];
bool vis[maxn];
queue<int> Q;

int n;

int main() {
	ios::sync_with_stdio(false); cin.tie(0);	
	cin>>n;

	for (int i = 1; i <= n; i++) {
		out[i] = p[i] = 0; S[i].init(); T[i].init(); vis[i] = false;
	}

	for (int i = 1; i <= n; i++) {
		cin>>p[i]; out[p[i]]++;
	}

	Q = *new queue<int>();
	for (int i = 1; i <= n; i++) {
		if (out[i] == 0) Q.push(i);
	}

	while (Q.size() > 0) {
		int z = Q.front(); Q.pop(); vis[z] = true;
		int mv = S[z].get();
		int y = p[z];
		out[y]--; S[y].add(mv);
		if (out[y] == 0) Q.push(y);
	}
	
	int u = 0;

	for (int i = 1; i <= n; i++) {
		if (vis[i] == false) { u = i; break; }
	}

	for (int t = 0; t < lm; t++) {

		for (int i = 1; i <= n; i++) {
			T[i] = S[i];
		}

		int x = u, lv = t;
		while (p[x] != u) {
			int y = p[x];
			S[y].add(lv);
			x = y; lv = S[x].get();
		}
		
		// p[x] == u

		S[u].add(S[x].get());
		if (S[u].get() == t) {
			cout<<"POSSIBLE"<<endl; return 0;
		}

		for (int i = 1; i <= n; i++) {
			S[i] = T[i];
		}
	}

	cout<<"IMPOSSIBLE"<<endl;
}

### Prompt

Construct a Cpp code solution to the problem outlined:

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>
using namespace std;

const int maxn = 2e5 + 6;
const int lm = 23;

typedef struct mex {
	bool occ[lm];

	void init() {
		for (int i = 0; i < lm; i++) occ[i] = false;
	}
	int get() {
		for (int i = 0; i < lm; i++) if (!occ[i]) return i;
		return lm;
	}
	void add(int x) {
		if (x >= lm) return;
		occ[x] = true;
	}
} mex;


int out[maxn];
int p[maxn];
mex S[maxn];
mex T[maxn];
bool vis[maxn];
queue<int> Q;

int n;

int main() {
	ios::sync_with_stdio(false); cin.tie(0);	
	cin>>n;

	for (int i = 1; i <= n; i++) {
		out[i] = p[i] = 0; S[i].init(); T[i].init(); vis[i] = false;
	}

	for (int i = 1; i <= n; i++) {
		cin>>p[i]; out[p[i]]++;
	}

	Q = *new queue<int>();
	for (int i = 1; i <= n; i++) {
		if (out[i] == 0) Q.push(i);
	}

	while (Q.size() > 0) {
		int z = Q.front(); Q.pop(); vis[z] = true;
		int mv = S[z].get();
		int y = p[z];
		out[y]--; S[y].add(mv);
		if (out[y] == 0) Q.push(y);
	}
	
	int u = 0;

	for (int i = 1; i <= n; i++) {
		if (vis[i] == false) { u = i; break; }
	}

	for (int t = 0; t < lm; t++) {

		for (int i = 1; i <= n; i++) {
			T[i] = S[i];
		}

		int x = u, lv = t;
		while (p[x] != u) {
			int y = p[x];
			S[y].add(lv);
			x = y; lv = S[x].get();
		}
		
		// p[x] == u

		S[u].add(S[x].get());
		if (S[u].get() == t) {
			cout<<"POSSIBLE"<<endl; return 0;
		}

		for (int i = 1; i <= n; i++) {
			S[i] = T[i];
		}
	}

	cout<<"IMPOSSIBLE"<<endl;
}

```