def cmb(n,r,mod):

    if r<0 or r>n:return 0

    r=min(r,n-r)

    return g1[n]*g2[r]*g2[n-r]%mod





mod=10**9+7

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

g1=[1,1]

g2=[1,1]

inverse=[0,1]



n,m=(2*y-x)//3,(2*x-y)//3

if (x+y)%3!=0 or n<0 or m<0:print((0));exit()



for i in range(2,n+m+1):

    g1.append((g1[-1]*i)%mod)

    inverse.append((-inverse[mod%i]*(mod//i))%mod)

    g2.append((g2[-1]*inverse[-1]%mod))



print((cmb(n+m,n,mod)))
mod=10**9+7

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



X,Y=(2*y-x)//3,(2*x-y)//3

if X<0 or Y<0 or (x+y)%3!=0:print((0));exit()





def cmb(n,r,mod):

    if r<0 or r>n:return 0

    return g1[r]*g2[r]%mod





n=X+Y

k=max(X,Y)

g1=[1,n]

g2=[1,1]

inverse=[0,1]



for i,j in enumerate(range(n-1,((n-k+1)-1),-1)):

    i=i+2

    g1.append((g1[-1]*j)%mod)

    inverse.append((-inverse[mod%i]*(mod//i))%mod)

    g2.append((g2[-1]*inverse[-1]%mod))



print((cmb(n,k,mod)))
def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


mod = 10**9 + 7
x, y = list(map(int, input().split()))
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
n, m = (2 * y - x) // 3, (2 * x - y) // 3
if (x + y) % 3 != 0 or n < 0 or m < 0:
    print((0))
    exit()
for i in range(2, n + m + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1] % mod))
print((cmb(n + m, n, mod)))

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


def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    return g1[r] * g2[r] % mod


n = X + Y
k = max(X, Y)
g1 = [1, n]
g2 = [1, 1]
inverse = [0, 1]
for i, j in enumerate(range(n - 1, ((n - k + 1) - 1), -1)):
    i = i + 2
    g1.append((g1[-1] * j) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1] % mod))
print((cmb(n, k, mod)))

+mod = 10**9 + 7 +x, y = list(map(int, input().split())) +X, Y = (2 * y - x) // 3, (2 * x - y) // 3 +if X < 0 or Y < 0 or (x + y) % 3 != 0: +    print((0)) +    exit() + + -    r = min(r, n - r) -    return g1[n] * g2[r] * g2[n - r] % mod +    return g1[r] * g2[r] % mod -mod = 10**9 + 7 -x, y = list(map(int, input().split())) -g1 = [1, 1] +n = X + Y +k = max(X, Y) +g1 = [1, n] -n, m = (2 * y - x) // 3, (2 * x - y) // 3 -if (x + y) % 3 != 0 or n < 0 or m < 0: -    print((0)) -    exit() -for i in range(2, n + m + 1): -    g1.append((g1[-1] * i) % mod) +for i, j in enumerate(range(n - 1, ((n - k + 1) - 1), -1)): +    i = i + 2 +    g1.append((g1[-1] * j) % mod) -print((cmb(n + m, n, mod))) +print((cmb(n, k, mod)))