#include<stack>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, M, K;
char S[2000011];
char T[2000011];

void show(char *s) {
    int i;
    for (i=2000010; s[i] == 0; i--) ;
    for (; i>=0; i--) putchar(s[i]+'0');
    putchar('\n');
}

void MAIN() {
    scanf("%d%d%d", &N, &M, &K);
    scanf("%s", S);
    scanf("%s", T);
    REP (i, N) S[i] -= '0';
    REP (i, M) T[i] -= '0';

    reverse(S, S+N);
    reverse(T, T+M);

    stack<int> st;

    for (int i=1000011; i--;) {
	VI update;
	if (S[i] == 1 && T[i] == 1) {
	    S[i] = T[i] = 0;
	    int xs = 1, xt = 1;
	    int z = K-1;
	    int j = i+1;
	    while (xs || xt) {
		if (S[j] == 0 && T[j] == 0) {
		    if (xs == 1 && xt == 0) {
			S[j] = 1;
			st.push(j);
			break;
		    } else if (xs == 0 && xt == 1) {
			T[j] = 1;
			st.push(j);
			break;
		    }
		}
		if (st.empty() || st.top() - j > z) {
		    S[j+z] = T[j+z] = 1;
		    break;
		}

		int p = st.top(); st.pop();
		z -= p - j;
		j = p;

		if (S[j] == xs && T[j] == xt) {
		    S[j] = T[j] = 0;
		    j++;
		    continue;
		}

		if (xs == 1 && xt == 1) {
		    xs = S[j];
		    xt = T[j];
		    S[j] ^= 1;
		    T[j] ^= 1;
		    update.push_back(j);
		    j++;
		    continue;
		}

		if (S[j] != xs && T[j] != xt) {
		    if (z == 0) {
			S[j] = T[j] = 1;
			break;
		    } else {
			S[j] = T[j] = 0;
			j++;
			z--;
			xs = xt = 1;
			continue;
		    }
		}

		assert(false);
	    }

	    while (!update.empty()) {
		st.push(update.back());
		update.pop_back();
	    }
	} else if (S[i] || T[i]) {
	    st.push(i);
	}
    }

    show(S);
    show(T);
}

int main() {
    int TC = 1;
    //    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}

