while True:
try:
A,B,k=input().strip().split()
#print(list(A))
if A!='0' and B!='0':
if k=='0':
print(-1)
else:
A_index=A[-int(k):]
B_index=B[-int(k):]
if int(A_index)!=int(B_index):
print(int(A)+int(B))
else:
print(-1)
except:
break
while True:
try:
a, b, c = input().split()
if a!="0" or b!="0":
if int(a[-int(c):]) == int(b[-int(c):]) or c=="0":
print(-1)
else:
print(int(a)+int(b))
except:
break
try:
while 1:
A, B, K = raw_input().split()
if A == B == '0':
break
K = int(K)
if K == 0:
print -1
elif int(A[-K:]) == int(B[-K:]):
print -1
else:
print int(A) + int(B)
except:
pass