#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
#define MN 200005
int n,last[MN],cir[MN],mem,now,sg[MN],sg2[MN],f[MN],vis[MN];
bool found,inq[MN],cime[MN],Vis[MN];
struct edge{int to,nex;}e[MN];int cnt,hr[MN];
inline void ins(int f,int t){
	e[++cnt]=(edge){t,hr[f]};hr[f]=cnt;
}
void findcircle(int x){
	if(found) return;inq[x]=Vis[x]=true;
	for(int i=hr[x];i;i=e[i].nex){
		if(inq[e[i].to]){for(int j=x;j!=e[i].to;j=last[j]) cir[++mem]=j;cir[++mem]=e[i].to;found=true;}
		else if(!Vis[e[i].to]) last[e[i].to]=x,findcircle(e[i].to);
	}
	inq[x]=false;
}
void dp(int x){
	register int i;
	for(i=hr[x];i;i=e[i].nex) if(!cime[e[i].to]) dp(e[i].to);
	++now;for(i=hr[x];i;i=e[i].nex) if(!cime[e[i].to]) vis[sg[e[i].to]]=now;
	for(;vis[sg[x]]==now;sg[x]++);
	for(sg2[x]=sg[x]+1;vis[sg2[x]]==now;sg2[x]++);
}
bool check(){
	f[1]=sg[cir[1]];register int i;
    for(i=2;i<=mem;i++) f[i]=f[i-1]==sg[cir[i]]?sg2[cir[i]]:sg[cir[i]];
    if(f[mem]!=sg[cir[1]]) return true;
    f[1]=sg2[cir[1]];
    for(i=2;i<=mem;i++) f[i]=f[i-1]==sg[cir[i]]?sg2[cir[i]]:sg[cir[i]];
    if(f[mem]==sg[cir[1]]) return true;
    return false;
}
int main(){
	n=read();register int i;
	for(i=1;i<=n;i++) ins(read(),i);
	for(i=1;i<=n;i++) findcircle(i);
	for(i=1;i<=mem;i++) cime[cir[i]]=true;
	for(i=1;i<=mem;i++) dp(cir[i]);
	printf(check()?"POSSIBLE\n":"IMPOSSIBLE\n");
    return 0;
}
### Prompt

Please create a solution in CPP 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>
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
#define MN 200005
int n,last[MN],cir[MN],mem,now,sg[MN],sg2[MN],f[MN],vis[MN];
bool found,inq[MN],cime[MN],Vis[MN];
struct edge{int to,nex;}e[MN];int cnt,hr[MN];
inline void ins(int f,int t){
	e[++cnt]=(edge){t,hr[f]};hr[f]=cnt;
}
void findcircle(int x){
	if(found) return;inq[x]=Vis[x]=true;
	for(int i=hr[x];i;i=e[i].nex){
		if(inq[e[i].to]){for(int j=x;j!=e[i].to;j=last[j]) cir[++mem]=j;cir[++mem]=e[i].to;found=true;}
		else if(!Vis[e[i].to]) last[e[i].to]=x,findcircle(e[i].to);
	}
	inq[x]=false;
}
void dp(int x){
	register int i;
	for(i=hr[x];i;i=e[i].nex) if(!cime[e[i].to]) dp(e[i].to);
	++now;for(i=hr[x];i;i=e[i].nex) if(!cime[e[i].to]) vis[sg[e[i].to]]=now;
	for(;vis[sg[x]]==now;sg[x]++);
	for(sg2[x]=sg[x]+1;vis[sg2[x]]==now;sg2[x]++);
}
bool check(){
	f[1]=sg[cir[1]];register int i;
    for(i=2;i<=mem;i++) f[i]=f[i-1]==sg[cir[i]]?sg2[cir[i]]:sg[cir[i]];
    if(f[mem]!=sg[cir[1]]) return true;
    f[1]=sg2[cir[1]];
    for(i=2;i<=mem;i++) f[i]=f[i-1]==sg[cir[i]]?sg2[cir[i]]:sg[cir[i]];
    if(f[mem]==sg[cir[1]]) return true;
    return false;
}
int main(){
	n=read();register int i;
	for(i=1;i<=n;i++) ins(read(),i);
	for(i=1;i<=n;i++) findcircle(i);
	for(i=1;i<=mem;i++) cime[cir[i]]=true;
	for(i=1;i<=mem;i++) dp(cir[i]);
	printf(check()?"POSSIBLE\n":"IMPOSSIBLE\n");
    return 0;
}
```