#include<iostream>
using namespace std;
int main() {long long s[100] = { 0 };int i = 0;while (1) {cin >> s[i];if (s[i]==0) {break;}i++;}for (i; i >= 0;i--) {if(s[i]!=0)cout << s[i] << " ";}return 0;
}
#include<iostream>
using namespace std;
int main() {long long s[100] = { 0 };int i = 0;while (1) {cin >> s[i];if (s[i]==0) {break;}i++;}for (i; i >= 0;i--) {if(s[i]!=0)cout << s[i] << " ";}return 0;
}