#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
vector<int> arr;
int n;
while (n != 0) {
cin >> n;
arr.push_back(n);
}
//reverse(arr.begin(), arr.end());
for (int i = arr.size() - 2; i >= 0; i--) {
cout << arr[i] << " ";
}
}