#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=1000005*3;
int k,n,m;
int _a[N],_b[N],*a=_a,*b=_b;
void IN(){
	static char s[N],t[N];
	n=read(),m=read(),k=read();
	cin>>(s+1)>>(t+1);
	For(i,1,n)
		a[i]=s[n-i+1]-'0';
	For(i,1,m)
		b[i]=t[m-i+1]-'0';
}
int p[N];
typedef pair <int,pair <int,int> > Node;
struct cmp{
	bool operator () (Node a,Node b){
		if (a.fi!=b.fi)
			return a.fi>b.fi;
		return a.fi>b.fi;
	}
};
priority_queue <Node,vector <Node>,cmp> Q;
int main(){
	IN();
	n=m=max(n,m)*2;
	For(i,1,n)
		if (a[i]&&b[i])
			p[i]=1,a[i]=b[i]=0;
//	outarr(p,1,n);
//	outarr(a,1,n);
//	outarr(b,1,n);
	int las=0;
	For(i,1,n)
		if (a[i]||b[i]||p[i]){
			if (p[las]&&!p[i]){
				Q.push(mp(i-las,mp(las,i)));
//				printf("push(%d,%d,%d)\n",i-las,las,i);
				las=0;
			}
			if (p[i])
				las=i;
		}
	int rev=0;
//	outtag(START);
	while (!Q.empty()){
		Node tmp=Q.top();
		Q.pop();
		if (tmp.fi>k)
			break;
		int now=tmp.fi,x=tmp.se.fi,y=tmp.se.se;
		if (!p[x]||(!a[y]&&!b[y]))
			continue;
//		outval(now),outval(x),outval(y);
//		outtag(ROUND_START);
		if (!a[y])
			rev^=1,swap(a,b);
		int yp=y;
		while (a[yp])
			a[yp++]=0;
//		outtag(PART1_END);
		a[yp]=1;
		b[y]=1;
		p[x]=0;
//		For(i,1,now*2)putchar(' ');outarr(p,1,n);
//		outarr(a,1,n);
//		outarr(b,1,n);
		int yq=y-1;
		while (yq-now>0&&!p[max(yq-now,0)]&&!a[yq]&&!b[yq])
			yq--;
//		assert(yq-now>=0);
//		outtag(MID);
		if (p[yq-now])
//			printf("push1(%d,%d,%d)\n",y-yq+now,yq-now,y),
			Q.push(mp(y-yq+now,mp(yq-now,y)));
		if (a[yp]&&b[yp]){
			p[yp-now]=1;
			a[yp]=b[yp]=0;
			int zp=yp+1;
			while (zp<=n+now&&!p[zp-now]&&!a[zp]&&!b[zp])
				zp++;
			if (a[zp]^b[zp])
//				printf("push2(%d,%d,%d)\n",zp-yp+now,yp-now,zp),
				Q.push(mp(zp-yp+now,mp(yp-now,zp)));
		}
//		outval(now);
//		For(i,1,now*2)putchar(' ');outarr(p,1,n);
//		outarr(a,1,n);
//		outarr(b,1,n);
//		outtag(NEXTROUND);
	}
//	outtag(FINAL);
	if (rev)
		swap(a,b);
	For(i,1,n)
		if (p[i])
			a[i+k]=b[i+k]=1;
	n=m=2e6+3;
	while (!a[n])
		n--;
	while (!b[m])
		m--;
	Fod(i,n,1)
		putchar('0'+a[i]);
	puts("");
	Fod(i,m,1)
		putchar('0'+b[i]);
	puts("");
	return 0;
}