#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 200010;
int N;
int p[MC];
vector<int> V[MC];
vector<int> d[MC];
int a[MC];
bool b[MC];
bool c[MC];
int r;

int dfs(int q){
	for(auto u : V[q]){
		if(c[u]) continue;
		d[q].PB(dfs(u));
	}
	sort(d[q].begin(),d[q].end());
	a[q] = -1;
	for(auto u : d[q]){
		if(u > a[q]+1) break;
		a[q] = u;
	}
	return ++a[q];
}

int main(){
	scanf("%d" , &N);
	repp(i,1,N+1){
		scanf("%d" , p + i);
		V[p[i]].PB(i);
	}
	r = 1;
	while(!b[r]){
		b[r] = 1;
		r = p[r];
	}
	while(!c[r]){
		c[r] = 1;
		r = p[r];
	}
	int mn = 123456789;
	repp(i,1,N+1){
		if(c[i]) mn = min(mn , dfs(i));
	}
	bool t = 0;
	int y = 0;
	while(c[r]){
		c[r] = 0;
		if(a[r] != mn) t = 1;
		r = p[r];
		++y;
	}
	printf("%s\n" , t || y%2==0 ? "POSSIBLE" : "IMPOSSIBLE");
	return 0;
}

### Prompt

Please formulate 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;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 200010;
int N;
int p[MC];
vector<int> V[MC];
vector<int> d[MC];
int a[MC];
bool b[MC];
bool c[MC];
int r;

int dfs(int q){
	for(auto u : V[q]){
		if(c[u]) continue;
		d[q].PB(dfs(u));
	}
	sort(d[q].begin(),d[q].end());
	a[q] = -1;
	for(auto u : d[q]){
		if(u > a[q]+1) break;
		a[q] = u;
	}
	return ++a[q];
}

int main(){
	scanf("%d" , &N);
	repp(i,1,N+1){
		scanf("%d" , p + i);
		V[p[i]].PB(i);
	}
	r = 1;
	while(!b[r]){
		b[r] = 1;
		r = p[r];
	}
	while(!c[r]){
		c[r] = 1;
		r = p[r];
	}
	int mn = 123456789;
	repp(i,1,N+1){
		if(c[i]) mn = min(mn , dfs(i));
	}
	bool t = 0;
	int y = 0;
	while(c[r]){
		c[r] = 0;
		if(a[r] != mn) t = 1;
		r = p[r];
		++y;
	}
	printf("%s\n" , t || y%2==0 ? "POSSIBLE" : "IMPOSSIBLE");
	return 0;
}

```