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