#include<stdlib.h>
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<stack>
#include<map>
#include<set>
#include<string>
#include<string.h>
#include<math.h>
#include<vector>
using namespace std;
typedef long long LL;
const int MAXN=1e5+10;
map<string,int>xudong;
int main(){
int a,b,k;
while(cin>>a>>b>>k){
if(a==0&&b==0)break;
string s1=to_string(a);
string s2=to_string(b);
if(s1.size()<k){
int cha=k-s1.size();
for(int i=0;i<cha;i++)s1='0'+s1;
}
if(s2.size()<k){
int cha=k-s2.size();
for(int i=0;i<cha;i++)s2='0'+s2;
}
// cout<<s1<<' '<<s2;
reverse(s1.begin(),s1.end());
reverse(s2.begin(),s2.end());
bool flag=true;
for(int i=0;i<k;i++){
if(s1[i]!=s2[i]){
flag=false;
break;
}
}
if(flag==true)cout<<-1<<endl;
else cout<<a+b<<endl;
}
return 0;
}