#include <bits/stdc++.h>
using namespace std;
int read();
int n, m, k, len;
char s[1000006], t[1000006];
int a[2000006];
struct St {
    int type, p;
} st[2000006], tst[2000006];
int top, ttop;
int res[2000006];

void prt() {
    int len = st[1].p;
    while (!res[len]) len--;
    for (int i = len; i >= 0; --i) putchar('0' + res[i]);
    puts("");
}

int main() {
    scanf("%d%d%d%s%s", &n, &m, &k, s, t), len = max(n, m);
    reverse(s, s + n), reverse(t, t + m);
    for (int i = 0; i < len; ++i) a[i] = ((s[i] == '1') << 1) | (t[i] == '1');

    for (int i = len - 1; i >= 0; --i) {
        if (a[i] != 3) {
            if (a[i]) st[++top] = (St){a[i], i};
            continue;
        }
        int tmp = k - 1, tpos = i, x = 3;
        while (1) {
            if (x != 3 && tpos + 1 != st[top].p) {
                tst[++ttop] = (St){x, tpos + 1};
                break;
            }
            if (!top) {
                tst[++ttop] = (St){x, tpos + tmp + 1};
                break;
            }
            if (x == 3) {
                int step = st[top].p - tpos - 1;
                if (step > tmp) {
                    tst[++ttop] = (St){x, tpos + tmp + 1};
                    break;
                } else
                    tmp -= step;
            }
            tpos = st[top].p;
            if ((st[top].type ^ x) == 3) {
                --tmp, --top, x = 3;
            } else {
                int ttype = st[top].type ^ x;
                x = st[top--].type & x, tst[++ttop] = (St){ttype, tpos};
            }
        }
        while (ttop) st[++top] = tst[ttop--];
    }

    st[top + 1].p = -1;
    for (int i = 1; i <= top; ++i) {
        res[st[i].p] = st[i].type >> 1;
        if (res[st[i].p] == -23) {
            cerr << i << ' ' << st[i].p << ' ' << st[i].type << endl;
        }
        for (int j = st[i].p - 1; j > st[i + 1].p; --j) res[j] = 0;
    }
    prt();
    for (int i = 1; i <= top; ++i) {
        res[st[i].p] = st[i].type & 1;
        for (int j = st[i].p - 1; j > st[i + 1].p; --j) res[j] = 0;
    }
    prt();
    return 0;
}
