import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        ArrayList<Integer> list = new ArrayList<>();//数组好

        while (sc.hasNextLine()) {//从控制台获取整数
            int n = sc.nextInt();
            if (n == 0) break;//遇0弹出
            list.add(n);// 添加整数进数组
        }
        Collections.reverse(list);// 反转


        for (Integer i : list) {//加强for循环
            System.out.print(i + " ");
        }
    }
}