#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
const int maxn = 4e5+5;
int n;
int en[maxn],nt[maxn],la[maxn],owo;
void adg(int x,int y) {
	en[++owo]=y; nt[owo]=la[x]; la[x]=owo;
}
int sta[maxn],tp;
int vis[maxn],tim;
int orz[maxn],oo,fr[maxn];
bool FUCK;
void dfs(int x) {
	if(vis[x]==tim) {
		int y;
		do{
			y = sta[tp--];
			orz[++oo] = y;
		}while(y!=x);
		FUCK = 1;
		return;
	}
	vis[x] = tim;
	sta[++tp] = x;
	for(int it=la[x];it;it=nt[it]) {
		int y = en[it];
		if(vis[y]==tim||(!vis[y]))dfs(y);
		if(FUCK) return;
	}
	--tp;
}
int val[maxn];
void dds(int x) {
	vector<int>ve; ve.push_back(0);
	for(int it=la[x];it;it=nt[it]) {
		int y = en[it];
		if(vis[y]) continue;
		dds(y);
		while(val[y]>=ve.size()) ve.push_back(0);
		ve[val[y]] = 1;
	}
	ve.push_back(0);
	int ss = ve.size();
	for(int i=0;i<ss;i++) if(!ve[i]) { val[x] = i; return; }
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		int x; scanf("%d",&x);
		adg(x,i);
	}
	for(int i=1;i<=n;i++) {
		if(!vis[i]) {
			++tim;
			dfs(i);
		}
		if(FUCK) break;
	}
	for(int i=1;i<=n;i++) vis[i] = 0;
	if( !(oo&1) ) 
	{ 
		puts("POSSIBLE"); 
		return 0; }
	for(int i=1;i<=oo;i++) vis[orz[i]] = 1;
	for(int i=1;i<=oo;i++) {
		dds(orz[i]);
	}
	bool flag = 1;
	for(int i=1;i<oo;i++) {
		if(val[orz[i]]!=val[orz[i+1]]) { flag = 0; break; }
	}
	if(flag) puts("IMPOSSIBLE"); 
	else puts("POSSIBLE");
}
### 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<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
const int maxn = 4e5+5;
int n;
int en[maxn],nt[maxn],la[maxn],owo;
void adg(int x,int y) {
	en[++owo]=y; nt[owo]=la[x]; la[x]=owo;
}
int sta[maxn],tp;
int vis[maxn],tim;
int orz[maxn],oo,fr[maxn];
bool FUCK;
void dfs(int x) {
	if(vis[x]==tim) {
		int y;
		do{
			y = sta[tp--];
			orz[++oo] = y;
		}while(y!=x);
		FUCK = 1;
		return;
	}
	vis[x] = tim;
	sta[++tp] = x;
	for(int it=la[x];it;it=nt[it]) {
		int y = en[it];
		if(vis[y]==tim||(!vis[y]))dfs(y);
		if(FUCK) return;
	}
	--tp;
}
int val[maxn];
void dds(int x) {
	vector<int>ve; ve.push_back(0);
	for(int it=la[x];it;it=nt[it]) {
		int y = en[it];
		if(vis[y]) continue;
		dds(y);
		while(val[y]>=ve.size()) ve.push_back(0);
		ve[val[y]] = 1;
	}
	ve.push_back(0);
	int ss = ve.size();
	for(int i=0;i<ss;i++) if(!ve[i]) { val[x] = i; return; }
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		int x; scanf("%d",&x);
		adg(x,i);
	}
	for(int i=1;i<=n;i++) {
		if(!vis[i]) {
			++tim;
			dfs(i);
		}
		if(FUCK) break;
	}
	for(int i=1;i<=n;i++) vis[i] = 0;
	if( !(oo&1) ) 
	{ 
		puts("POSSIBLE"); 
		return 0; }
	for(int i=1;i<=oo;i++) vis[orz[i]] = 1;
	for(int i=1;i<=oo;i++) {
		dds(orz[i]);
	}
	bool flag = 1;
	for(int i=1;i<oo;i++) {
		if(val[orz[i]]!=val[orz[i+1]]) { flag = 0; break; }
	}
	if(flag) puts("IMPOSSIBLE"); 
	else puts("POSSIBLE");
}
```