#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:255000000 )   bool firstout = 1;   template <class T>   T &minn(T &a, T b) {     if (b < a) a = b;     return a;   }   template <class T>   T &maxx(T &a, T b) {     if (a < b) a = b;     return a;   }   int &madd(int &a, int b) {     a += b;     if (a >= 1000000009) a -= 1000000009;     return a;   }   int &msub(int &a, int b) {     a -= b;     if (a < 0) a += 1000000009;     return a;   }   int &mmult(int &a, int b) { return a = (long long)a * b % 1000000009; }   int mdiv(long long a, long long b, long long m) {     a = (a % m + m) % m;     b = (b % m + m) % m;     if (a % b == 0) return a / b;     return (a + m * mdiv(-a, m, b)) / b;   }   int n, m;   int A[201234];   int B[201234];   int R[201234];   int RR[201234];   int P[201234];   vector<int> O[201234];   vector<int> OO[201234];   void fnd(int *R) {     int i, j, k;     for (i = (0); i < (n); ++i) P[B[i]] = i;     for (i = (0); i < (2 * n); ++i) OO[i].clear(), O[i].clear();     for (i = (0); i < (n); ++i) {       j = P[A[i]];       j = (i - j + n) % n;       O[j].push_back(-j);       OO[j + n - i].push_back(-j);     }     for (i = (0); i < (n); ++i) R[i] = 1012345678;     multiset<int> s;     s.clear();     for (i = (0); i < (2 * n); ++i) {       for (k = (0); k < (O[i].size()); ++k) s.insert(O[i][k]);       for (k = (0); k < (OO[i].size()); ++k) s.erase(s.find(OO[i][k]));       if (s.size()) minn(R[i % n], *s.begin() + i);     }   }   int main() {     int i, j, k;     char c;     int a, d;     int ts;     for (ts = 1; scanf( %                          d ,                        &(n)) > 0;          ++ts) {       for (i = (0); i < (n); ++i)         scanf(              %               d ,             &(A[i])),             --A[i];       for (i = (0); i < (n); ++i)         scanf(              %               d ,             &(B[i])),             --B[i];       fnd(R);       reverse(A, A + n);       reverse(B, B + n);       fnd(RR);       int res = 0;       for (i = (0); i < (n); ++i)         printf(              %               d ,             (min(RR[i], R[(n - i) % n]))),             printf(  n ), firstout = 1;     }     return 0;   }   