#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

const int N = 1000005;
const int inf = 0x3f3f3f3f;

stack <pair <int, pii>> cur, tmp;
char s[N], t[N];
int n, m, k;

inline void Push(stack <pair <int, pii>> &s, int x, pii p) {
  if (!s.empty() && s.top().Y == p) {
    s.top().X += x;
  } else {
    s.push(mp(x, p));
  }
}

inline void Pop(stack <pair <int, pii>> &s, int x) {
  if (s.top().X == x) {
    s.pop();
  } else {
    s.top().X -= x;
  }
}

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  Read(n), Read(m), Read(k);
  int p = max(n, m);
  scanf("%s%s", s + 1, t + 1);
  reverse(s + 1, s + n + 1);
  reverse(t + 1, t + m + 1);
  for (int i = 1; i <= n; ++i) {
    s[i] -= '0';
  }
  for (int i = 1; i <= m; ++i) {
    t[i] -= '0';
  }
  Push(cur, inf, mp(0, 0));
  for (int i = p; i; --i) {
    if (s[i] && t[i]) {
      int z = k;
      bool f = true;
      while (z) {
        int x = cur.top().Y.X, y = cur.top().Y.Y;
        if (x) {
          Push(tmp, 1, mp(0, 0));
          Push(tmp, 1, mp(0, 1));
          Pop(cur, 1);
          x = cur.top().Y.X, y = cur.top().Y.Y;
          if (x) {
            Push(tmp, cur.top().X, mp(0, 0));
            Pop(cur, cur.top().X);
            x = cur.top().Y.X, y = cur.top().Y.Y;
          }
          Pop(cur, 1);
          if (y) {
            --z;
          } else {
            Push(tmp, 1, mp(1, 0));
            f = false;
            break;
          }
        } else if (y) {
          Push(tmp, 1, mp(0, 0));
          Push(tmp, 1, mp(1, 0));
          Pop(cur, 1);
          x = cur.top().Y.X, y = cur.top().Y.Y;
          if (y) {
            Push(tmp, cur.top().X, mp(0, 0));
            Pop(cur, cur.top().X);
            x = cur.top().Y.X, y = cur.top().Y.Y;
          }
          Pop(cur, 1);
          if (x) {
            --z;
          } else {
            Push(tmp, 1, mp(0, 1));
            f = false;
            break;
          }
        } else {
          int t = min(cur.top().X, z);
          Push(tmp, t, mp(0, 0));
          Pop(cur, t);
          z -= t;
        }
      }
      if (f) {
        Push(cur, 1, mp(1, 1));
      }
      while (!tmp.empty()) {
        Push(cur, tmp.top().X, tmp.top().Y);
        tmp.pop();
      }
    } else {
      Push(cur, 1, mp(s[i], t[i]));
    }
  }
  vector <pair <int, pii>> v;
  while (!cur.empty()) {
    v.pb(cur.top()), cur.pop();
  }
  reverse(v.begin(), v.end());
  for (int i = 0; i < v.size(); ++i) {
    if (v[i].Y.X) {
      for (int j = i; j < v.size(); ++j) {
        for (int k = 0; k < v[j].X; ++k) {
          putchar(v[j].Y.X + '0');
        }
      }
      putchar(10);
      break;
    }
  }
  for (int i = 0; i < v.size(); ++i) {
    if (v[i].Y.Y) {
      for (int j = i; j < v.size(); ++j) {
        for (int k = 0; k < v[j].X; ++k) {
          putchar(v[j].Y.Y + '0');
        }
      }
      putchar(10);
      break;
    }
  }
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


Measured memory_bytes: 27208