#UnionFind from collections import defaultdict class UnionFind(): def __init__(self, n, R): self.n = n self.parents = [-1] * n self.R=R def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x mx=max(self.R[x],self.R[y]) self.R[x],self.R[y]=mx,mx self.parents[x] += self.parents[y] self.parents[y] = x def size(self, x): return -self.parents[self.find(x)] n=int(input()) x=list(map(int,input().split())) a=list(map(int,input().split())) uf=UnionFind(n,[a[i]+x[i] for i in range(n)]) id={} for i in range(n): id[x[i]]=i for i in range(n): xi,ai=x[i],a[i] if xi-ai in id: j=id[xi-ai] uf.union(i,j) if xi+ai in id: j=id[xi+ai] uf.union(i,j) for i in range(n): j=uf.find(i) print(uf.R[j]-x[i])