#include<iostream>
#include<cstdio>
#define MN 200000
using namespace std;
inline int read()
{
    int x=0,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();}
    return x*f;
}
int n,m,head[MN+5],c[MN+5],num,inq[MN+5],Fa[MN+5],cnt,found,in[MN+5],sg[MN+5],sg2[MN+5],vis[MN+5],now,f[MN+5],Vis[MN+5];
struct edge{int to,next;}e[MN+5];
inline void ins(int f,int t){e[++cnt]=(edge){t,head[f]};head[f]=cnt;}
void FindCircle(int x)
{
    if(found) return;inq[x]=1;Vis[x]=1;
    for(int i=head[x];i;i=e[i].next)
        if(inq[e[i].to])
        {
            for(int t=x;t!=e[i].to;t=Fa[t]) c[++num]=t;
            c[++num]=e[i].to;found=1;
        }
        else if(!Vis[e[i].to]) Fa[e[i].to]=x,FindCircle(e[i].to);
    inq[x]=0;
}
void Dp(int x)
{
    for(int i=head[x];i;i=e[i].next)
        if(!in[e[i].to]) Dp(e[i].to);
    ++now;for(int i=head[x];i;i=e[i].next) if(!in[e[i].to]) vis[sg[e[i].to]]=now;
    for(;vis[sg[x]]==now;++sg[x]);
    for(sg2[x]=sg[x]+1;vis[sg2[x]]==now;++sg2[x]);
}
int main()
{
    n=read();
    for(int i=1;i<=n;++i) ins(read(),i);
    for(int i=1;i<=n;++i) if(!vis[i]) FindCircle(i);
    for(int i=1;i<=num;++i) in[c[i]]=1;
    for(int i=1;i<=num;++i) Dp(c[i]);
    f[1]=sg[c[1]];
    for(int i=2;i<=num;++i) f[i]=f[i-1]==sg[c[i]]?sg2[c[i]]:sg[c[i]];
    if(f[num]!=sg[c[1]]) return 0*puts("POSSIBLE");
    f[1]=sg2[c[1]];
    for(int i=2;i<=num;++i) f[i]=f[i-1]==sg[c[i]]?sg2[c[i]]:sg[c[i]];
    if(f[num]==sg[c[1]]) return 0*puts("POSSIBLE");
    puts("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<iostream>
#include<cstdio>
#define MN 200000
using namespace std;
inline int read()
{
    int x=0,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();}
    return x*f;
}
int n,m,head[MN+5],c[MN+5],num,inq[MN+5],Fa[MN+5],cnt,found,in[MN+5],sg[MN+5],sg2[MN+5],vis[MN+5],now,f[MN+5],Vis[MN+5];
struct edge{int to,next;}e[MN+5];
inline void ins(int f,int t){e[++cnt]=(edge){t,head[f]};head[f]=cnt;}
void FindCircle(int x)
{
    if(found) return;inq[x]=1;Vis[x]=1;
    for(int i=head[x];i;i=e[i].next)
        if(inq[e[i].to])
        {
            for(int t=x;t!=e[i].to;t=Fa[t]) c[++num]=t;
            c[++num]=e[i].to;found=1;
        }
        else if(!Vis[e[i].to]) Fa[e[i].to]=x,FindCircle(e[i].to);
    inq[x]=0;
}
void Dp(int x)
{
    for(int i=head[x];i;i=e[i].next)
        if(!in[e[i].to]) Dp(e[i].to);
    ++now;for(int i=head[x];i;i=e[i].next) if(!in[e[i].to]) vis[sg[e[i].to]]=now;
    for(;vis[sg[x]]==now;++sg[x]);
    for(sg2[x]=sg[x]+1;vis[sg2[x]]==now;++sg2[x]);
}
int main()
{
    n=read();
    for(int i=1;i<=n;++i) ins(read(),i);
    for(int i=1;i<=n;++i) if(!vis[i]) FindCircle(i);
    for(int i=1;i<=num;++i) in[c[i]]=1;
    for(int i=1;i<=num;++i) Dp(c[i]);
    f[1]=sg[c[1]];
    for(int i=2;i<=num;++i) f[i]=f[i-1]==sg[c[i]]?sg2[c[i]]:sg[c[i]];
    if(f[num]!=sg[c[1]]) return 0*puts("POSSIBLE");
    f[1]=sg2[c[1]];
    for(int i=2;i<=num;++i) f[i]=f[i-1]==sg[c[i]]?sg2[c[i]]:sg[c[i]];
    if(f[num]==sg[c[1]]) return 0*puts("POSSIBLE");
    puts("IMPOSSIBLE");
    return 0;
}
```