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.PrintWriter;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Stack;
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class E {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.readInt();
        int[] A = new int[n];
        Stack<Integer> last = new Stack<Integer>();
        for (int i = 0; i < n; i++) {
            A[in.readInt() - 1] = i;
        }
        int[] O = new int[n];
        int[] B = new int[n];
        for (int i = 0; i < n; i++) {
            int x = in.readInt() - 1;
            O[i] = x;
            last.push(x);
            B[x] = i;
        }
        int[] ans = new int[n];
        int[] type = new int[n];
        PriorityQueue<cell> before = new PriorityQueue<cell>();
        PriorityQueue<cell> after = new PriorityQueue<cell>();
        LinkedList<Integer>[] shift = new LinkedList[n];
        for (int i = 0; i < n; i++)
            shift[i] = new LinkedList<Integer>();
        for (int i = 0; i < n; i++) {
            if (B[i] <= A[i]) {
                before.add(new cell(i, A[i] - B[i], 0));
                shift[A[i] - B[i]].add(i);
                type[i] = 0;
            } else {
                after.add(new cell(i, B[i] - A[i], 1));
                shift[n - (B[i] - A[i])].add(i);
                type[i] = 1;
            }
        }
        for (int i = 0; i < n; i++) {
            cell bestBefore = new cell(-1, n, -1);
            while (!before.isEmpty()) {
                bestBefore = before.peek();
                if (bestBefore.type == type[bestBefore.value])
                    break;
                before.poll();
            }
            cell bestAfter = new cell(-1, n, -1);
            while (!after.isEmpty()) {
                bestAfter = after.peek();
                if (bestAfter.type == type[bestAfter.value])
                    break;
                after.poll();
            }
            // System.out.println((bestBefore.value + 1) + " "
            // + (bestAfter.value + 1));
            // System.out.println(bestBefore.distance + " " +
            // bestAfter.distance);
            ans[O[(n - i) % n]] = Math.min(bestAfter.distance + i,
                    bestBefore.distance - i);
            for (int x : shift[i]) {
                after.add(new cell(x, -i, 3));
                type[x] = 3;
            }
            int temp = last.pop();
            // System.out.println(temp + "* " + (A[temp] + i + 1));
            before.add(new cell(temp, A[temp] + i + 1, 4));
            type[temp] = 4;
        }
        for (int i = 0; i < n; i++)
            out.println(ans[O[i]]);
        out.flush();
        out.close();
    }
}

class cell implements Comparable<cell> {
    int value;
    int distance;
    int type;

    public cell(int i, int j, int k) {
        value = i;
        distance = j;
        type = k;
    }

    public int compareTo(cell o) {
        return distance - o.distance;
    }
}

class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1000];
    private int curChar, numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    private int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int readInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long readLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public String readString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    private boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private String readLine0() {
        StringBuffer buf = new StringBuffer();
        int c = read();
        while (c != '\n' && c != -1) {
            buf.appendCodePoint(c);
            c = read();
        }
        return buf.toString();
    }

    public String readLine() {
        String s = readLine0();
        while (s.trim().length() == 0)
            s = readLine0();
        return s;
    }

    public String readLine(boolean ignoreEmptyLines) {
        if (ignoreEmptyLines)
            return readLine();
        else
            return readLine0();
    }

    public char readCharacter() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        return (char) c;
    }

    public double readDouble() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E')
                return res * Math.pow(10, readInt());
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, readInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        return res * sgn;
    }
}