#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef long double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 1000010, INF = 0x3f3f3f3f;
int n, m, k;
char str[2][N << 1];
struct data {
  int tp, st;
  bool operator < (const data& a) const {
    if (st != a.st) return st < a.st;
    return tp < a.tp;
  }
};
set<data> st;
set<data> :: iterator it, it2;
vector<data> add, del;
void doit(int las) {
  int res = k-1;
  add.clear(), del.clear();
  for (it = st.begin(); it != st.end(); ++ it) {
    int tp = it -> tp;
    assert(tp != 3);
    if (tp == 0) {
      int len = it->st - las - 1;
      if (res <= len) {
	add.push_back((data) {3, las + res});
	if (las + res > las) add.push_back((data) {0, las + res - 1});
	break;
      } else if (res == len+1) {
	add.push_back((data) {3, it->st});
	if (las + res > las) add.push_back((data) {0, las + res - 1});
	del.push_back(*it);
	break;
      } else {
	res -= len + 2;
	las = it->st + 1;
      }
    } else {
      it2 = it; ++ it2;
      while (it2->tp == it->tp) {
	del.push_back(*it);
	it = it2;
	++ it2;
      }
      int tmp = it2->tp, rec = it->tp;
      if (it->st == las) {
	del.push_back(*it);
	add.push_back((data) {rec ^ 3, las});
      } else {
	int r = it->st;
	del.push_back(*it);
	add.push_back((data) {0, r});
	add.push_back((data) {rec ^ 3, las});
      }
      assert(tmp != 3);
      las = it->st + 1;
      if (tmp == 0) {
	if (it2->st == las) {
	  del.push_back(*it2);
	  add.push_back((data) {rec, las});
	} else add.push_back((data) {rec, las});
	break;
      } else {
	if (res == 0) {
	  if (it2->st == las) {
	    del.push_back(*it2);
	    add.push_back((data) {3, las});
	  } else add.push_back((data) {3, las});
	  break;
	} else {
	  if (it2->st == las) {
	    del.push_back(*it2);
	    add.push_back((data) {0, las});
	  } else add.push_back((data) {0, las});
	  if (it2->st == las) ++ it;
	  las = las + 1;
	  -- res;
	}
      }
    }
  }
  rep (i, 0, (int)add.size()-1) st.insert(add[i]);
  rep (i, 0, (int)del.size()-1) st.erase(del[i]);
}
int main() {
  read(n), read(m), read(k);
  rep (i, 0, 1) scanf("%s", str[i] + 1);
  reverse(str[0] + 1, str[0] + n + 1);
  reverse(str[1] + 1, str[1] + m + 1);
  int l = max(n, m);
  rep (a, 0, 1) rep (i, 1, l) if (str[a][i] == 0) str[a][i] = '0';
  int las = 0;
  st.insert((data) {0, INF});
  rrp (i, l, 1) {
    int tp = (str[0][i] - '0') << 1 | (str[1][i] - '0');
    if (tp == 3) {
      doit(i+1);
      tp = 0;
      las = st.begin()->tp;
    } 
    if (tp != las)
      st.insert((data) {tp, i});
    las = tp;
  }
  int rec = 0, cur = 1;
  for (it = st.begin(); it != st.end(); ++ it)
    if (((it->tp)>>1)&1) rec = it->st;
  for (it = st.begin(); it != st.end(); ++ it) {
    if (it->st <= rec) {
      while (cur <= it->st)
	str[0][cur ++] = '0' + ((it->tp >> 1)&1);
    } else break;
  }
  rrp (i, rec, 1) putchar(str[0][i]);
  puts("");
  rec = 0, cur = 1;
  for (it = st.begin(); it != st.end(); ++ it)
    if (it->tp&1) rec = it->st;
  for (it = st.begin(); it != st.end(); ++ it) {
    if (it->st <= rec) {
      while (cur <= it->st)
	str[1][cur ++] = '0' + (it->tp&1);
    } else break;
  }
  rrp (i, rec, 1) putchar(str[1][i]);
  puts("");
  return 0;
}


Measured memory_bytes: 50688