#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 200010
int p[N],n;
bool vis[N];
int nz[N],g[N];
vector<int> ch[N];
bool Solve(int val,int t){
    //cout<<"$"<<val<<" "<<t<<endl;
    int x=p[t],y=val;
    while(1){
	unordered_set<int> st;
	st.insert(y);
	for(auto i:ch[x])st.insert(g[i]);
	y=0;
	while(1){
	    if(st.find(y)==st.end())break;
	    y++;
	}
	if(x==t)break;
	x=p[x];
    }
    return val==y;
}
int main(){
    cin>>n;
    lol(i,n)nz[i]=0,vis[i]=0;
    lol(i,n){
	cin>>p[i];p[i]--;
	nz[p[i]]++;
	ch[p[i]].push_back(i);
    }
    int x=0,t;
    while(1){
	if(vis[x]){
	    t=x;break;
	}
	vis[x]=1;
	x=p[x];
    }
    x=t;
    lol(i,n)vis[i]=0,g[i]=-1;
    while(1){
	vis[x]=1;
	x=p[x];
	if(x==t)break;
    }
    queue<int> Q;
    lol(i,n)if(nz[i]==0)Q.push(i);
    while(!Q.empty()){
	x=Q.front();Q.pop();
	if(vis[x])continue;
	unordered_set<int> st;
	for(auto y:ch[x])st.insert(g[y]);
	g[x]=0;
	while(1){
	    if(st.find(g[x])==st.end())break;
	    g[x]++;
	}
	nz[p[x]]--;
	if(nz[p[x]]==0)Q.push(p[x]);
    }
    //lol(i,n)cout<<vis[i]<<" "<<g[i]<<endl;
    unordered_set<int> st;
    for(auto y:ch[t])st.insert(g[y]);
    bool ans=false;
    x=0;
    int cnt=0;
    while(cnt<2){
	if(st.find(x)==st.end()){
	    ans|=Solve(x,t);
	    cnt++;
	}
	x++;
    }
    cout<<(ans?"POSSIBLE":"IMPOSSIBLE")<<endl;
    return 0;
}

### Prompt

Your task is to create 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<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 200010
int p[N],n;
bool vis[N];
int nz[N],g[N];
vector<int> ch[N];
bool Solve(int val,int t){
    //cout<<"$"<<val<<" "<<t<<endl;
    int x=p[t],y=val;
    while(1){
	unordered_set<int> st;
	st.insert(y);
	for(auto i:ch[x])st.insert(g[i]);
	y=0;
	while(1){
	    if(st.find(y)==st.end())break;
	    y++;
	}
	if(x==t)break;
	x=p[x];
    }
    return val==y;
}
int main(){
    cin>>n;
    lol(i,n)nz[i]=0,vis[i]=0;
    lol(i,n){
	cin>>p[i];p[i]--;
	nz[p[i]]++;
	ch[p[i]].push_back(i);
    }
    int x=0,t;
    while(1){
	if(vis[x]){
	    t=x;break;
	}
	vis[x]=1;
	x=p[x];
    }
    x=t;
    lol(i,n)vis[i]=0,g[i]=-1;
    while(1){
	vis[x]=1;
	x=p[x];
	if(x==t)break;
    }
    queue<int> Q;
    lol(i,n)if(nz[i]==0)Q.push(i);
    while(!Q.empty()){
	x=Q.front();Q.pop();
	if(vis[x])continue;
	unordered_set<int> st;
	for(auto y:ch[x])st.insert(g[y]);
	g[x]=0;
	while(1){
	    if(st.find(g[x])==st.end())break;
	    g[x]++;
	}
	nz[p[x]]--;
	if(nz[p[x]]==0)Q.push(p[x]);
    }
    //lol(i,n)cout<<vis[i]<<" "<<g[i]<<endl;
    unordered_set<int> st;
    for(auto y:ch[t])st.insert(g[y]);
    bool ans=false;
    x=0;
    int cnt=0;
    while(cnt<2){
	if(st.find(x)==st.end()){
	    ans|=Solve(x,t);
	    cnt++;
	}
	x++;
    }
    cout<<(ans?"POSSIBLE":"IMPOSSIBLE")<<endl;
    return 0;
}

```