#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define poly vector<ll>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
inline ll read(){
	ll x=0;char ch=getchar();bool d=1;
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') d=0;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return d?x:-x;
}
inline void write(ll x){
	if(x<0) x=-x,putchar('-');
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=2e5+5;
int a[N],fa[N];
bool used[N];
poly v[N];
void dfs(int u){
	poly rv;
	for(auto k:v[u]){
		if(used[k]) continue;
		dfs(k);rv.pb(a[k]);
	}
	sort(rv.begin(),rv.end());
	for(auto x:rv){
		if(x==a[u]) a[u]++;
	}
}
int main(){
	int n=read();
	For(i,1,n){
		fa[i]=read();
		v[fa[i]].pb(i);
	}
	int rt=1;
	while(!used[rt]) used[rt]=1,rt=fa[rt];
	memset(used,0,sizeof(used));
	while(!used[rt]) used[rt]=1,rt=fa[rt];
	int L=n+1,R=0,cnt=0;
	For(i,1,n) if(used[i]){
		dfs(i);cnt++;
		R=max(R,a[i]);L=min(L,a[i]);
	}
	if(L==R&&cnt%2) puts("IMPOSSIBLE");
	else puts("POSSIBLE");
}
### 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>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define poly vector<ll>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
inline ll read(){
	ll x=0;char ch=getchar();bool d=1;
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') d=0;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return d?x:-x;
}
inline void write(ll x){
	if(x<0) x=-x,putchar('-');
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=2e5+5;
int a[N],fa[N];
bool used[N];
poly v[N];
void dfs(int u){
	poly rv;
	for(auto k:v[u]){
		if(used[k]) continue;
		dfs(k);rv.pb(a[k]);
	}
	sort(rv.begin(),rv.end());
	for(auto x:rv){
		if(x==a[u]) a[u]++;
	}
}
int main(){
	int n=read();
	For(i,1,n){
		fa[i]=read();
		v[fa[i]].pb(i);
	}
	int rt=1;
	while(!used[rt]) used[rt]=1,rt=fa[rt];
	memset(used,0,sizeof(used));
	while(!used[rt]) used[rt]=1,rt=fa[rt];
	int L=n+1,R=0,cnt=0;
	For(i,1,n) if(used[i]){
		dfs(i);cnt++;
		R=max(R,a[i]);L=min(L,a[i]);
	}
	if(L==R&&cnt%2) puts("IMPOSSIBLE");
	else puts("POSSIBLE");
}
```