Problem: There are n coins labeled from 1 to n. Initially, coin c_i is on position i and is facing upwards ((c_1, c_2, ..., c_n) is a permutation of numbers from 1 to n). You can do some operations on these coins. 

In one operation, you can do the following:

  * Choose 2 distinct indices i and j.

  * Then, swap the coins on positions i and j.

  * Then, flip both coins on positions i and j. (If they are initially faced up, they will be faced down after the operation and vice versa)




Construct a sequence of at most n+1 operations such that after performing all these operations the coin i will be on position i at the end, facing up.

Note that you do not need to minimize the number of operations.

Input

The first line contains an integer n (3 ≤ n ≤ 2 ⋅ 10^5) — the number of coins.

The second line contains n integers c_1,c_2,...,c_n (1 ≤ c_i ≤ n, c_i ≠ c_j for i≠ j).

Output

In the first line, output an integer q (0 ≤ q ≤ n+1) — the number of operations you used.

In the following q lines, output two integers i and j (1 ≤ i, j ≤ n, i ≠ j) — the positions you chose for the current operation.

Examples

Input


3
2 1 3


Output


3
1 3
3 2
3 1


Input


5
1 2 3 4 5


Output


0

Note

Let coin i facing upwards be denoted as i and coin i facing downwards be denoted as -i.

The series of moves performed in the first sample changes the coins as such:

  * [~~~2,~~~1,~~~3] 
  * [-3,~~~1,-2] 
  * [-3,~~~2,-1] 
  * [~~~1,~~~2,~~~3] 



In the second sample, the coins are already in their correct positions so there is no need to swap.

Solution (in CPP):

Solution:
//我忘不掉夏小姐了。
//如果不是知道了咩粟小姐，说不定我已经对这个世界没有留恋了。
//巫沐小姐真的好可爱啊。做料理的时候笨拙的样子很可爱，故意撒娇，修女小姐也很可爱，唱歌的时候很可爱，生气拍桌子的时候也很可爱。
//所以我离不开星夜小姐了。如果早晨不是有多多小姐的起床闹钟的话，说不定我永远都不愿意睁眼了。如果晚上不是有黎歌小姐的直播预定的话，这一天我都不希望过完了。
//萨摩小姐的眼睛好灵动，如果能映照出我就好了。冷鸢小姐的笑容好温柔，如果只为我一个人绽放就好了。鹿乃小姐的头发好柔顺，如果能让我尽情抚摸就好了。
//白桃小姐这样的存在真的是被允许的吗。
//只是像现在这样默念七海小姐的名字，我就觉得自己是世界上最最最最最幸福的傻子。
#include<bits/stdc++.h>
using namespace std;

int n,c[200005];
vector<pair<int,int>> ans;
bool vis[200005];

void swp(int u,int v){
    tie(c[u],c[v])=make_pair(-c[v],-c[u]);
    ans.emplace_back(u,v);
}

void cycswp(int u,int v){
    swp(u,v);
    int x=u;
    while(c[-c[x]]>0)swp(x,-c[x]);
    x=-c[x];
    while(c[-c[x]]>0)swp(x,-c[x]);
    swp(x,-c[x]);
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=1;i<=n;i++)cin>>c[i];
    int p=-1;
    for(int i=1;i<=n;i++)if(!vis[i]&&c[i]!=i){
        int x=i;
        do vis[x=c[x]]=true;
        while(x!=i);
        if(p==-1)p=i;
        else cycswp(p,i),p=-1;
    }
    if(p!=-1){
        bool f=true;
        for(int i=1;i<=n;i++)if(c[i]==i){
            cycswp(p,i);
            f=false;
            break;
        }
        if(f){
            int x=c[p],y=c[c[p]];
            swp(p,x);
            cycswp(x,y);
        }
    }
    cout<<ans.size()<<'\n';
    for(pair<int,int> &p:ans)cout<<p.first<<' '<<p.second<<'\n';

    return 0;
}