#include <bits/stdc++.h>
using namespace std;

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

const int Nmax=2000010;

struct Hog{
	Hog* nx,*pr;
	int ng,pg;
};
Hog hogBuf[Nmax*2];
Hog* hogIdx[Nmax*2];
int hogUsed;
void InitHogBuf(){
	REP(i,Nmax*2)
		hogIdx[i]=hogBuf+i;
	hogUsed=0;
}
Hog* newNode(){
	auto ptr=hogIdx[hogUsed++];
	ptr->nx=nullptr;
	ptr->pr=nullptr;
	ptr->ng=ptr->pg=0;
	return ptr;
}
void Recycle(Hog*ptr){
	hogIdx[--hogUsed]=ptr;
}
void Link(Hog*a,Hog*b,int gap){
	if(a){
		a->nx=b;
		a->ng=gap;
	}
	if(b){
		b->pr=a;
		b->pg=gap;
	}
}

struct Node{
	int type,left,right;
	Hog* he,*ta;
	bool popFront(){
		Recycle(he);
		if(he==ta)return false;
		Hog*x=he;
		left+=x->ng;
		he=x->nx;
		he->pr=nullptr;
		he->pg=0;
		return true;
	}
	bool popBack(){
		Recycle(ta);
		if(he==ta)return false;
		Hog*x=ta;
		right-=x->pg;
		ta=x->pr;
		ta->nx=nullptr;
		ta->ng=0;
		return true;
	}
};

struct Rng{
	vector<Node> buf;
	int head;
	void Init(){
		head=0;
		buf.clear();
	}
	bool empty(){
		return head==int(buf.size());
	}
	pi getFront(){
		return pi(buf[head].type,buf[head].left);
	}
	void popFront(){
		if(!buf[head].popFront())
			head++;
	}
	Node getNode(){
		return buf[head];
	}
	void popNode(){
		head++;
	}
	void push(int t,int pos){
		if(t==0)return;
		if(t==3&&!buf.empty()&&buf.back().type==3){
			Node& w=buf.back();
			Hog* x=newNode();
			Link(w.ta,x,pos-w.right);
			w.ta=x;
			w.right=pos;
		}else{
			Hog* x=newNode();
			Node w{t,pos,pos,x,x};
			buf.PB(w);
		}
	}
	void pushNode(Node y){
		if(y.type==3&&!buf.empty()&&buf.back().type==3){
			Node& w=buf.back();
			Link(w.ta,y.he,y.left-w.right);
			w.ta=y.ta;
			w.right=y.right;
		}else{
			buf.PB(y);
		}
	}
	void Clean(int k){
		while(!buf.empty()&&buf.back().right>=k)
			if(!buf.back().popBack())buf.pop_back();
	}
	void Show(){
		for(auto nd:buf){
			Hog*x=nd.he;
			int pos=nd.left;
			while(x){
				cerr<<pi(nd.type,pos)<<endl;
				pos+=x->ng;
				x=x->nx;
			}
		}
	}
};

signed main(){
	InitHogBuf();
	int n=read(),m=read(),k=read();
	string s=readString(),t=readString();
	int bot=0;
	Rng cur,nx;
	cur.Init();
	nx.Init();
	string ans1,ans2;
	while(bot<max(n,m)||!cur.empty()){
		nx.Init();
		int w=0;
		if(bot<n){
			w+=((s[n-1-bot]-'0')<<1);
		}
		if(bot<m){
			w+=(t[m-1-bot]-'0');
		}
		cerr<<w<<endl;
		//cur.Show();
		int pos=0;
		while(!cur.empty()){
			while(!cur.empty()&&!((w==0||w==3)&&cur.getFront().first==3)){
				cerr<<endl;
				if(w==3){
					nx.push(3,pos);
					w=0;
					continue;
				}
				cerr<<endl;
				pi f=cur.getFront();
				cerr<<endl;
				int ty=f.first,p=f.second;
				cur.popFront();
				nx.push(w&ty,p);
				w=w^ty;
				pos=p+1;
			}
			if(!cur.empty()){
				cerr<<endl;
				if(w==3){
					nx.push(3,pos);
				}
				Node x=cur.getNode();
				cur.popNode();
				x.left++;
				x.right++;
				pos=x.right;
				if(!x.popBack()){
					
				}else{
					nx.pushNode(x);
				}
				w=3;
			}
		}
		cerr<<endl;
		if(pos<k&&w==3){
			nx.push(3,pos);
			w=0;
		}
		cerr<<endl;
		ans1.PB(char('0'+((w>>1)&1)));
		ans2.PB(char('0'+(w&1)));
		nx.Clean(k);
		swap(nx,cur);
		bot++;
	}
	while(ans1.back()=='0')ans1.pop_back();
	reverse(ALL(ans1));
	while(ans2.back()=='0')ans2.pop_back();
	reverse(ALL(ans2));
	printf("%s\n",ans1.c_str());
	printf("%s\n",ans2.c_str());
}


Measured memory_bytes: 47324