#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; (i) < (int) (n); (i) ++)
using namespace std;

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	string s, t;
	cin >> s >> t;
	reverse(s.begin(), s.end());
	reverse(t.begin(), t.end());
	rep(i, m + k + 5) s.push_back('0');
	rep(i, n + k + 5) t.push_back('0');
	// cerr << "s = " << s << endl;
	// cerr << "t = " << t << endl;
	for (int i = n + m - 1; i >= 0; i --) {
		// cerr << "s = " << s << endl;
		// cerr << "t = " << t << endl;
		if (s[i] == '1' && t[i] == '1') {
			s[i] = '0';
			t[i] = '0';
			s[i + 1] ++;
			t[i + 1] ++;
			int life = k - 1;
			int j = i + 1;
			while (life) {
				if (s[j] == '2') {
					s[j] = '0';
					s[j + 1] ++;
				} else if (t[j] == '2') {
					t[j] = '0';
					t[j + 1] ++;
				} else if (s[j] == '1' && t[j] == '1') {
					life --;
					s[j] = '0';
					t[j] = '0';
					s[j + 1] ++;
					t[j + 1] ++;
				} else {
					break;
				}
				j ++;
			}
			if (s[j] == '2') {
				s[j] = '0';
				s[j + 1] ++;
			}
			if (t[j] == '2') {
				t[j] = '0';
				t[j + 1] ++;
			}
		}
	}
	while (s.back() == '0') s.pop_back();
	while (t.back() == '0') t.pop_back();
	reverse(s.begin(), s.end());
	reverse(t.begin(), t.end());
	cout << s << endl;
	cout << t << endl;
        return 0;
}
