#include <bits/stdc++.h>
using namespace std;
class myClass{
    public:
    string s1[10];
    string s2[10];
    int count=0;
};
int main() {
    int n;
    myClass my;
    while(cin>>n){
        if(n == 0 || my.count == 10)break;
        string s = to_string(n);
        my.s1[my.count] = s;
        reverse(s.begin(),s.end());
        n = stoi(s);
        s = to_string(n);
        my.s2[my.count++] = s;
    }
    for(int i =0;i<my.count;i++)
        cout<<my.s1[i]<<" "<<my.s2[i]<<endl;
}
// 64 位输出请用 printf("%lld")

qd