#include <bits/stdc++.h>
#define ri register int
using namespace std;
typedef double db;
typedef long double ld;
typedef long long ll;
typedef vector <int> poly;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
typedef unsigned long long ulll;
typedef unsigned int uii;
typedef string strr;
#define fi first
#define se second
#define pb push_back
#define ppp pop_back
#define rez resize
const ll Inf = 1e18;
const int rlen = 1 << 20, inf = 0x3f3f3f3f;
char buf[rlen], *ib = buf, *ob = buf;
#define gc() (((ib == ob) && (ob = (ib = buf) + fread(buf, 1, rlen, stdin)), ib == ob) ? -1 : *ib++)
inline int read() {
  static int ans, f;
  static char ch;
  ans = 0, ch = gc(), f = 1;
  while (!isdigit(ch)) f ^= ch == '-', ch = gc();
  while (isdigit(ch)) ans = (ans << 3) + (ans << 1) + (ch ^ 48), ch = gc();
  return f ? ans: -ans;
}
inline ll readl() {
  static ll ans;
  static char ch;
  for (ans = 0, ch = gc(); !isdigit(ch); ch = gc());
  while (isdigit(ch)) ans = ((ans << 2) + ans << 1) + (ch ^ 48), ch = gc();
  return ans;
}
inline int Read(char *s) {
  static int top;
  static char ch;
  top = 0, ch = gc();
  while (!isalpha(ch) && !isdigit(ch)) ch = gc();
  while (isalpha(ch) || isdigit(ch)) s[++top] = ch, ch = gc();
  return top;
}
namespace modular {
  const int mod = 998244353;
  int ret;
  inline int add(int a, int b) { return a + b < mod ? a + b : a + b - mod; }
  inline int dec(int a, int b) { return a < b ? a - b + mod : a - b; }
  inline int mul(int a, int b) { return (ll) a * b % mod; }
  inline void Add(int &a, int b) { a = a + b < mod ? a + b : a + b - mod; }
  inline void Dec(int &a, int b) { a = a < b? a - b + mod : a - b; }
  inline void Mul(int &a, int b) { a = (ll) a * b % mod; }
  inline int ksm(int a, int p) {
    for (ret = 1; p; p >>= 1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1);
    return ret;
  }
  inline int Inv(int a) { return ksm(a, mod - 2); }
  inline int sqr(int a) { return (ll) a * a % mod; }
  inline int cub(int a) { return (ll) a * a % mod * a % mod; }
} using namespace modular;
template <typename T> inline void ckmax(T &a, T b) { a < b ? a = b : 0; }
template <typename T> inline void ckmin(T &a, T b) { a > b ? a = b : 0; }
template <typename T> inline T Abs(T a) { return a < 0 ? -a : a; }
template <typename T> inline T gcd(T a, T b) {
  T t;
  while (b) t = a, a = b, b = t - t / a * a;
  return a;
}
template <typename T> inline void exgcd(T a, T b, T &x, T &y) {
  if (a == 1) {
    x = 1, y = 0;
    return;
  }
  exgcd(b, a % b, y, x);
  y -= a / b * x;
}
const int N = 1e7 + 5;
char s[N], t[N];
int n, m, K, a[N], b[N], pre[N], suf[N], pss[N], tot = 0;
inline void ins(int X, int Y, int c) {
  suf[X] = pre[Y] = c;
  pre[c] = X, suf[c] = Y;
}
inline void del(int c) { pre[suf[c]] = pre[c], suf[pre[c]] = suf[c]; }
inline void check(int tp) {
  if (!pre[tp] || pss[pre[tp]] > pss[tp] || (a[pre[tp]] && b[pre[tp]])) return;
  int bt = pre[tp], _ps = pss[bt], _a = a[bt], _b = b[bt];
  del(tp);
  while (pre[bt] && pss[pre[bt]] == pss[bt] + 1 && a[bt] == a[pre[bt]] && b[bt] == b[pre[bt]]) del(bt), bt = pre[bt];
  if (pre[bt] && pss[pre[bt]] == pss[bt] + 1 && a[bt] != a[pre[bt]] && b[bt] != b[pre[bt]]) {
    pss[pre[bt]] = pss[tp] + pss[pre[bt]] - _ps;
    a[pre[bt]] = b[pre[bt]] = 1;
    a[bt] = _a ^ 1, b[bt] = _b ^ 1, pss[bt] = _ps;
    check(pre[bt]);
  }
  else {
    ++pss[bt];
    ins(bt, suf[bt], ++tot);
    pss[suf[bt]] = _ps;
    a[suf[bt]] = _a ^ 1;
    b[suf[bt]] = _b ^ 1;
  }
}
int main() {
  #ifdef ldxcaicai
  freopen("lx.in", "r", stdin);
  freopen("lx.out", "w", stdout);
  #endif
  n = read(), m = read(), K = read();
  Read(s), Read(t);
  reverse(s + 1, s + n + 1);
  reverse(t + 1, t + m + 1);
  ckmax(n, m), m = 0;
  for (ri i = n, x, y; i; --i) {
    x = s[i] == '1', y = t[i] == '1';
    if (!x && !y) continue;
    ins(pre[0], 0, ++tot);
    pss[pre[0]] = i, a[pre[0]] = x, b[pre[0]] = y;
    if (x && y) pss[pre[0]] += K, check(pre[0]);
  }
  bool ff = 1;
  for (ri ps, i = suf[0]; ; i = suf[i]) {
    if (ff) {
      if (!a[i]) continue;
      ff = 0;
      cout << a[i];
      ps = pss[i] - 1;
      continue;
    }
    while (ps != pss[i]) --ps, cout << 0;
    if (i) cout << a[i], --ps;
    else break;
  }
  cout << '\n';
  ff = 1;
  for (ri ps, i = suf[0]; ; i = suf[i]) {
    if (ff) {
      if (!b[i]) continue;
      ff = 0;
      cout << b[i];
      ps = pss[i] - 1;
      continue;
    }
    while (ps != pss[i]) --ps, cout << 0;
    if (i) cout << b[i], --ps;
    else break;
  }
  return 0;
}

Measured memory_bytes: 52096