#include <deque>
#include <algorithm>
#include <cassert>
#include <iostream>
using namespace std;

void calc_and(const string &s, const string &t, string &u) {
    for (int i = 0; i < int(s.size()) && i < int(t.size()); i++)
        if (s[i] == '1' && t[i] == '1') u[i] = '1';
        else u[i] = '0';
}

void add(string &s, const string &t) {
    int c = 0;
    s.resize(max(s.size(), t.size()), '0');
    for (int i = 0; i < int(s.size()); i++) {
        int x = c + (s[i] == '1') + (t[i] == '1');
        s[i] = x % 2 == 1 ? '1' : '0';
        c = x / 2;
    }
    if (c == 1) s.push_back('1');
}

pair<string, string> bruteforce(int n, int m, int k, const string &s, const string &t) {
    string s1 = s, t1 = t, buf;
    reverse(s1.begin(), s1.end());
    reverse(t1.begin(), t1.end());
    s1.resize(max(n, m) + k, '0');
    t1.resize(max(n, m) + k, '0');
    buf.resize(max(n, m) + k, '0');
    while (k--) {
        calc_and(s1, t1, buf);
        add(s1, buf);
        add(t1, buf);
        // cerr << s1 << " " << t1 << " " << buf << endl;
    }
    while (s1.back() == '0') s1.pop_back();
    while (t1.back() == '0') t1.pop_back();
    reverse(s1.begin(), s1.end());
    reverse(t1.begin(), t1.end());
    return make_pair(s1, t1);
}

void update(deque<int> &a, deque<int> &b, deque<int> &c,
            deque<int> &a1, deque<int> &b1, deque<int> &c1,
            char &x, char &y, int lb)
{
    // assert (x == '0' || y == '0');
    // if (!c.empty()) {
    //     assert(a.size() <= 1);
    //     assert(b.size() <= 1);
    // }
    // for (int i = 1; i < a.size(); i++) assert (a[i-1] < a[i]);
    // for (int i = 1; i < b.size(); i++) assert (b[i-1] < b[i]);
    // for (int i = 1; i < c.size(); i++) assert (c[i-1] < c[i]);
    
    if (x == '1') {
        if (!a.empty() || !b.empty()) {
            int A = a.empty() ? -1 : a.back(),
                B = b.empty() ? -1 : b.back();
            if (A == B) {
                assert (c.empty());
                a1.push_front(a.back() + 1);
                a.pop_back();
                A = a.empty() ? -1 : a.back();
                b.pop_back();
                // cerr << "a = "; for (int x : a) cerr << x << ' '; cerr << endl;
                // cerr << "b = "; for (int x : b) cerr << x << ' '; cerr << endl;
                if (!b.empty() && b.back() >= A) {
                    b1.push_front(b.back() + 1);
                    b.pop_back();
                    for (int x : b) c1.push_back(x);
                    if (a.size() == b.size()) x = '0';
                } else {
                    for (int x : a) c1.push_back(x);
                    x = '0';
                    if (a.size() <= b.size()) y = '1';
                    // cerr << "a1 = "; for (int x : a1) cerr << x << ' '; cerr << endl;
                    // cerr << "b1 = "; for (int x : b1) cerr << x << ' '; cerr << endl;
                    // cerr << "c1 = "; for (int x : c1) cerr << x << ' '; cerr << endl;
                    // cerr << "lb = " << lb << endl;
                }
            } else if (A > B) {
                assert(a.size() >= b.size());
                a.pop_back();
                a1.push_front(A+1);
                if (a.size() < b.size()) {
                    if (c.empty()) {
                        for (int x : a) c1.push_back(x);
                        x = '0'; y = '1';
                    } else {
                        assert(a.empty());
                        assert(b.size() == 1);
                        x = '0'; y = '1';
                        for (int i = c.size() - 1; i >= 0; i--) {
                            if (x == '1') a1.push_front(c[i] + 1);
                            else b1.push_front(c[i] + 1);
                            swap(x, y);
                        }
                    }
                } else {
                    assert(a.size() == b.size());
                    swap(c, c1);
                    for (int x : a) c1.push_back(x);
                    x = y = '0';
                }
            } else {
                if (a.size() == b.size()) {
                    if (c.empty()) {
                        for (int x : b) c1.push_back(x);
                    } else {
                        assert(a.size() == 1);
                        assert(b.size() == 1);
                        a1.push_back(B);
                        b1.push_back(B);
                        x = '1'; y = '0';
                        for (int i = c.size() - 1; i >= 0; i--) {
                            if (x == '1') a1.push_front(c[i] + 1);
                            else b1.push_front(c[i] + 1);
                            swap(x, y);
                        }
                    }
                } else {
                    assert(a.size() + 1 == b.size());
                    swap(c, c1);
                    for (int x : b) c1.push_back(x);
                    x = y = '0';
                }
            }
        } else {
            for (int i = c.size() - 1; i >= 0; i--) {
                if (x == '1') a1.push_front(c[i]+1);
                else b1.push_front(c[i]+1);
                swap(x, y);
            }
        }
    } else if (y == '1') {
        update(b, a, c, b1, a1, c1, y, x, lb);
        return;
    } else {
        if (a.size() == b.size() || c.empty()) {
            swap(c, c1);
            const int len = min(a.size(), b.size()),
                oa = a.size() - len,
                ob = b.size() - len;
            for (int i = 0; i < len; i++) c1.push_back(min(a[oa + i], b[ob + i]));
            if (a.size() > b.size()) x = '1';
            else if (a.size() < b.size()) y = '1';
        } else {
            if (a.size() > 0) {
                assert(b.empty());
                assert(a.size() == 1);
                x = '1';
            } else {
                assert(a.empty());
                assert(b.size() == 1);
                y = '1';
            }
            for (int i = c.size() - 1; i >= 0; i--) {
                if (x == '1') a1.push_front(c[i] + 1);
                else b1.push_front(c[i] + 1);
                swap(x, y);
            }
        }
    }
    if (!a1.empty() && a1.front() < lb) {
        a1.pop_front();
        x ^= 1;
    }
    if (!b1.empty() && b1.front() < lb) {
        b1.pop_front();
        y ^= 1;
    }
    if (!c1.empty() && c1.front() < lb) {
        c1.pop_front();
        x ^= 1;
        y ^= 1;
    }
}

