x, y = list(map(int, input().split()))

mod = 10**9 + 7

if (x + y) % 3 != 0:

    print((0))

    exit()

n = (x + y) // 3

a = (2 * y - x) // 3

b = (2 * x - y) // 3

if a == 0 or b == 0:

    print((1))

    exit()

if a < 0 or b < 0:

    print((0))

    exit()

MAX = 700000

fac = [1, 1] + [0] * MAX

finv = [1, 1] + [0] * MAX

inv = [0, 1] + [0] * MAX

for i in range(2, MAX):

    fac[i] = fac[i - 1] * i % mod

    inv[i] = -inv[mod % i] * (mod // i) % mod

    finv[i] = finv[i - 1] * inv[i] % mod





def nCr(n, r):

    if n < r:

        return 0

    if n < 0 or r < 0:

        return 0

    return fac[n] * (finv[r] * finv[n - r] % mod) % mod





print((nCr(n, a)))

x, y = list(map(int, input().split()))

mod = 10**9 + 7

if (x + y) % 3:

    print((0))

    exit()

n = (x + y) // 3

a = (2 * y - x) // 3

b = (2 * x - y) // 3

if a < 0 or b < 0:

    print((0))

    exit()

if a == 0 or b == 0:

    print((1))

    exit()





def neko(n, r):

    p, q = 1, 1

    for i in range(r):

        p = p * (n - i) % mod

        q = q * (i + 1) % mod

    return p * pow(q, mod - 2, mod) % mod





print((neko(n, a)))

x, y = list(map(int, input().split()))
mod = 10**9 + 7
if (x + y) % 3 != 0:
    print((0))
    exit()
n = (x + y) // 3
a = (2 * y - x) // 3
b = (2 * x - y) // 3
if a == 0 or b == 0:
    print((1))
    exit()
if a < 0 or b < 0:
    print((0))
    exit()
MAX = 700000
fac = [1, 1] + [0] * MAX
finv = [1, 1] + [0] * MAX
inv = [0, 1] + [0] * MAX
for i in range(2, MAX):
    fac[i] = fac[i - 1] * i % mod
    inv[i] = -inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod


def nCr(n, r):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod


print((nCr(n, a)))

x, y = list(map(int, input().split()))
mod = 10**9 + 7
if (x + y) % 3:
    print((0))
    exit()
n = (x + y) // 3
a = (2 * y - x) // 3
b = (2 * x - y) // 3
if a < 0 or b < 0:
    print((0))
    exit()
if a == 0 or b == 0:
    print((1))
    exit()


def neko(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p * (n - i) % mod
        q = q * (i + 1) % mod
    return p * pow(q, mod - 2, mod) % mod


print((neko(n, a)))

-if (x + y) % 3 != 0: +if (x + y) % 3: +if a < 0 or b < 0: +    print((0)) +    exit() -if a < 0 or b < 0: -    print((0)) -    exit() -MAX = 700000 -fac = [1, 1] + [0] * MAX -finv = [1, 1] + [0] * MAX -inv = [0, 1] + [0] * MAX -for i in range(2, MAX): -    fac[i] = fac[i - 1] * i % mod -    inv[i] = -inv[mod % i] * (mod // i) % mod -    finv[i] = finv[i - 1] * inv[i] % mod -def nCr(n, r): -    if n < r: -        return 0 -    if n < 0 or r < 0: -        return 0 -    return fac[n] * (finv[r] * finv[n - r] % mod) % mod +def neko(n, r): +    p, q = 1, 1 +    for i in range(r): +        p = p * (n - i) % mod +        q = q * (i + 1) % mod +    return p * pow(q, mod - 2, mod) % mod -print((nCr(n, a))) +print((neko(n, a)))