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.

-----Sample Input-----
4
2 3 4 1

-----Sample Output-----
POSSIBLE

The assignment is possible: {a_i} = {0, 1, 0, 1} or {a_i} = {1, 0, 1, 0}.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = "import sys\nfrom itertools import chain\nreadline = sys.stdin.readline\n\n#非再帰\ndef scc(Edge):\n    N = len(Edge)\n    Edgeinv = [[] for _ in range(N)]\n    for vn in range(N):\n        for vf in Edge[vn]:\n            Edgeinv[vf].append(vn)\n    \n    used = [False]*N\n    dim = [len(Edge[i]) for i in range(N)]\n    order = []\n    for st in range(N):\n        if not used[st]:\n            stack = [st, 0]\n            while stack:\n                vn, i = stack[-2], stack[-1]   \n                if not i and used[vn]:\n                    stack.pop()\n                    stack.pop()\n                else:\n                    used[vn] = True\n                    if i < dim[vn]:\n                        stack[-1] += 1\n                        stack.append(Edge[vn][i])\n                        stack.append(0)\n                    else:\n                        stack.pop()\n                        order.append(stack.pop())\n    res = [None]*N\n    used = [False]*N\n    cnt = -1\n    for st in order[::-1]:\n        if not used[st]:\n            cnt += 1\n            stack = [st]\n            res[st] = cnt\n            used[st] = True\n            while stack:\n                vn = stack.pop()\n                for vf in Edgeinv[vn]:\n                    if not used[vf]:\n                        used[vf] = True\n                        res[vf] = cnt\n                        stack.append(vf)\n    M = cnt+1\n    components = [[] for _ in range(M)]\n    for i in range(N):\n        components[res[i]].append(i)\n    tEdge = [[] for _ in range(M)]\n    teset = set()\n    for vn in range(N):\n        tn = res[vn]\n        for vf in Edge[vn]:\n            tf = res[vf]\n            if tn != tf and tn*M + tf not in teset:\n                teset.add(tn*M + tf)\n                tEdge[tn].append(tf)\n    return res, components, tEdge\n\nN = int(readline())\nP = list([int(x)-1 for x in readline().split()])\n\nEdge = [[] for _ in range(N)]\nfor i in range(N):\n    Edge[P[i]].append(i)\n\nR, Com, _ = scc(Edge)\n\nLord = list(chain(*Com[::-1]))\nval = [None]*N\nfor vn in Lord:\n    if not R[vn]:\n        break\n    lvn = len(Edge[vn]) + 1\n    res = [0]*lvn\n    for vf in Edge[vn]:\n        if val[vf] < lvn:\n            res[val[vf]] += 1\n    \n    for k in range(lvn):\n        if not res[k]:\n            val[vn] = k\n            break\n\nst = Lord[-1]\nlst = len(Edge[st]) + 2\nres = [0]*lst\nfor vf in Edge[st]:\n    if val[vf] is None:\n        continue\n    if val[vf] < lst:\n        res[val[vf]] += 1\nmc = []\nfor k in range(lst):\n    if not res[k]:\n        mc.append(k)\n\nvn = st\nLs = []\nwhile vn is not None:\n    for vf in Edge[vn]:\n        if R[vf]:\n            continue\n        if vf == st:\n            vn = None\n        else:\n            Ls.append(vf)\n            vn = vf\n\nLs.reverse()\n\nans = False\nfor idx in range(2):\n    vc = val[:]\n    vc[st] = mc[idx]\n    for vn in Ls:\n        lvn = len(Edge[vn])+1\n        res = [0]*lvn\n        for vf in Edge[vn]:\n            if vc[vf] < lvn:\n                res[vc[vf]] += 1\n        \n        for k in range(lvn):\n            if not res[k]:\n                vc[vn] = k\n                break\n    \n    for vn in range(N):\n        res = [False]*vc[vn]\n        for vf in Edge[vn]:\n            if vc[vn] == vc[vf]:\n                break\n            if vc[vf] < vc[vn]:\n                res[vc[vf]] = True\n        else:\n            if not all(res):\n                break\n            continue\n        break\n    else:\n        ans = True\n    if ans:\n        break\nprint(('POSSIBLE' if ans else 'IMPOSSIBLE'))\n"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 14553