#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=200000+10;
int a[maxn],sg[maxn],cnt[maxn],b[maxn],c[maxn],p[maxn],q[maxn],h[maxn],go[maxn],nxt[maxn];
bool bz[maxn],pd[maxn];
int i,j,k,l,t,n,m,u,v,tot,top;
bool czy;
void add(int x,int y){
	go[++tot]=y;
	nxt[tot]=h[x];
	h[x]=tot;
}
void dfs(int x){
	int i,l=0,t=h[x];
	while (t){
		dfs(go[t]);
		t=nxt[t];
	}
	t=h[x];
	while (t){
		q[++l]=sg[go[t]];
		t=nxt[t];
	}
	fo(i,1,l) cnt[q[i]]++;
	while (cnt[sg[x]]) sg[x]++;
	fo(i,1,l) cnt[q[i]]=0;
}
int main(){
	scanf("%d",&n);
	fo(i,1,n){
		scanf("%d",&a[i]);
		add(a[i],i);
	}
	j=1;
	while (1){
		bz[j]=1;
		if (bz[a[j]]){
			u=a[j];
			v=j;
			break;
		}
		j=a[j];
	}
	while (1){
		pd[j]=1;
		if (pd[a[j]]) break;
		j=a[j];
	}
	k=j;
	while (1){
		t=h[j];
		top=0;
		while (t){
			if (!pd[go[t]]){
				dfs(go[t]);
				p[++top]=sg[go[t]];
			}
			t=nxt[t];
		}
		fo(i,1,top) cnt[p[i]]++;
		while (cnt[b[j]]) b[j]++;
		c[j]=b[j]+1;
		while (cnt[c[j]]) c[j]++;
		fo(i,1,top) cnt[p[i]]=0;
		if (a[j]==k) break;
		j=a[j];
	}
	sg[u]=b[u];
	j=u;
	while (1){
		if (sg[j]==b[a[j]]) sg[a[j]]=c[a[j]];else sg[a[j]]=b[a[j]];
		if (a[j]==v) break;
		j=a[j];
	}
	if (sg[u]!=sg[v]){
		printf("POSSIBLE\n");
		return 0;
	}
	sg[u]=c[u];
	j=u;
	while (1){
		if (sg[j]==b[a[j]]) sg[a[j]]=c[a[j]];else sg[a[j]]=b[a[j]];
		if (a[j]==v) break;
		j=a[j];
	}
	if (sg[v]!=b[u]) printf("IMPOSSIBLE\n");else printf("POSSIBLE\n");
}
### Prompt

In Cpp, your task is to solve 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<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=200000+10;
int a[maxn],sg[maxn],cnt[maxn],b[maxn],c[maxn],p[maxn],q[maxn],h[maxn],go[maxn],nxt[maxn];
bool bz[maxn],pd[maxn];
int i,j,k,l,t,n,m,u,v,tot,top;
bool czy;
void add(int x,int y){
	go[++tot]=y;
	nxt[tot]=h[x];
	h[x]=tot;
}
void dfs(int x){
	int i,l=0,t=h[x];
	while (t){
		dfs(go[t]);
		t=nxt[t];
	}
	t=h[x];
	while (t){
		q[++l]=sg[go[t]];
		t=nxt[t];
	}
	fo(i,1,l) cnt[q[i]]++;
	while (cnt[sg[x]]) sg[x]++;
	fo(i,1,l) cnt[q[i]]=0;
}
int main(){
	scanf("%d",&n);
	fo(i,1,n){
		scanf("%d",&a[i]);
		add(a[i],i);
	}
	j=1;
	while (1){
		bz[j]=1;
		if (bz[a[j]]){
			u=a[j];
			v=j;
			break;
		}
		j=a[j];
	}
	while (1){
		pd[j]=1;
		if (pd[a[j]]) break;
		j=a[j];
	}
	k=j;
	while (1){
		t=h[j];
		top=0;
		while (t){
			if (!pd[go[t]]){
				dfs(go[t]);
				p[++top]=sg[go[t]];
			}
			t=nxt[t];
		}
		fo(i,1,top) cnt[p[i]]++;
		while (cnt[b[j]]) b[j]++;
		c[j]=b[j]+1;
		while (cnt[c[j]]) c[j]++;
		fo(i,1,top) cnt[p[i]]=0;
		if (a[j]==k) break;
		j=a[j];
	}
	sg[u]=b[u];
	j=u;
	while (1){
		if (sg[j]==b[a[j]]) sg[a[j]]=c[a[j]];else sg[a[j]]=b[a[j]];
		if (a[j]==v) break;
		j=a[j];
	}
	if (sg[u]!=sg[v]){
		printf("POSSIBLE\n");
		return 0;
	}
	sg[u]=c[u];
	j=u;
	while (1){
		if (sg[j]==b[a[j]]) sg[a[j]]=c[a[j]];else sg[a[j]]=b[a[j]];
		if (a[j]==v) break;
		j=a[j];
	}
	if (sg[v]!=b[u]) printf("IMPOSSIBLE\n");else printf("POSSIBLE\n");
}
```