#include <bits/stdc++.h>

using std::pair;
using std::vector;
using std::string;
 
typedef long long ll;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

const int N = 2000000;

typedef vector<pair<int, pii> > stack;

stack ans, tmp;

void Push(stack& a, int x, pii t) {
    if(!a.empty() && a.back().snd == t) {
        a.back().fst += x;
    } else {
        a.pb(mp(x, t));
    }
}

void Pop(stack& a, int x) {
    if(a.back().fst == x) {
        a.pop_back();
    } else {
        a.back().fst -= x;
    }
}

int n, m, k;
char st[N + 5];
int a[N + 5], b[N + 5];

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    read(n); read(m); read(k);
    scanf("%s", st); for(int i = 0; i < n; ++i) a[i] = st[n - i - 1] - '0';
    scanf("%s", st); for(int i = 0; i < m; ++i) b[i] = st[m - i - 1] - '0';

    Push(ans, oo, mp(0, 0));
    for(int i = std::max(n, m) - 1; i >= 0; --i) {
        if(!a[i] || !b[i]) {
            Push(ans, 1, mp(a[i], b[i]));
        } else {
            int z = k;
            bool f = true;
            while (z) {
                int x = ans.back().snd.fst, y = ans.back().snd.snd;

                if(x) {
                    Push(tmp, 1, mp(0, 0));
                    Push(tmp, 1, mp(0, 1));
                    Pop(ans, 1);
                    x = ans.back().snd.fst, y = ans.back().snd.snd;
                    if(x) {
                        Push(tmp, ans.back().fst, mp(0, 0));
                        Pop(ans, ans.back().fst);

                        x = ans.back().snd.fst, y = ans.back().snd.snd;
                    }
                    Pop(ans, 1);
                    if(y) { -- z; } else { f = false; Push(tmp, 1, mp(1, 0)); break; }
                } else if(y) {
                    Push(tmp, 1, mp(0, 0));
                    Push(tmp, 1, mp(1, 0));
                    Pop(ans, 1);
                    x = ans.back().snd.fst, y = ans.back().snd.snd;
                    if(y) {
                        Push(tmp, ans.back().fst, mp(0, 0));
                        Pop(ans, ans.back().fst);

                        x = ans.back().snd.fst, y = ans.back().snd.snd;
                    }
                    Pop(ans, 1);
                    if(x) { -- z; } else { f = false; Push(tmp, 1, mp(0, 1)); break; }
                } else {
                    int t = std::min(z, ans.back().fst);
                    Push(tmp, t, mp(0, 0));
                    Pop(ans, t);
                    z -= t;
                }
            }
            if(f) Push(ans, 1, mp(1, 1));
            while(!tmp.empty()) {
                Push(ans, tmp.back().fst, tmp.back().snd);
                tmp.pop_back();
            }
        }
    }

    for(int i = 0; i < (int) ans.size(); ++i) {
        if(ans[i].snd.fst == 1) {
            for(int j = i; j < (int) ans.size(); ++j) {
                for(int t = 0; t < ans[j].fst; ++t) {
                    putchar(ans[j].snd.fst + '0');
                }
            } break;
        }
    } puts("");
    for(int i = 0; i < (int) ans.size(); ++i) {
        if(ans[i].snd.snd == 1) {
            for(int j = i; j < (int) ans.size(); ++j) {
                for(int t = 0; t < ans[j].fst; ++t) {
                    putchar(ans[j].snd.snd + '0');
                }
            } break;
        }
    } puts("");

    return 0;
}


Measured memory_bytes: 27244