#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iterator>
#include <string>
using namespace std;

string ItoS(int x)
{
    string str="";
    while(x!=0)
    {
        char c = '0' + x%10;
        x/=10;
        str = str +c ;
    }
//    reverse(str.begin(),str.end());
    return str;
}


int main() {
    int A,B,K;
    while(cin>>A>>B>>K)
    {
        if(A==0&&B==0)break;
        int ans = A+B;
        string s1 = ItoS(A);
        string s2 = ItoS(B);
        // cout<<s1<<endl;
        // cout<<s2<<endl;

        int l1 = s1.size(),l2 = s2.size();
        while(l1>l2)
        {
            s2 = s2+'0';
            l2++;
        }
         while(l1<l2)
        {
            s1 = s1+'0';
            l1++;
        }
        // cout<<s1<<endl;
        // cout<<s2<<endl;
        
        if(l1<K){
            cout<<ans<<endl;
        }
        else {
            int flag =0;
            for(int i=0;i<K;i++)
            {
                if(s1[i]!=s2[i])flag=1;
            }
            if(flag)cout<<ans<<endl;
            else cout<<-1<<endl;
        
        }
    }
}
// 64 位输出请用 printf("%lld")