#include <bits/stdc++.h>
using namespace std;
int main() {
  auto read_deque = [&](int n) {
    deque<int> vec(n);
    for (int& x : vec) {
      scanf("%d", &x);
      --x;
    }
    return vec;
  };
  int n;
  scanf("%d", &n);
  deque<int> A = read_deque(n);
  deque<int> B = read_deque(n);
  vector<int> posA(n), posB(n);
  for (int i = 0; i < n; i++) posA[A[i]] = i;
  for (int i = 0; i < n; i++) posB[B[i]] = i;
  vector<int> dist(n);
  set<pair<int, int>> inc, dec;
  for (int i = 0; i < n; i++) {
    int diff = posB[i] - posA[i];
    if (diff >= 0)
      dec.insert({diff, i});
    else {
      inc.insert({-diff, i});
      dist[i] = -diff;
    }
  }
  for (int shift = 0; shift < n; shift++) {
    int res = dec.begin()->first - shift;
    if (inc.size()) res = min(res, inc.begin()->first + shift);
    printf("%d\n", res);
    while (dec.size() && dec.begin()->first == shift) {
      inc.insert({-shift, dec.begin()->second});
      dist[dec.begin()->second] = -shift;
      dec.erase(dec.begin());
    }
    if (inc.count({dist[B[0]], B[0]})) inc.erase({dist[B[0]], B[0]});
    dec.insert({n - posA[B[0]] + shift, B[0]});
    B.push_back(B[0]);
    B.pop_front();
  }
  return 0;
}
