
#include "iostream"
#include "stdio.h"
#include <vector>
#include <cstring>
#include <algorithm>
#include <string>
#include <string.h>
#include <stack>
using namespace std;
//1015
int a,b,k;
int main(){
//freopen("input.txt","r",stdin);
while(cin>>a>>b>>k){
if(a==0&&b==0) break;
int t=a+b;
int x=0,y=0;
while(k--){
x=x*10+a%10;
a/=10;
y=y*10+b%10;
b/=10;
}
if(x==y) printf("-1\n");
else printf("%d\n",t);
}
return 0;
}
/**************************************************************
Problem: 1015
User: cust123
Language: C++
Result: Accepted
Time:0 ms
Memory:1520 kb
****************************************************************/