#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(ll i=int(x);i<int(y);++i)
#define For(i,x,y)  for(ll i=int(x);i<=int(y);++i)
#define FOr(i,x,y)  for(ll i=int(x);i>=int(y);--i)
#define pi acos(-1) 
#define mk make_pair
#define pa pair<ll,ll>
#define lf else if
#define IL inline
#define sqr(x)      ((x)*(x))
#define Mul(x,y)    ((x)=1LL*(x)*(y)%mod)
#define Add(x,y)    ((x)=((x)+(y))%mod)
#define E(x)        return writeln(x),0
#define LL          (long long)
#define p(x)        printf("~%lld~\n",LL(x))
#define pp(x,y)     printf("~~%lld %lld~~\n",LL(x),LL(y))
#define ppp(x,y,z)  printf("~~~%lld %lld %lld~~~\n",LL(x),LL(y),LL(z))
#define pppp(a,b,c,d)   printf("~~~%lld %lld %lld %lld\n",LL(a),LL(b),LL(c),LL(d))
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
#define GuYue       puts("\nGuYueNa________________________________________________________________________________")
#define y1          fafa____
typedef complex<double> E;
namespace SHENZHEBEI{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_; 
#endif 
#define NEG 1
    static const int GYN=2333333;
    char SZB[GYN],*SSS=SZB,*TTT=SZB;
    inline char gc(){   if (SSS==TTT){  TTT=(SSS=SZB)+fread(SZB,1,GYN,stdin); if (SSS==TTT) return '\n';  }   return *SSS++;    }
#define gc getchar
#if NEG
    inline ll read(){    ll x=0,g=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') g=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*g; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
    void Print(long long *a,int s,int t){For(i,s,t)printf("%lld ",a[i]);puts("");}
    void Print(int *a,int s,int t){For(i,s,t)printf("%d ",a[i]);puts("");}
    void Print(char *a,int s,int t){For(i,s,t)putchar(a[i]);puts("");}
    void writeln(ll x){write(x),puts("");}
    void Max(ll &x,ll y){x=x<y?y:x;}
    ll max(ll x,ll y){return x<y?y:x;}
}using namespace SHENZHEBEI;
const ll N=2001000;
ll a[N],b[N],lena,lenb,len,lenl,k;
int main(){
	lena=read();	lenb=read();	k=read();
	For(i,1,lena)a[lena-i+1]=readchar()-'0';
	For(i,1,lenb)b[lenb-i+1]=readchar()-'0';
	len=max(lena,lenb);
	FOr(i,len,1){
		ll w=0,tim=0;
		for(;a[i+w]==1&&b[i+w]==1&&tim<k;){
			a[i+w]=0;b[i+w]=0;
			++w;++tim;
			++a[i+w];++b[i+w];
			ll w1=w,w2=w;
			for(;a[i+w1]==2;)a[i+w1]=0,++a[i+(++w1)];
			for(;b[i+w2]==2;)b[i+w2]=0,++b[i+(++w2)];
			w=max(w1,w2);
		}
		Max(lenl,i+w);
	}ll s1=lenl,s2=lenl;
	for(;!a[s1];--s1);
	for(;!b[s2];--s2);
	FOr(i,s1,1)write(a[i]);puts("");
	FOr(i,s2,1)write(b[i]);puts("");
}
/*
从高位到低位处理
依次考虑初始第i位在时刻j对i+j位置的贡献。
如果遇到(1,0),(0,1),(0,0)则这一位没有用,只能靠更低位的进位,因此跳过处理更低位置。
如果遇到(1,1),则可以进位。
*/


Measured memory_bytes: 36864