def ascan; gets.split.map(&:to_i); end a,b = ascan a,b = b,a if a < b c = a-b if (a+b)%c == 0 && (b+c)%a == 0 && (c+a)%b == 0 p c else p -1 end