#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=1000005;
int num,head[maxn],t[maxn<<1],ne[maxn<<1],n;
bool vis[maxn];
int a[maxn],p[maxn],S[maxn],top,id,lst[maxn];
inline void addedge(int x,int y){
	ne[++num]=head[x];head[x]=num;t[num]=y;
}
inline void dfs(int x){
	forE(i,x)if(!vis[t[i]])dfs(t[i]);
	id++;
	forE(i,x)if(!vis[t[i]])lst[a[t[i]]]=id;
	a[x]=0;while(lst[a[x]]==id)a[x]++;
}
int main(){
	// judge();
	read(n);
	rep(i,1,n)head[i]=-1;
	rep(i,1,n){
		read(p[i]);
		addedge(p[i],i);
	}
	int x=1;
	while(!vis[x]){
		vis[x]=1;S[++top]=x;x=p[x];
	}int p=0;
	while(S[p]!=x)p++;
	S[top+1]=S[p];
	if((top-p+1)%2==0)return puts("POSSIBLE"),0;
	// return 0;
	memset(vis,0,sizeof(vis));
	rep(i,p,top)vis[S[i]]=1;
	rep(i,p,top)dfs(S[i]);
	rep(i,p,top)if(a[S[i]]!=a[S[i+1]])return puts("POSSIBLE"),0;
	puts("IMPOSSIBLE");
	return 0;
}

### Prompt

Generate 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 rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=1000005;
int num,head[maxn],t[maxn<<1],ne[maxn<<1],n;
bool vis[maxn];
int a[maxn],p[maxn],S[maxn],top,id,lst[maxn];
inline void addedge(int x,int y){
	ne[++num]=head[x];head[x]=num;t[num]=y;
}
inline void dfs(int x){
	forE(i,x)if(!vis[t[i]])dfs(t[i]);
	id++;
	forE(i,x)if(!vis[t[i]])lst[a[t[i]]]=id;
	a[x]=0;while(lst[a[x]]==id)a[x]++;
}
int main(){
	// judge();
	read(n);
	rep(i,1,n)head[i]=-1;
	rep(i,1,n){
		read(p[i]);
		addedge(p[i],i);
	}
	int x=1;
	while(!vis[x]){
		vis[x]=1;S[++top]=x;x=p[x];
	}int p=0;
	while(S[p]!=x)p++;
	S[top+1]=S[p];
	if((top-p+1)%2==0)return puts("POSSIBLE"),0;
	// return 0;
	memset(vis,0,sizeof(vis));
	rep(i,p,top)vis[S[i]]=1;
	rep(i,p,top)dfs(S[i]);
	rep(i,p,top)if(a[S[i]]!=a[S[i+1]])return puts("POSSIBLE"),0;
	puts("IMPOSSIBLE");
	return 0;
}

```