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

int main() {

    vector<int> v;
    int a = 5, i =0;
    v.resize(a);
    while(a--)
        cin >> v[i++];
    vector<int>::iterator it = v.begin();
    while(it != v.end())
    {
        cout << *it << " ";
        it++;
    }
    cout <<endl;
    vector<int>::reverse_iterator it1 = v.rbegin();
    while(it1 != v.rend())
    {
        cout << *it1 << " ";
        it1++;
    }
    cout << endl;

    return 0;
}