#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int a, b;

    cin >> a >> b;
    vector<int> resenje;

    int a1, b1;

    while(a > 0 && b > 0)
    {
        a1 = a % 10;
        b1 = b % 10;

        if(a1 == b1)
        {
            resenje.push_back(a1);
            resenje.push_back(b1);
        }
        else if(a1 > b1)
            resenje.push_back(a1);
        else if(a1 < b1)
            resenje.push_back(b1);

        a /= 10;
        b /= 10;
    }

    while(a > 0)
    {
        a1 = a % 10;
        resenje.push_back(a1);
        a /= 10;
    }
    while(b > 0)
    {
        b1 = b % 10;
        resenje.push_back(b1);
        b /= 10;
    }

    for(int i = resenje.size() - 1; i >= 0; i--)
        cout << resenje[i];
    
    cout << endl;

    cout << a << " " << b;
}