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

int main() {

    // write your code here......
    vector<int> v;
    int num;
    for (int i=0;i<5;i++)
    {
        cin>>num;
        v.push_back(num);
    }
    for(vector<int>::iterator it =v.begin();it!=v.end();it++)
    {
        cout<<*it<<" ";
    }
    cout<<"\n";
    for(vector<int>::iterator it =v.end()-1;it!=v.begin()-1;it--)//begin()是v[1] edn()是v[5]
    {
        cout<<*it<<" ";
    }

    return 0;
}