#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

struct FastSet{	//[0,N)
	using ull = unsigned long long;
	int N,D;
	vector<vector<ull>> seg;
	FastSet(int N):N(N){
		while(N>1){
			N = (N+63)>>6;
			seg.pb(vector<ull>(N));
		}
		D = seg.size();
	}
	void insert(int x){
		rep(d,D){
			ull b = 1ull<<(x&63);
			x >>= 6;
			seg[d][x] |= b;
		}
	}
	void erase(int x){	//なくてもよんでいい
		rep(d,D){
			ull b = 1ull<<(x&63);
			x >>= 6;
			seg[d][x] &= ~b;
			if(seg[d][x]) break;
		}
	}
	int geq(int x){		//x<=res
		rep(d,D){
			int i = x>>6, r = x&63;
			if(i == (int)seg[d].size()) break;
			ull b = seg[d][i]>>r;
			if(b){
				x += bsf(b);
				while(d--){
					x = (x<<6)|bsf(seg[d][x]);
				}
				return x;
			}else{
				x = (x>>6)+1;
			}
		}
		return N;
	}
	int leq(int x){		//res<=x
		rep(d,D){
			if(x == -1) break;
			int i = x>>6, r = x&63;
			ull b = seg[d][i]<<(r^63);
			if(b){
				x -= bsr(b)^63;
				while(d--){
					x = (x<<6)|bsr(seg[d][x]);
				}
				return x;
			}
			x = (x>>6)-1;
		}
		return -1;
	}

	int bsr(ull x){return __builtin_clzll(x)^63;}
	int bsf(ull x){return __builtin_ctzll(x);}

};


int main(){
	const int MX = 2000010;
	V<bool> a(MX),b(MX);
	int K;
	{
		int N,M;
		cin>>N>>M>>K;
		string s,t;
		cin>>s>>t;
		rep(i,N) a[N-1-i] = s[i]=='1';
		rep(i,M) b[M-1-i] = t[i]=='1';
	}

	V<int> oo,oofinal;
	rep(i,MX) if(a[i]&&b[i]) oo.pb(i),a[i]=b[i]=false;
	reverse(all(oo));
	FastSet non0(MX);
	rep(i,MX) if(a[i]^b[i]) non0.insert(i);
	for(int x: oo){
		int counter = K;
		while(true){
			int nx = non0.geq(x);
			assert(x != nx);
			if(nx==MX || nx-x>counter){
				oofinal.pb(x + counter);
				break;
			}
			counter -= nx-x;
			int i=nx,j=nx;
			while(a[i]) i++;
			while(b[j]) j++;
			assert((i==nx) ^ (j==nx));
			// show(nx);
			// show(i);
			// show(j);
			if(i>nx){
				for(int k=nx;k<i;k++){
					a[k] = false;
					assert(!b[k]);
					non0.erase(k);
				}
				b[nx] = true;
				non0.insert(nx);

				a[i] = true;
				if(b[i]){
					a[i] = b[i] = false;
					non0.erase(i);
					x = i;
					continue;
				}else{
					non0.insert(i);
					break;
				}
			}else{
				for(int k=nx;k<j;k++){
					b[k] = false;
					assert(!a[k]);
					non0.erase(k);
				}
				a[nx] = true;
				non0.insert(nx);

				b[j] = true;
				if(a[j]){
					a[j] = b[j] = false;
					non0.erase(j);
					x = j;
					continue;
				}else{
					non0.insert(j);
					break;
				}
			}
		}
	}
	for(int x: oofinal) a[x] = b[x] = true;
	auto Answer = [](V<bool>& a){
		bool is = false;
		string s;
		for(int i=(int)a.size()-1;i>=0;i--){
			if(a[i]) is = true;
			if(is) s += '0'+a[i];
		}
		cout<<s<<endl;
	};
	Answer(a);
	Answer(b);
}

Measured memory_bytes: 12980