//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int nax=1007*1007;
using pii=pair<int,int>;
const int inf=1e9;

int n, m, k;

char wcz[nax];

vector <int> raz, dwa;

vector <int> pozr, pozd;

void opierdol(int v, int p, int a, int b)
{
	//~ debug() << "opierdalam " << v << " " << p << " " << a << " " << b;
	int x=(pozr.back()==v);
	int y=(pozd.back()==v);
	if (a && b)
		assert(!x || !y);
	if (a && x)
	{
		pozr.pop_back();
		if (y)
		{
			pozd.pop_back();
			b=1;
		}
		opierdol(v+1, p, 1, 0);
		if (b)
			pozd.push_back(v);
		return;
	}
	if (b && y)
	{
		pozd.pop_back();
		if (x)
		{
			pozr.pop_back();
			a=1;
		}
		opierdol(v+1, p, 0, 1);
		if (a)
			pozr.push_back(v);
		return;
	}
	if (x)
	{
		a=1;
		pozr.pop_back();
	}
	if (y)
	{
		b=1;
		pozd.pop_back();
	}
	if (!a || !b)
	{
		if (a)
			pozr.push_back(v);
		if (b)
			pozd.push_back(v);
		return;
	}
	int dys=v+p;
	dys=min(dys, pozr.back());
	dys=min(dys, pozd.back());
	if (dys==v)
	{
		pozr.push_back(v);
		pozd.push_back(v);
		return;
	}
	opierdol(dys, p-(dys-v), 1, 1);
}

void wypisz(const vector <int> &setel)
{
	//~ setel.erase(inf);
	int naj=0;
	for (int i : setel)
		if (i!=inf)
			naj=max(naj, i);
	vector <int> wyn(naj+1, 0);
	for (int i : setel)
		if (i!=inf)
			wyn[i]=1;
	reverse(wyn.begin(), wyn.end());
	for (int i : wyn)
		printf("%d", i);
	printf("\n");
}

int main()
{
	scanf("%d%d%d", &n, &m, &k);
	scanf("%s", wcz);
	for (int i=0; i<n; i++)
		raz.push_back(wcz[i]-'0');
	scanf("%s", wcz);
	for (int i=0; i<m; i++)
		dwa.push_back(wcz[i]-'0');
	reverse(raz.begin(), raz.end());
	reverse(dwa.begin(), dwa.end());
	n=max(n, m);
	raz.resize(n, 0);
	dwa.resize(n, 0);
	//~ debug() << raz;
	//~ debug() << dwa;
	pozr.push_back(inf);
	pozd.push_back(inf);
	for (int i=n-1; i>=0; i--)
	{
		opierdol(i, k, raz[i], dwa[i]);
		//~ debug() << "po " << i << " " << pozr << " " << pozd;
	}
	
	wypisz(pozr);
	wypisz(pozd);
	
	//~ wypisz(raz);
	//~ wypisz(dwa);
	return 0;
}


Measured memory_bytes: 27876