#include<iostream>
#include<cstdio>
#include<math.h>
#define N 2000005
using namespace std;

int a[N],b[N],k,lena,lenb;

void swap(int &a,int &b){ int c=a; a=b; b=c; }

int main(){
	scanf("%d%d%d",&lena,&lenb,&k);
	char ch; int llen;
	for (int i=1;i<=lena;i++){ cin>>ch; a[i]=ch-'0'; }
	for (int i=1;i<=lenb;i++){ cin>>ch; b[i]=ch-'0'; }
	for (int i=1;i<=lena/2;i++) swap(a[i],a[lena-i+1]); 
	for (int i=1;i<=lenb/2;i++) swap(b[i],b[lenb-i+1]); 
	int len=max(lena,lenb);
	for (int i=len;i>0;i--){
		int s=0,kk=k;
		while (a[i+s]==1&&b[i+s]==1&&kk>0){
			a[i+s]=0; a[i+s+1]++;
			b[i+s]=0; b[i+s+1]++;
			s++; kk--; 
			int sa=s,sb=s;
			while (a[i+sa]==2){ a[i+sa]=0; a[i+sa+1]++; sa++; }
			while (b[i+sb]==2){ b[i+sb]=0; b[i+sb+1]++; sb++; }
			s=max(sa,sb);
		}
		llen=max(llen,s+i);
	}
	int sa=0,sb=0;
	while (!a[llen-sa]) sa++;
	while (!b[llen-sb]) sb++;
	for (int i=llen-sa;i>0;i--) printf("%d",a[i]);
	printf("\n");
	for (int i=llen-sb;i>0;i--) printf("%d",b[i]);
}