import sys,random,bisect from collections import deque,defaultdict input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) N = int(input()) X = li() Y = li() M = max(Y) f_inv = [-1] * (M+1) for i in range(N): f_inv[Y[i]] = N * X[i] + i deq = deque([-1]*N) for i in range(M+1)[::-1]: if not deq: exit(print(-1)) v = deq.popleft() if f_inv[i]==-1: f_inv[i] = v else: if v!=-1 and v!=f_inv[i]: exit(print(-1)) elif v==-1: v = f_inv[i] if v==-1: deq.append(v) elif N <= v: deq.append(v-N) if deq: exit(print(-1)) ans = [0] * N for i in range(M+1): if f_inv[i] < N and f_inv[i]!=-1: ans[f_inv[i]] = i print(*ans)