#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(!b.empty()){ b.pop(); cout<<b.top()<<' '; } return 0; }