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:
/**
 * Created by Andrew on 06.10.2015.
 */

import java.io.*;
import java.util.StringTokenizer;

public class E {

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void solve() throws IOException {
        int n = readInt();
        int[] b = readArr(n);
        int[] a = readArr(n);
        int[] ra = new int[n];
        int[] rb = new int[n];
        for (int i = 0; i < n; i++) {
            ra[a[i]] = i;
            rb[b[i]] = i;
        }

        long res = 0;
        int l = 0;
        int[] from = new int[1000 * 1000 * 2 + 1];
        int[] to = new int[1000 * 1000 * 2 + 1];

        boolean[] used = new boolean[n];
        for (int i = 0; i < n; i++) {
            used[i] = b[i] == a[i];
        }

        for (int i = 0; i < n; i++) {
            int cur = -1;
            for (int j = 0; j < n; j++) {
                if (used[j]) {
                    continue;
                }
                int x = b[j];
                int need = ra[x];
                if (need < j) {
                    cur = j;
                    break;
                }
            }
            if (cur == -1) {
                break;
            }

            int pointer = cur - 1;
            while (!used[cur]) {
                while (used[pointer]) {
                    pointer--;
                }
                res += cur - pointer;
                from[l] = cur + 1;
                to[l] = pointer + 1;
                l++;
                cur = move(b, rb, a, used, cur, pointer);
                pointer = cur - 1;
            }
        }
        out.println(res);
        out.println(l);
        for(int i = 0; i < l; i++) {
            out.println(from[i] + " " + to[i]);
        }
    }

    int move(int[] b, int[] rb, int[] a, boolean[] used, int from, int to) {
        int tmp = b[from];
        b[from] = b[to];
        b[to] = tmp;
        rb[b[from]] = from;
        rb[b[to]] = to;
        used[from] = b[from] == a[from];
        used[to] = b[to] == a[to];
        return to;
    }


    void init() throws FileNotFoundException {
        if (ONLINE_JUDGE) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    int[] readArr(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = readInt() - 1;
        }
        return res;
    }

    long[] readArrL(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = readLong();
        }
        return res;
    }

    public static void main(String[] args) {
        new E().run();
    }

    public void run() {
        try {
            long t1 = System.currentTimeMillis();
            init();
            solve();
            out.close();
            long t2 = System.currentTimeMillis();
            System.err.println("Time = " + (t2 - t1));
        } catch (Exception e) {
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }
}