import sys while True: b=list(map(int,sys.stdin.readline().split())) if b[-1]==0: b.pop() c=b[::-1] for i in c: print(i,end=' ') break