#include<iostream>
#include<cstdio>
#include<algorithm>

char a[3000000],b[3000000];
int x,y,k;

void go(int S,int dis){
	for (int i=S+1;i<=S+dis;i++)
		if (a[i]||b[i]){
			a[i]++;b[i]++;
			a[S]=0;b[S]=0;
			int I=i+1,J=i+1;
			if (a[i]==2){
				while (a[I]){a[I]=0;I++;}
				a[i]=0;a[I]=1;
			}
			if (b[i]==2){
				while (b[J]){b[J]=0;J++;}
				b[i]=0;b[J]=1;
			}
			if (a[I]&b[I]) go(I,dis-i+S);
			if (a[J]&b[J]) go(J,dis-i+S);
			return;
		}
	a[S+dis]++;b[S+dis]++;
	a[S]--;b[S]--;
}

int main(){
	scanf("%d%d%d",&x,&y,&k);
	scanf("%s%s",a,b);
	for (int i=0;i<x;i++){a[i]-='0';}
	for (int i=0;i<y;i++){b[i]-='0';}
	std::reverse(a,a+x);std::reverse(b,b+y);
	for (int i=std::max(x-1,y-1);i>=0;i--) if (a[i]&b[i]) go(i,k);
	int I=2999999;while (!a[I]) I--;I++;while (I--) printf("%d",a[I]);printf("\n");
	int J=2999999;while (!b[J]) J--;J++;while (J--) printf("%d",b[J]);printf("\n");
}