Problem: Anton loves transforming one permutation into another one by swapping elements for money, and Ira doesn't like paying for stupid games. Help them obtain the required permutation by paying as little money as possible.

More formally, we have two permutations, p and s of numbers from 1 to n. We can swap pi and pj, by paying |i - j| coins for it. Find and print the smallest number of coins required to obtain permutation s from permutation p. Also print the sequence of swap operations at which we obtain a solution. 

Input

The first line contains a single number n (1 ≤ n ≤ 2000) — the length of the permutations.

The second line contains a sequence of n numbers from 1 to n — permutation p. Each number from 1 to n occurs exactly once in this line.

The third line contains a sequence of n numbers from 1 to n — permutation s. Each number from 1 to n occurs once in this line.

Output

In the first line print the minimum number of coins that you need to spend to transform permutation p into permutation s.

In the second line print number k (0 ≤ k ≤ 2·106) — the number of operations needed to get the solution.

In the next k lines print the operations. Each line must contain two numbers i and j (1 ≤ i, j ≤ n, i ≠ j), which means that you need to swap pi and pj.

It is guaranteed that the solution exists.

Examples

Input

4
4 2 1 3
3 2 4 1


Output

3
2
4 3
3 1

Note

In the first sample test we swap numbers on positions 3 and 4 and permutation p becomes 4 2 3 1. We pay |3 - 4| = 1 coins for that. On second turn we swap numbers on positions 1 and 3 and get permutation 3241 equal to s. We pay |3 - 1| = 2 coins for that. In total we pay three coins.

Solution (in JAVA):

Solution:
import java.util.*;
import java.io.*;

public class AntonAndIra {

    static class Pair{
        int x;
        int y;
        public Pair(int x, int y){
            this.x = x;
            this.y = y;
        }

        @Override
        public String toString() {
            return "["+x+" "+y+"]";
        }
    }

    public static void main(String[] args) throws IOException {
        FastReader sc = new FastReader();
        PrintWriter pw = new PrintWriter(System.out);

        int n = sc.nextInt();
        int[] p = new int[n];
        int[] q = new int[n];
        int[] desPos = new int[n+1];
        ArrayList<Pair> list = new ArrayList<Pair>();

        for(int i = 0; i<n; i++) p[i] = sc.nextInt();
        for(int i = 0; i<n; i++){
            q[i] = sc.nextInt();
            desPos[q[i]] = i;
        }

        for(int i = n-1; i>=0; i--){
            int curr = i;
            for(int j = i+1; j<=desPos[p[curr]]; j++){
                if(desPos[p[j]] < j){
                    list.add(new Pair(curr+1, j+1));
                    int temp = p[curr];
                    p[curr] = p[j];
                    p[j] = temp;
                    curr = j;
                }
            }
        }
        long cost = 0;
        for(Pair k : list){
            cost += Math.abs(k.x - k.y);
        }
        pw.println(cost);
        pw.println(list.size());
        for(Pair k : list){
            pw.println(k.x + " " + k.y);
        }
        pw.close();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}