A tree of size *n* is an undirected connected graph consisting of *n* vertices without cycles.

Consider some tree with *n* vertices. We call a tree invariant relative to permutation *p* = *p*<sub class="lower-index">1</sub>*p*<sub class="lower-index">2</sub>... *p*<sub class="lower-index">*n*</sub>, if for any two vertices of the tree *u* and *v* the condition holds: "vertices *u* and *v* are connected by an edge if and only if vertices *p*<sub class="lower-index">*u*</sub> and *p*<sub class="lower-index">*v*</sub> are connected by an edge".

You are given permutation *p* of size *n*. Find some tree size *n*, invariant relative to the given permutation.
The first line contains number *n* (1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>) — the size of the permutation (also equal to the size of the sought tree).

The second line contains permutation *p*<sub class="lower-index">*i*</sub> (1 ≤ *p*<sub class="lower-index">*i*</sub> ≤ *n*).
def solve_tree_permutation(n, permutation):
    inverse_permutation = [0] * n
    for i in range(n):
        inverse_permutation[permutation[i] - 1] = i + 1
    
    if permutation == inverse_permutation:
        return "NO"
    
    edges = []
    for i in range(n):
        edges.append((permutation[i], inverse_permutation[i]))
    
    return "YES", edges


n = int(input())
permutation = list(map(int, input().split()))


result = solve_tree_permutation(n, permutation)
if result == "NO":
    print(result)
else:
    print(result[0])
    for edge in result[1]:
        print(edge[0], edge[1])


