#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
int N;
vector<pair<int,int> >G[1<<17];
int main()
{
	cin>>N;
	vector<pair<int,int> >X(N),Y(N);
	for(int i=0;i<N;i++)
	{
		int a;cin>>a;
		X[i]=make_pair(a,i);
	}
	for(int i=0;i<N;i++)
	{
		int b;cin>>b;
		Y[i]=make_pair(b,i);
	}
	sort(X.begin(),X.end());
	sort(Y.begin(),Y.end());
	for(int i=1;i<N;i++)
	{
		int u=X[i-1].second,v=X[i].second;
		int c=X[i].first-X[i-1].first;
		G[u].push_back(make_pair(v,c));
		G[v].push_back(make_pair(u,c));
		u=Y[i-1].second,v=Y[i].second;
		c=Y[i].first-Y[i-1].first;
		G[u].push_back(make_pair(v,c));
		G[v].push_back(make_pair(u,c));
	}
	vector<int>d(N,2e9);
	d[0]=0;
	priority_queue<pair<int,int> >P;
	P.push(make_pair(0,0));
	while(!P.empty())
	{
		int u=P.top().second;
		int cost=-P.top().first;
		P.pop();
		if(d[u]<cost)continue;
		for(pair<int,int>p:G[u])
		{
			int v=p.first;
			int nxt=d[u]+p.second;
			if(d[v]>nxt)
			{
				d[v]=nxt;
				P.push(make_pair(-nxt,v));
			}
		}
	}
	for(int i=0;i<N;i++)cout<<d[i]<<endl;
}

