import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        // TODO 自动生成的方法存根
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int k = sc.nextInt();
            if (a == 0 && b == 0)break;
            int x = 1;
            while (k > 0) {
                x = x * 10;
                k--;
            }
            if (a % x == b % x) {
                System.out.println("-1");
            } else
                System.out.println(a + b);
        }
    }
}