#include <iostream>
#include <cmath> // pow() and log10()
#include <cstring> // memset()
#include <algorithm> // std::min_element() and std::max_element()

using namespace std;

// Problem: http://n...content-available-to-author-only...r.net/Problem/Details/5621

int arr[18]; // Store the binary sequence
long double result[262144]; // (=2^18) Store the possible results of number z
double a, b;
int na, nb, _index = 0, n = 0;
/* a and b is the 2 numbers of input. na is the number of digit of a, nb is the number of
digit of b, _index is the index of array result[], n is the number of elements of result[]*/

void Analyze(int a[])
{
    /* "_na" is used with pow() of base 10 and mod 10 to take the first digit of "a" from
    the left to the right. So is "_nb".
    For instance: a = 584 => na = 3 => _na = 2 => (584 / 10^2) % 10 = 5 is the first digit
    of a from the left to the right.
    */
    int _na = na - 1, _nb = nb - 1, temp = na + nb - 1;
    for (int i = 0; i < (na + nb); ++i) {
        if (a[i] == 0) {
            int digit = static_cast<int>(::a/pow(10.0, (double)_na)) % 10;
            --_na;
            result[_index] += static_cast<double>(digit) * pow(10.0, (double)temp--);
        }
        else {
            int digit = static_cast<int>(::b/pow(10.0, (double)_nb)) % 10;
            --_nb;
            result[_index] += static_cast<double>(digit) * pow(10.0, (double)temp--);
        }
    }
    ++_index; // update the index of result[] for the next assignments.
}

// Backtracking
void ListBinary(int i)
{
    // na + nb is the length of the binary sequence.
    if (i == (na + nb)) {
        /* Count if the number of value 0 in the binary sequence is equal to the length of
        a and the number of value 1 in the binary sequence is equal to the length of b. */
        int zero = 0, one = 0;
        for (int i = 0; i < (na + nb); ++i) {
            if (arr[i] == 0)
                ++zero;
            else ++one;
        }
        /* If the binary sequence is appropriate, then we will use it to create a number
        and put into the result[] */
        if (zero == na && one == nb) {
            ++n;
            Analyze(arr);
        }
    }
    else {
        arr[i] = 0;
        ListBinary(i + 1);
        arr[i] = 1; // backtrack
        ListBinary(i + 1);
    }
}

int main()
{
    memset(result, 0, sizeof(result));
    cin >> a >> b;
    na = (int)log10(a) + 1;
    nb = (int)log10(b) + 1;
    ListBinary(0);
    cout << *min_element(result, result + n) << endl << *max_element(result, result + n);
    return 0;
}
