N=int(input())
X=[int(x) for x in input().split()]
Y=[int(x) for x in input().split()]
Ltemp=[]
L=[]
for i in zip(X,Y):
if i!=(-1,-1):
Ltemp.append(i)
else:
L.append(Ltemp)
Ltemp=[]
L.append(Ltemp)
for i in range(1,len(L)-1):
if L[i]:
M=max(L[i],key=lambda x:x[0])
Ma=L[i].index(M)
m=min(L[i],key=lambda x:x[0])
ma=L[i].index(m)
L[i][Ma],L[i][ma]=L[i][ma],L[i][Ma]
for i in range(0,len(L)-1):
for j in range(len(L[i])):
print(L[i][j][1],end=' ')
print(-1,end=' ')
for j in range(len(L[-1])):
print(L[-1][j][1],end=' ')