A permutation *p* of length *n* is a sequence of distinct integers *p*<sub class="lower-index">1</sub>, *p*<sub class="lower-index">2</sub>, ..., *p*<sub class="lower-index">*n*</sub> (1 ≤ *p*<sub class="lower-index">*i*</sub> ≤ *n*). A permutation is an identity permutation, if for any *i* the following equation holds *p*<sub class="lower-index">*i*</sub> = *i*. 

A swap (*i*, *j*) is the operation that swaps elements *p*<sub class="lower-index">*i*</sub> and *p*<sub class="lower-index">*j*</sub> in the permutation. Let's assume that *f*(*p*) is the minimum number of swaps that you need to make the permutation *p* an identity permutation. 

Valera wonders, how he can transform permutation *p* into any permutation *q*, such that *f*(*q*) = *m*, using the minimum number of swaps. Help him do that.
The first line contains integer *n* (1 ≤ *n* ≤ 3000) — the length of permutation *p*. The second line contains *n* distinct integers *p*<sub class="lower-index">1</sub>, *p*<sub class="lower-index">2</sub>, ..., *p*<sub class="lower-index">*n*</sub> (1 ≤ *p*<sub class="lower-index">*i*</sub> ≤ *n*) — Valera's initial permutation. The last line contains integer *m* (0 ≤ *m* &lt; *n*).
def ID(L):
    x=0
    for i in range(n):
        Pos[L[i]]=i
    for i in range(n):
        if(Pos[i]==i):
            continue
        e=Pos[i]
        q=L[i]
        L[i],L[Pos[i]]=L[Pos[i]],L[i]
        Pos[i],Pos[q]=i,e
        x+=1
    return x
        

n=int(input())

L=list(map(int,input().split()))
Pos=[0]*3001
for i in range(n):
    L[i]-=1
y=ID(list(L))
for i in range(n):
    Pos[L[i]]=i
Ans=[]
m=int(input())
Ans=[]
if(y>m and n!=1):
    e=y-m
    while(e>=1):
        q1=0
        while(L[q1]==q1):
            q1+=1
        q2=q1+1
        while(cont or L[q2]==q2):
            q2+=1
            
        numx=L[q1]
        posx=q1
        numy=L[q2]
        posy=q2
        if(posx==numy):
            e-=1
            Ans.append((posx,posy))
            L[numx]=numx
            Pos[numx]=numx
            L[numy]=numy
            Pos[numy]=numy
        else:
            e-=1
            Ans.append((posx,posy))
            L[numx]=numx
            Pos[numx]=numx
            L[posx]=numy
            Pos[numy]=posx
    
if(y<m and n!=1):
    e=m-y
    #print(L)
    while(e>=1):
        q1=0
        while(L[q1]!=q1):
            q1+=1
        q2=q1+1
        cont=True
        q2=0
        while(1):
            if(q2==q1):
                q2+=1
                continue
            if(L[q2]!=q2 and e>1):
                q2+=1
                continue
            break
        numx=L[q1]
        posx=q1
        numy=L[q2]
        posy=q2
        b=min(posx,posy)
        c=max(posx,posy)
        Ans.append((b,c))
        L[posx],L[posy]=L[posy],L[posx]
        Pos[numx],Pos[numy]=Pos[numy],Pos[numx]
        e-=1
print(len(Ans))
for i in range(len(Ans)):
    print(Ans[i][0]+1,Ans[i][1]+1,end=" ")
        
        
    
