#include <iostream>
// write your code here......
#include <vector>
using namespace std;

int main() {

    // write your code here......
    vector<int> v;
    for (int i=1;i<=5;i++){
        int is;
        cin >> is;
        v.push_back(is);
    }
    vector<int>::iterator iter;
    for (iter = v.begin(); iter != v.end(); ++iter){
        cout << *iter << " ";
    }
    cout << endl;
    vector<int>::reverse_iterator ater;
    for (ater = v.rbegin(); ater != v.rend(); ++ater){
        cout << *ater << " ";
    }
    cout << endl;

    return 0;
}