The Little Elephant has two permutations a and b of length n, consisting of numbers from 1 to n, inclusive. Let's denote the i-th (1 ≤ i ≤ n) element of the permutation a as ai, the j-th (1 ≤ j ≤ n) element of the permutation b — as bj.

The distance between permutations a and b is the minimum absolute value of the difference between the positions of the occurrences of some number in a and in b. More formally, it's such minimum |i - j|, that ai = bj.

A cyclic shift number i (1 ≤ i ≤ n) of permutation b consisting from n elements is a permutation bibi + 1... bnb1b2... bi - 1. Overall a permutation has n cyclic shifts.

The Little Elephant wonders, for all cyclic shifts of permutation b, what is the distance between the cyclic shift and permutation a?

Input

The first line contains a single integer n (1 ≤ n ≤ 105) — the size of the permutations. The second line contains permutation a as n distinct numbers from 1 to n, inclusive. The numbers are separated with single spaces. The third line contains permutation b in the same format.

Output

In n lines print n integers — the answers for cyclic shifts. Print the answers to the shifts in the order of the shifts' numeration in permutation b, that is, first for the 1-st cyclic shift, then for the 2-nd, and so on.

Examples

Input

2
1 2
2 1


Output

1
0


Input

4
2 1 3 4
3 4 2 1


Output

2
1
0
1
import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author George Marcus
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskE {
	public void solve(int testNumber, Scanner in, PrintWriter out) {
        int N = in.nextInt();
        int[] A = new int[N];
        int[] posA = new int[N];
        for(int i = 0; i < N; i++) {
            A[i] = in.nextInt();
            A[i]--;
            posA[A[i]] = i;
        }
        int[] B = new int[N];
        int[] posB = new int[N];
        for(int i = 0; i < N; i++) {
            B[i] = in.nextInt();
            B[i]--;
            posB[B[i]] = i;
        }

        TreeSet<Pair> left = new TreeSet<Pair>();
        TreeSet<Pair> right = new TreeSet<Pair>();
        int[] dist = new int[N];

        for(int i = 0; i < N; i++)
            if(posA[i] <= posB[i])
                right.add(new Pair(posB[i] - posA[i], i));
            else {
                left.add(new Pair(posA[i] - posB[i], i));
                dist[i] = posB[i] - posA[i];
            }

        for(int i = 0; i < N; i++) {
            int ans = Integer.MAX_VALUE;
            if(left.size() > 0)
                ans = Math.min(ans, left.first().val + i);
            if(right.size() > 0)
                ans = Math.min(ans,right.first().val - i);
            out.println(ans);

            while(right.size() > 0 && right.first().val == i) {
                int id = right.first().id;
                right.remove(right.first());
                left.add(new Pair(-i, id));
                dist[id] = -i;
            }

            int id = B[i];
            left.remove(new Pair(dist[id], id));
            right.add(new Pair(N - 1 - posA[id] + i + 1, id));
        }
	}

    private class Pair implements Comparable<Pair> {
        public int val, id;
        Pair(int a, int b) {
            val = a;
            id = b;
        }

        public int compareTo(Pair p) {
            if(val != p.val)
                return val - p.val;
            return id - p.id;
        }
    }
}

