#include<bits/stdc++.h> using namespace std; int main(){ int n=0,a[n],b; memset(a,0,sizeof(a)); while(true) { n++; cin>>a[n]; if(a[n]==0) { break; } b=n; } for(int i=b;i>=1;i--) { cout<<a[i]<<" "; } return 0; }