M=10**9+7

f=[1]

for j in range(1,10**6):f+=f[-1]*j%M,

i=[pow(f[-1],M-2,M)]

for j in range(1,10**6)[::-1]:i+=i[-1]*j%M,

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

n,m=divmod(x+y,3)

print(((m<1)*(x*2>=y)*(y*2>=x)*(y-n<=n)*f[n]*i[~n-n+y]*i[~y+n]%M))
M=10**9+7

f=[1]

for j in range(1,10**6):f+=f[-1]*j%M,

i=[pow(f[-1],M-2,M)]

for j in range(1,10**6)[::-1]:i+=i[-1]*j%M,

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

n,m=divmod(x+y,3)

print(((m<1)*(x*2>=y)*(y*2>=x)*f[n]*i[~n-n+y]*i[~y+n]%M))
M = 10**9 + 7
f = [1]
for j in range(1, 10**6):
    f += (f[-1] * j % M,)
i = [pow(f[-1], M - 2, M)]
for j in range(1, 10**6)[::-1]:
    i += (i[-1] * j % M,)
x, y = list(map(int, input().split()))
n, m = divmod(x + y, 3)
print(
    (
        (m < 1)
        * (x * 2 >= y)
        * (y * 2 >= x)
        * (y - n <= n)
        * f[n]
        * i[~n - n + y]
        * i[~y + n]
        % M
    )
)

M = 10**9 + 7
f = [1]
for j in range(1, 10**6):
    f += (f[-1] * j % M,)
i = [pow(f[-1], M - 2, M)]
for j in range(1, 10**6)[::-1]:
    i += (i[-1] * j % M,)
x, y = list(map(int, input().split()))
n, m = divmod(x + y, 3)
print(((m < 1) * (x * 2 >= y) * (y * 2 >= x) * f[n] * i[~n - n + y] * i[~y + n] % M))

-print( -    ( -        (m < 1) -        * (x * 2 >= y) -        * (y * 2 >= x) -        * (y - n <= n) -        * f[n] -        * i[~n - n + y] -        * i[~y + n] -        % M -    ) -) +print(((m < 1) * (x * 2 >= y) * (y * 2 >= x) * f[n] * i[~n - n + y] * i[~y + n] % M))