#include <iostream>
using namespace std;

int main() {
    int a, b,k;
    while (cin >> a >> b>>k) { // 注意 while 处理多个 case
        if(a==0&&b==0)return 0;
        string aStr =to_string(a),bStr=to_string(b);
        if(k==0){
            cout<<-1<<endl;
            continue;
        }
        while(aStr.length()>k)
            aStr = aStr.substr(1);
        while(bStr.length()>k)
            bStr = bStr.substr(1);
        // cout<<stoi(aStr)<<"+++"<<stoi(bStr)<<endl;
        if(stoi(aStr)==stoi(bStr))cout<<-1<<endl;
        else cout<<a+b<<endl;
    }
}
// 64 位输出请用 printf("%lld")