a=input()
b=[]
c=""
for i in range(len(a)):
if a[i] == " ":
b.append(c)
c=""
else:
c+=a[i]
if i == len(a)-1:
b.append(c)
for i in range(1,len(b)+1):
print(b[-i],end=" ")
a=input()
b=[]
c=""
for i in range(len(a)):
if a[i] == " ":
b.append(c)
c=""
else:
c+=a[i]
if i == len(a)-1:
b.append(c)
for i in range(1,len(b)+1):
print(b[-i],end=" ")