pair<string, string> solve1(int n, int m, int k, const string &s1, const string &t1) {
    string s = s1, t = t1;
    reverse(s.begin(), s.end());
    reverse(t.begin(), t.end());
    s.resize(max(n, m) + k, '0');
    t.resize(max(n, m) + k, '0');
    deque<int> a[2], b[2], c[2];
    int cur = 0, prev = 1;
    for (int i = 0; i < max(n, m) + k; i++) {
        swap(cur, prev);
        a[cur].clear();
        b[cur].clear();
        c[cur].clear();
        // cerr << "i = " << i << " " << s[i] << " " << t[i] << endl;
        bool carry = false;
        if (s[i] == '1' && t[i] == '1') {
            s[i] = t[i] = '0';
            carry = true;
        }
        update(a[prev], b[prev], c[prev], a[cur], b[cur], c[cur], s[i], t[i], i - k + 1);
        if (carry) {
            if (a[cur].empty() && b[cur].empty()) c[cur].push_back(i);
            else { a[cur].push_back(i); b[cur].push_back(i); }
        }
        // for (int x : c[cur]) cerr << x << " "; cerr << endl;
        // for (int x : a[cur]) cerr << x << " "; cerr << endl;
        // for (int x : b[cur]) cerr << x << " "; cerr << endl;
        // cerr << "==> " << s[i] << " " << t[i] << endl;
    }
    while (s.back() == '0') s.pop_back();
    while (t.back() == '0') t.pop_back();
    reverse(s.begin(), s.end());
    reverse(t.begin(), t.end());
    return make_pair(s, t);
}

int main() {
    int n, m, k; cin >> n >> m >> k;
    string s, t; cin >> s >> t;
    const auto &[s1, t1] = solve1(n, m, k, s, t);
    cout << s1 << endl << t1 << endl;
    // const auto &[s2, t2] = bruteforce(n, m, k, s, t);
    // cout << s2 << endl << t2 << endl;
    // assert (s1 == s2);
    // assert (t1 == t2);
}


Measured memory_bytes: 12748