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.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.TreeSet;
import java.util.StringTokenizer;
import java.io.InputStream;

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

class TaskE {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] posInA = new int[n];
        int[] posInB = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
            posInA[a[i] - 1] = i;
        }
        for (int i = 0; i < n; i++) {
            b[i] = in.nextInt();
            posInB[b[i] - 1] = i;
        }
        int[] initDist = new int[n];
        TreeSet<Pair<Integer, Integer>> negativeDists = new TreeSet<Pair<Integer, Integer>>();
        TreeSet<Pair<Integer, Integer>> positiveDists = new TreeSet<Pair<Integer, Integer>>();
        for (int i = 0; i < n; i++) {
            initDist[i] = posInB[a[i] - 1] - i;
            if (initDist[i] < 0)
                negativeDists.add(Pair.makePair(initDist[i], i));
            else
                positiveDists.add(Pair.makePair(initDist[i], i));
        }
        for (int i = 0; i < n; i++) {
            while (!positiveDists.isEmpty()) {
                Pair<Integer, Integer> first = positiveDists.first();
                if (first.x - i >= 0) break;
                positiveDists.pollFirst();
                negativeDists.add(first);
            }
            int ans = Integer.MAX_VALUE;
            if (!negativeDists.isEmpty())
                ans = Math.min(ans, Math.abs(negativeDists.last().x - i));
            if (!positiveDists.isEmpty())
                ans = Math.min(ans, Math.abs(positiveDists.first().x - i));
            out.println(ans);
            int k = posInA[b[i] - 1];
            Pair<Integer, Integer> oldV = Pair.makePair(initDist[k], k);
            Pair<Integer, Integer> newV = Pair.makePair(initDist[k] + n, k);
            if (negativeDists.remove(oldV)) {
                if (newV.x - i >= 0)
                    positiveDists.add(newV);
                else
                    negativeDists.add(newV);
            } else if (positiveDists.remove(oldV))
                positiveDists.add(newV);
            else throw new RuntimeException();
        }
    }

}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

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

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }
}

class Pair<U, V> implements Comparable<Pair<U, V>> {
    public final U x;
    public final V y;

    public static <U, V> Pair<U, V> makePair(U x, V y) {
        return new Pair<U, V>(x, y);
    }

    private Pair(U x, V y) {
        this.x = x;
        this.y = y;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return !(x != null ? !x.equals(pair.x) : pair.x != null) && !(y != null ? !y.equals(pair.y) : pair.y != null);
    }

    public int hashCode() {
        int result = x != null ? x.hashCode() : 0;
        result = 31 * result + (y != null ? y.hashCode() : 0);
        return result;
    }

    public String toString() {
        return "(" + x + "," + y + ")";
    }

    public int compareTo(Pair<U, V> o) {
        int value = ((Comparable<U>) x).compareTo(o.x);
        if (value != 0)
            return value;
        return ((Comparable<V>) y).compareTo(o.y);
    }
}
