#include<bits/stdc++.h> using namespace std; int main(){ vector<int> a; int temp; while(1){ cin >> temp; if(temp==0){ break; } a.push_back(temp); } for(int i=0; i<(int)a.size(); i++){ cout << a.back() << " "; a.pop_back(); } return 0; }