#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
#include <set>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=200010;
int fa[N];
bool vis[N];
int nodes[N],ns=0;
int mex1[N],mex2[N];
namespace T{
	const int E=N;
	int to[E],bro[E],head[N],e=0;
	inline void init(){
		memset(head,-1,sizeof(head));
	}
	inline void ae(int u,int v){
		to[e]=v,bro[e]=head[u],head[u]=e++;
	}
	void dfs(int x){
		set<int>s;
		for(int i=head[x],v;~i;i=bro[i]){
			dfs(v=to[i]);
			s.insert(mex1[v]);
		}
		for(int &i=mex1[x]=0;s.find(i)!=s.end();i++);
		for(int &i=mex2[x]=mex1[x]+1;s.find(i)!=s.end();i++);
	}
}
inline int gval(int sg){
	for(int i=1;i<=ns;i++){
		sg=(sg!=mex1[nodes[i]]?mex1:mex2)[nodes[i]];
	}
	return sg;
}
inline bool Main(){
	int n=ni;
	T::init();
	for(int i=1;i<=n;i++){
		fa[i]=ni;
	}
	memset(vis,0,sizeof(vis));
	int x=1;
	for(;!vis[x];vis[x]=true,x=fa[x]);
	memset(vis,0,sizeof(vis));
	for(int p=x;nodes[++ns]=p,vis[p]=true,p=fa[p],p!=x;);
	T::init();
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			T::ae(fa[i],i);
		}
	}
	for(int i=1;i<=ns;i++){
		T::dfs(nodes[i]);
	}
	int val1=mex1[nodes[ns]],val2=mex2[nodes[ns]];
	return gval(val1)==val1||gval(val2)==val2;
}
int main(){
	puts(Main()?"POSSIBLE":"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 <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
#include <set>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=200010;
int fa[N];
bool vis[N];
int nodes[N],ns=0;
int mex1[N],mex2[N];
namespace T{
	const int E=N;
	int to[E],bro[E],head[N],e=0;
	inline void init(){
		memset(head,-1,sizeof(head));
	}
	inline void ae(int u,int v){
		to[e]=v,bro[e]=head[u],head[u]=e++;
	}
	void dfs(int x){
		set<int>s;
		for(int i=head[x],v;~i;i=bro[i]){
			dfs(v=to[i]);
			s.insert(mex1[v]);
		}
		for(int &i=mex1[x]=0;s.find(i)!=s.end();i++);
		for(int &i=mex2[x]=mex1[x]+1;s.find(i)!=s.end();i++);
	}
}
inline int gval(int sg){
	for(int i=1;i<=ns;i++){
		sg=(sg!=mex1[nodes[i]]?mex1:mex2)[nodes[i]];
	}
	return sg;
}
inline bool Main(){
	int n=ni;
	T::init();
	for(int i=1;i<=n;i++){
		fa[i]=ni;
	}
	memset(vis,0,sizeof(vis));
	int x=1;
	for(;!vis[x];vis[x]=true,x=fa[x]);
	memset(vis,0,sizeof(vis));
	for(int p=x;nodes[++ns]=p,vis[p]=true,p=fa[p],p!=x;);
	T::init();
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			T::ae(fa[i],i);
		}
	}
	for(int i=1;i<=ns;i++){
		T::dfs(nodes[i]);
	}
	int val1=mex1[nodes[ns]],val2=mex2[nodes[ns]];
	return gval(val1)==val1||gval(val2)==val2;
}
int main(){
	puts(Main()?"POSSIBLE":"IMPOSSIBLE");
	return 0;
}
```