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:

    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





r = min(a, b)

print((neko(n, r)))

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:
    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


r = min(a, b)
print((neko(n, r)))

-print((neko(n, a))) +r = min(a, b) +print((neko(n, r)))