#include <bits/stdc++.h>
// write your code here......

using namespace std;

vector <int> v;

int main() {
    int x;
    for(int i=0;i<5;i++){
        cin>>x;
        v.push_back(x);
    }
    // write your code here......
    
    for(vector<int>::iterator i = v.begin();i!=v.end();i++){
        cout<<*i<<" ";
    }
    puts("");

    for(vector<int>::iterator i = v.end()-1;i!=v.begin()-1;i--){
        cout<<*i<<" ";
    }
    puts("");

    return 0;
}