a, b = map(int, input().split()) if a == 0: exit(print(b if b % 2 else b + 1)) if b == 0: exit(print(a if a % 2 else a + 1)) p = (a + b) * 2 s = a * b * 2 print((p + (s - p // 2 + 1)) % (10 ** 9 + 7))