#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;

class solution{
public:
    vector<pair<int,int>>ints;
    bool input(int x){
        if(ints.size()==10) return true;
        string y=to_string(x);
        reverse(y.begin(),y.end());
        int x_reverse=stoi(y);
        ints.push_back({x,x_reverse});
        return false;
    }

    void print(){
        for(pair it:ints){
            cout<<it.first<<" "<<it.second<<endl;
        }
    }
};

int main() {
    int x;
    solution Solution;
    while(cin>>x){
        if(!x || Solution.input(x)){
            Solution.print();
            break;
        }
    }
}