#include <iostream> using namespace std; bool is_equal(int a,int b,int k){ int t=1; while(t<=k){ t++; int aa=a%10; a/=10; int bb=b%10; b/=10; if(aa!=bb) return false; } return true; } int main() { int a,b,k; while(cin>>a>>b>>k){ if(a==0&&b==0) break; if(is_equal(a,b,k)) cout<<-1<<endl; else cout<<a+b<<endl; } return 0; }