from collections import * def bfs(G, s, N): Q = deque([]) dist = [-1] * N dist[s] = 0 for u in G[s]: dist[u] = 1 seen[u] = seen[s] Q.append(u) while Q: u = Q.popleft() for v in G[u]: if seen[v] != -1: continue dist[v] = dist[u] + 1 seen[v] = seen[u] Q.append(v) return dist N = int(input()) X = list(map(int, input().split())) A = list(map(int, input().split())) G = [[] for i in range(N)] D = defaultdict(int) for i in range(N): D[X[i]] = i for i in range(N): if X[i] + A[i] in D: G[D[X[i] + A[i]]].append(i) if X[i] - A[i] in D: G[D[X[i] - A[i]]].append(i) seen = [-1] * N L = [] for i in range(N): L.append((X[i] + A[i], i)) L.sort(reverse=True) for d, i in L: if seen[i] != -1: continue seen[i] = d bfs(G, i, N) for i in range(N): print(seen[i] - X[i])