/*
TASK: phrope
LANG: C++
*/

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string t1, t2;

bool f(string& t) {
	int s = t[t.length()-1]-'0';
	return ( s == 0 || s == 2 || s == 4 || s == 6 || s == 8 );
}

string div2(string num) {
	string t = num;
	int pr=0;
	for(int i = 0; i < num.length(); ++i) {
		t[i] = (num[i]-'0')/2+'0'+pr;
		pr = (num[i]-'0')%2;
	}
	return t;
}

string m2(string num) {
	string t="";
	int pr=0;
	for(int i = num.length()-1; i >= 0; --i) {
		int s = (num[i]-'0')*2+pr; pr = s>9;
		s = s%10;
		t += s+'0';
	}
	if( pr ) t += '1';
	reverse(t.begin(), t.end());	
	return t;		
}

bool cmp(string t1, string t2) {
	if( t1.length() < t2.length() ) return false;
	if( t1.length() > t2.length() ) return true;
	for(int i = 0; i < t1.length(); ++i) {
		if( t1[i] < t2[i] ) return false;
		if( t1[i] > t2[i] ) return true; 
	}
	return true;
}

int main() {

	cin >> t1 >> t2;

	if( !f(t1) && !f(t2) ) { cout << "0 0\n"; return 0; }	bool r; 
	string rez; 
	if( f(t1) ) {
		rez = div2(t1);
		if( !cmp(rez, t2) )
			cout << t1 << ' ' << rez << '\n';	
		else cout << m2(t2) << ' ' << t2 << '\n';
	}

	else {
		rez = div2(t2);
		if( cmp(rez, t1) )
			cout << rez << ' ' << t2 << '\n';
		else cout << t1 << ' ' << m2(t1) << '\n';
	}  

	return 0;
}