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.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.StringTokenizer;

public class E
{
	public static final Random RANDOM = new Random(System.currentTimeMillis());
	private BufferedReader bufferedReader;
	private StringTokenizer stringTokenizer;
	private PrintWriter out;

	public E()
	{
		this(new BufferedReader(new InputStreamReader(System.in)));
	}

	public E(BufferedReader bufferedReader)
	{
		this.bufferedReader = bufferedReader;
		this.stringTokenizer = null;
		this.out = new PrintWriter(new BufferedOutputStream(System.out));
	}

	public E(String file) throws FileNotFoundException
	{
		this(new BufferedReader(new InputStreamReader(new FileInputStream(file))));
	}

	private String next() throws IOException
	{
		while ((this.stringTokenizer == null) || (!this.stringTokenizer.hasMoreTokens()))
		{
			this.stringTokenizer = new StringTokenizer(this.bufferedReader.readLine());
		}
		return stringTokenizer.nextToken();
	}

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

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

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

	public String nextLine() throws IOException
	{
		return this.bufferedReader.readLine();
	}

	public void close()
	{
		out.close();
	}

	public static void main(String[] args)
	{
		E template = new E();
		try
		{
			template.solve();
		}
		catch (IOException exception)
		{
			exception.printStackTrace();
		}
		template.close();
	}

	static Integer largestNotInOrder(int[] x)
	{
		Integer result = null;
		for (int index = 0; index < x.length; index++)
		{
			if (x[index] != index)
			{
				if (result == null || x[result] < x[index])
				{
					result = index;
				}
			}
		}
		return result;
	}

	public static int[] inverse(int[] x)
	{
		int[] result = new int[x.length];
		for (int index = 0; index < x.length; index++)
		{
			result[x[index]] = index;
		}
		return result;
	}

	public static int[] transformation(int[] x, int[] t)
	{
		int[] result = new int[x.length];
		for (int index = 0; index < x.length; index++)
		{
			result[index] = t[x[index]];
		}
		return result;
	}

	public static void print(int[] x)
	{
		for (int index = 0; index < x.length; index++)
		{
			System.out.print(x[index] + 1 + " ");
		}
		System.out.println();
	}

	public static long permutate(int[] ordered, List<Integer> listFrom, List<Integer> listTo)
	{
		long result = 0;
		Integer from = largestNotInOrder(ordered);
		while (from != null)
		{
			for (int to = from + 1; to <= ordered[from]; to++)
			{
				if (ordered[to] <= from)
				{
					listFrom.add(from);
					listTo.add(to);
					result += Math.abs(from - to);
					int swap = ordered[from];
					ordered[from] = ordered[to];
					ordered[to] = swap;
					from = to;
				}
			}
			from = largestNotInOrder(ordered);
		}
		return result;
	}

	public void solve() throws IOException
	{
		int n = nextInt();
		int[] p = new int[n];
		for (int index = 0; index < n; index++)
		{
			p[index] = nextInt() - 1;
		}
		int[] q = new int[n];
		for (int index = 0; index < n; index++)
		{
			q[index] = nextInt() - 1;
		}
		int[] t = inverse(q);
		int[] ordered = transformation(p, t);
		List<Integer> listFrom = new ArrayList<>();
		List<Integer> listTo = new ArrayList<>();
		long coins = permutate(ordered, listFrom, listTo);
		out.println(coins);
		out.println(listFrom.size());
		for (int index = 0; index < listFrom.size(); index++)
		{
			out.println((listFrom.get(index) + 1) + " " + (listTo.get(index) + 1));
		}
	}
}