X,Y = list(map(int,input().split()))

if X>Y:

    X,Y = Y,X

if(X+Y)%3:

    print((0))

    exit()

n = (X+Y)//3

if X < n:

    print((0))

    exit()



MOD = 10**9+7

r = X-n



maxn = n+5

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

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

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

for i in range(2,maxn+2):

    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,r)))
X,Y = list(map(int,input().split()))

MOD = 10**9+7



if (X+Y)%3:

    print((0))

    exit()

n = (X+Y)//3

r = X-n

if not 0 <= r <= n:

    print((0))

    exit()



MAXN = r

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

for i in range(2,MAXN+2):

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

def comb(n,r):

    ret = 1

    for i in range(r):

        ret *= n-i

        ret *= inv[i+1]

        ret %= MOD

    return ret



print((comb(n,r)))
X, Y = list(map(int, input().split()))
if X > Y:
    X, Y = Y, X
if (X + Y) % 3:
    print((0))
    exit()
n = (X + Y) // 3
if X < n:
    print((0))
    exit()
MOD = 10**9 + 7
r = X - n
maxn = n + 5
fac = [1, 1] + [0] * maxn
finv = [1, 1] + [0] * maxn
inv = [0, 1] + [0] * maxn
for i in range(2, maxn + 2):
    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, r)))

X, Y = list(map(int, input().split()))
MOD = 10**9 + 7
if (X + Y) % 3:
    print((0))
    exit()
n = (X + Y) // 3
r = X - n
if not 0 <= r <= n:
    print((0))
    exit()
MAXN = r
inv = [0, 1] + [0] * MAXN
for i in range(2, MAXN + 2):
    inv[i] = -inv[MOD % i] * (MOD // i) % MOD


def comb(n, r):
    ret = 1
    for i in range(r):
        ret *= n - i
        ret *= inv[i + 1]
        ret %= MOD
    return ret


print((comb(n, r)))

-if X > Y: -    X, Y = Y, X +MOD = 10**9 + 7 -if X < n: +r = X - n +if not 0 <= r <= n: -MOD = 10**9 + 7 -r = X - n -maxn = n + 5 -fac = [1, 1] + [0] * maxn -finv = [1, 1] + [0] * maxn -inv = [0, 1] + [0] * maxn -for i in range(2, maxn + 2): -    fac[i] = fac[i - 1] * i % MOD +MAXN = r +inv = [0, 1] + [0] * MAXN +for i in range(2, MAXN + 2): -    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 comb(n, r): +    ret = 1 +    for i in range(r): +        ret *= n - i +        ret *= inv[i + 1] +        ret %= MOD +    return ret -print((ncr(n, r))) +print((comb(n, r)))