import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList al = new ArrayList<>();
int count = 1;
while (count != 0){
count = sc.nextInt();
al.add(count);
}
for(int i=al.lastIndexOf(count)-1; i>=0; i--){
System.out.print(al.get(i)+" ");
}
}
}



