http://acm.hdu.edu.cn/showproblem.php?pid=1229
#include<iostream>
using namespace std;
bool r(int a,int b,int k){
while(k--){
if(a%10!=b%10){
return false;
}
a/=10;
b/=10;
}
return true;
}
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int a,b,k;
while(cin>>a>>b>>k&&(a!=0||b!=0)){
bool flag=r(a,b,k);
if(flag){
cout<<-1<<endl;
}else{
cout<<a+b<<endl;
}
}
return 0;
}