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 = 'mod = 1000000007\neps = 10**-9\n\n\ndef main():\n    import sys\n    from collections import deque\n    input = sys.stdin.readline\n\n    N = int(input())\n    P = list(map(int, input().split()))\n    adj = [[] for _ in range(N+1)]\n    adj_directed = [[] for _ in range(N+1)]\n    adj_rev = [[] for _ in range(N+1)]\n    out = [0] * (N + 1)\n    for i, p in enumerate(P):\n        adj_directed[p].append(i+1)\n        adj[p].append(i+1)\n        adj[i+1].append(p)\n        adj_rev[i+1].append(p)\n        out[p] += 1\n\n    que = deque()\n    que.append(1)\n    seen = [-1] * (N+1)\n    seen[1] = 0\n    par = [-1] * (N+1)\n    back_from = -1\n    back_to = -1\n    while que:\n        v = que.popleft()\n        for u in adj[v]:\n            if seen[u] == -1:\n                seen[u] = seen[v] + 1\n                que.append(u)\n                par[u] = v\n            else:\n                if par[v] != u:\n                    if P[v-1] == u:\n                        back_from = u\n                        back_to = v\n                        out[u] -= 1\n\n    G = [-1] * (N+1)\n    for v in range(1, N+1):\n        if out[v] == 0:\n            que.append(v)\n    while que:\n        v = que.popleft()\n        M = set()\n        for u in adj_directed[v]:\n            if v == back_from and u == back_to:\n                continue\n            M.add(G[u])\n        for i in range(N+1):\n            if i not in M:\n                G[v] = i\n                break\n        for u in adj_rev[v]:\n            if v == back_to and u == back_from:\n                continue\n            out[u] -= 1\n            if out[u] == 0:\n                que.append(u)\n\n    if G[back_from] != G[back_to]:\n        print("POSSIBLE")\n        return\n\n    cycle = set()\n    v = back_from\n    while v > 0:\n        cycle.add(v)\n        v = par[v]\n    v = back_to\n    while v > 0:\n        cycle.add(v)\n        v = par[v]\n\n    v = back_from\n    seen = {v}\n    while True:\n        M = set()\n        for u in adj_directed[v]:\n            M.add(G[u])\n        for i in range(N+1):\n            if i not in M:\n                if G[v] == i:\n                    print("POSSIBLE")\n                    return\n                G[v] = i\n                break\n        fin = 1\n        for u in adj_rev[v]:\n            if u in cycle and u not in seen:\n                v = u\n                seen.add(u)\n                fin = 0\n                break\n        if fin:\n            break\n    print("IMPOSSIBLE")\n\n\ndef __starting_point():\n    main()\n\n__starting_point()'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 16457