#include<bits/stdc++.h> using namespace std; int main(){ stack<int> b; int a=1; do{ cin>>a; b.push(a); }while(a!=0); while(1){ if(b.size()<0){ break; } cout<<b.top()<<' '; b.pop(); } return 0; }