#include <bits/stdc++.h>
using namespace std;

int main() {
    int a[101];
    int len = 0;
    // 先输入再判断,避免使用未初始化的数组元素
    while (len < 100) {  // 限制最大输入数量,防止数组越界
        cin >> a[len];
        if (a[len] == 0) break;  // 遇到0则停止输入
        len++;
    }
    // 逆序输出
    for (int j = len - 1; j >= 0; j--) {
        cout << a[j] << " ";
    }
    return 0;
}