from collections import * import sys sys.setrecursionlimit(10**7) from heapq import * def topsort(G): Q = [] count = dict((u, 0) for u in range(len(G))) for u in range(len(G)): for v in G[u]: count[v] += 1 temp = [] for u in range(len(G)): if count[u] == 0: heappush(Q, u) anslst = [] while Q: u = heappop(Q) anslst.append(u) temp = [] for v in G[u]: count[v] -= 1 if count[v] == 0: heappush(Q, v) anslst.reverse() return anslst class UnionFind(object): def __init__(self, n=1): self.par = [i for i in range(n)] self.rank = [0 for _ in range(n)] self.size = [1 for _ in range(n)] def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x != y: if self.rank[x] < self.rank[y]: x, y = y, x if self.rank[x] == self.rank[y]: self.rank[x] += 1 self.par[y] = x self.size[x] += self.size[y] def is_same(self, x, y): return self.find(x) == self.find(y) def get_size(self, x): x = self.find(x) return self.size[x] N = int(input()) X = list(map(int, input().split())) A = list(map(int, input().split())) D = defaultdict(lambda:-1) for i in range(N): D[X[i]] = i T = UnionFind(N) G = [[] for i in range(N)] for i in range(N): if D[X[i] + A[i]] != -1: T.union(i, D[X[i] + A[i]]) G[i].append(D[X[i] + A[i]]) for i in range(N): if D[X[i] - A[i]] != -1: if not T.is_same(i, D[X[i] - A[i]]): G[i].append(D[X[i] - A[i]]) T.union(i, D[X[i] - A[i]]) B = topsort(G) M = [0] * N for i in range(N): M[i] = X[i] + A[i] for b in B: for u in G[b]: M[b] = max(M[u], X[b] + A[b]) for i in range(N): print(M[i] - X[i])