Snuke is standing on a two-dimensional plane. In one operation, he can move by 1 in the positive x-direction, or move by 1 in the positive y-direction.
Let us define a function f(r, c) as follows:
 - f(r,c) :=  (The number of paths from the point (0, 0) to the point (r, c) that Snuke can trace by repeating the operation above)
Given are integers r_1, r_2, c_1, and c_2.
Find the sum of f(i, j) over all pair of integers (i, j) such that r_1 ≤ i ≤ r_2 and c_1 ≤ j ≤ c_2, and compute this value modulo (10^9+7).

-----Constraints-----
 - 1 ≤ r_1 ≤ r_2 ≤ 10^6
 - 1 ≤ c_1 ≤ c_2 ≤ 10^6
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
r_1 c_1 r_2 c_2

-----Output-----
Print the sum of f(i, j) modulo (10^9+7).

-----Sample Input-----
1 1 2 2

-----Sample Output-----
14

For example, there are two paths from the point (0, 0) to the point (1, 1): (0,0) → (0,1) → (1,1) and (0,0) → (1,0) → (1,1), so f(1,1)=2.
Similarly, f(1,2)=3, f(2,1)=3, and f(2,2)=6. Thus, the sum is 14.

Difficulty: MEDIUM_HARD

Solutions:
(r1, c1, r2, c2) = map(int, input().split())
MOD = 10 ** 9 + 7

def factorial(n, mod=10 ** 9 + 7):
	a = 1
	for i in range(1, n + 1):
		a = a * i % mod
	return a

def power(n, r, mod=10 ** 9 + 7):
	if r == 0:
		return 1
	if r % 2 == 0:
		return power(n * n % mod, r // 2, mod) % mod
	if r % 2 == 1:
		return n * power(n, r - 1, mod) % mod

def comb(n, k, mod=10 ** 9 + 7):
	if n < k or k < 0:
		result = 0
	else:
		a = factorial(n, mod=mod)
		b = factorial(k, mod=mod)
		c = factorial(n - k, mod=mod)
		result = a * power(b, mod - 2, mod=mod) * power(c, mod - 2, mod=mod) % mod
	return result

def g(r, c):
	return comb(c + r + 2, r + 1) - 1
ans = g(r2, c2) - g(r2, c1 - 1) - g(r1 - 1, c2) + g(r1 - 1, c1 - 1)
ans %= MOD
print(ans)


(r1, c1, r2, c2) = map(int, input().split())
MOD = 10 ** 9 + 7
MAXN = r2 + c2 + 5
fac = [1, 1] + [0] * MAXN
for i in range(2, MAXN + 2):
	fac[i] = fac[i - 1] * i % MOD

def inv(n):
	return pow(n, MOD - 2, MOD)

def comb(n, r):
	if n < r:
		return 0
	if n < 0 or r < 0:
		return 0
	return fac[n] * inv(fac[r]) * inv(fac[n - r]) % MOD
(r2, c2) = (r2 + 1, c2 + 1)
ans = comb(r2 + c2, r2) - comb(r2 + c1, r2) - comb(r1 + c2, r1) + comb(r1 + c1, r1)
ans %= MOD
print(ans)


def mod_inverse(n, mod=10 ** 9 + 7):
	return pow(n, mod - 2, mod)

def combination(n, k, mod=10 ** 9 + 7):
	numer = denom = 1
	for i in range(k):
		numer = numer * (n - i) % mod
		denom = denom * (i + 1) % mod
	return numer * mod_inverse(denom, mod) % mod
mod = 10 ** 9 + 7
(r1, c1, r2, c2) = list(map(int, input().split()))
ans = combination(r1 + c1, r1) - combination(1 + r2 + c1, 1 + r2) - combination(1 + r1 + c2, r1) + combination(2 + r2 + c2, 1 + r2)
print(ans % mod)


MOD = 10 ** 9 + 7

def nCr(n, r, mod=MOD):
	r = min(r, n - r)
	numer = denom = 1
	for i in range(1, r + 1):
		numer = numer * (n + 1 - i) % mod
		denom = denom * i % mod
	return numer * pow(denom, mod - 2, mod) % mod

def g(r, c):
	return nCr(r + c + 2, r + 1) - 1
(r1, c1, r2, c2) = list(map(int, input().split()))
r1 -= 1
c1 -= 1
ans = g(r2, c2)
ans -= g(r1, c2)
ans -= g(r2, c1)
ans += g(r1, c1)
ans += MOD * 2
ans %= MOD
print(ans)


mod = 10 ** 9 + 7
f = [1] * (2 * 10 ** 6 + 5)
f[0] = 1
for i in range(1, 2 * 10 ** 6 + 4):
	f[i] = f[i - 1] * i % mod

def inv(i):
	return pow(f[i], mod - 2, mod)

def g(x, y):
	return f[x + y] * inv(x) * inv(y) % mod
(r1, c1, r2, c2) = map(int, input().split(' '))
ans = g(r2 + 1, c2 + 1) - g(r2 + 1, c1) - g(r1, c2 + 1) + g(r1, c1)
print(ans % mod)


(r1, c1, r2, c2) = list(map(int, input().split()))
mod = int(1000000000.0 + 7)

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

def init_cmb(Nmax):
	g1 = [1, 1]
	g2 = [1, 1]
	inverse = [0, 1]
	for i in range(2, Nmax + 1):
		g1.append(g1[-1] * i % mod)
		inverse.append(-inverse[mod % i] * (mod // i) % mod)
		g2.append(g2[-1] * inverse[-1] % mod)
	return (g1, g2)
(g1, g2) = init_cmb(max(r1, r2) + max(c1, c2) + 10)

def solve(r1, c1, r2, c2):

	def f(r, c):
		return cmb(r + c, min(r, c))
	res = 0
	(r2, c2) = (r2, c2)
	res += f(r2, c2)
	res -= f(r2, c1)
	res -= f(r1, c2)
	res += f(r1, c1)
	return res % mod

def solve2(r1, c1, r2, c2):
	res = 0
	for r in range(r1, r2 + 1):
		for c in range(c1, c2 + 1):
			res += cmb(c + r, c)
			res %= mod
	return res
print(solve(r1, c1, r2 + 1, c2 + 1))


(r1, c1, r2, c2) = map(int, input().split())
mod = 10 ** 9 + 7
n = [1] * (r2 + c2 + 3)
for i in range(r2 + c2 + 2):
	n[i + 1] = n[i] * (i + 1) % mod

def g(a, b):
	(x, y, z) = (n[a + b], n[a], n[b])
	return x * pow(y, mod - 2, mod) % mod * pow(z, mod - 2, mod) % mod
print((g(r2 + 1, c2 + 1) - g(r2 + 1, c1) - g(r1, c2 + 1) + g(r1, c1)) % mod)


(r1, c1, r2, c2) = map(int, input().split())
n = 2 * max(r1, r2, c1, c2) + 2
mod = 10 ** 9 + 7
factorial = [1]
for i in range(1, n + 1):
	factorial.append(factorial[-1] * i % mod)
inv_factorial = [-1] * (n + 1)
inv_factorial[-1] = pow(factorial[-1], mod - 2, mod)
for i in reversed(range(n)):
	inv_factorial[i] = inv_factorial[i + 1] * (i + 1) % mod

def fact(n):
	return factorial[n]

def nck(n, k):
	if k > n or k < 0:
		return 0
	else:
		return factorial[n] * inv_factorial[n - k] * inv_factorial[k]

def routes(r, c):
	return nck(r + c + 2, c + 1) - 1
ans = routes(r2, c2) - routes(r2, c1 - 1) - routes(c2, r1 - 1) + routes(r1 - 1, c1 - 1)
ans %= mod
print(ans)


import copy

def prepare(n, MOD):
	f = 1
	factorials = [1]
	for m in range(1, n + 1):
		f *= m
		f %= MOD
		factorials.append(f)
	inv = pow(f, MOD - 2, MOD)
	invs = [1] * (n + 1)
	invs[n] = inv
	for m in range(n, 1, -1):
		inv *= m
		inv %= MOD
		invs[m - 1] = inv
	return (factorials, invs)

def func(r, c):
	return f[r + 1 + c + 1] * i[r + 1] % MOD * i[c + 1] % MOD
MOD = 10 ** 9 + 7
(f, i) = prepare(2 * 10 ** 6 + 2, MOD)
(r1, c1, r2, c2) = map(int, input().split())
combi = func(r2, c2) - func(r2, c1 - 1) - func(r1 - 1, c2) + func(r1 - 1, c1 - 1)
print(combi % MOD)


import sys
MOD = 10 ** 9 + 7

def make_table(size=2 * 10 ** 6 + 2, p=MOD):
	fac = [None] * (size + 1)
	fac[0] = 1
	for i in range(size):
		fac[i + 1] = fac[i] * (i + 1) % p
	ifac = [None] * (size + 1)
	ifac[size] = pow(fac[size], p - 2, p)
	for i in range(size, 0, -1):
		ifac[i - 1] = ifac[i] * i % p
	return (fac, ifac)
(fac, ifac) = make_table()

def comb(n, r, mod=MOD):
	if r > n or r < 0:
		return 0
	return fac[n] * ifac[r] % mod * ifac[n - r] % mod

def g(y, x):
	return comb(y + x + 2, y + 1) - 1
(r1, c1, r2, c2) = map(int, sys.stdin.readline().split())

def main():
	ans = (g(r2, c2) - (g(r1 - 1, c2) + g(r2, c1 - 1) - g(r1 - 1, c1 - 1))) % MOD
	return ans

def __starting_point():
	ans = main()
	print(ans)
__starting_point()


(r1, c1, r2, c2) = map(int, input().split())
MOD = 10 ** 9 + 7
ans = 0

class Factorial:

	def __init__(self, n, mod):
		self.f = [1]
		self.mod = mod
		for j in range(1, n + 1):
			self.f.append(self.f[-1] * j % mod)
		self.i = [pow(self.f[-1], mod - 2, mod)]
		for j in range(n, 0, -1):
			self.i.append(self.i[-1] * j % mod)
		self.i.reverse()

	def factorial(self, j):
		return self.f[j]

	def ifactorial(self, j):
		return self.i[j]

	def comb(self, n, k):
		return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0
F = Factorial(r2 + c2 + 3, MOD)
ans = F.comb(c1 + r1, c1) - F.comb(c1 + r2 + 1, c1) - F.comb(c2 + r1 + 1, c2 + 1) + F.comb(c2 + r2 + 2, c2 + 1)
print(ans % MOD)


(r1, c1, r2, c2) = map(int, input().split())
MOD = 10 ** 9 + 7
N = r2 + c2 + 10
fact = [0 for _ in range(N)]
invfact = [0 for _ in range(N)]
fact[0] = 1
for i in range(1, N):
	fact[i] = fact[i - 1] * i % MOD
invfact[N - 1] = pow(fact[N - 1], MOD - 2, MOD)
for i in range(N - 2, -1, -1):
	invfact[i] = invfact[i + 1] * (i + 1) % MOD

def nCk(n, k):
	if k < 0 or n < k:
		return 0
	else:
		return fact[n] * invfact[k] * invfact[n - k] % MOD
ans = nCk(r2 + c2 + 2, r2 + 1) - nCk(r2 + c1 + 1, r2 + 1) - nCk(r1 + c2 + 1, c2 + 1) + nCk(r1 + c1, r1)
print(ans % MOD)


import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)
(r1, c1, r2, c2) = list(map(int, input().split()))

def cumprod(arr, MOD):
	L = len(arr)
	Lsq = int(L ** 0.5 + 1)
	arr = np.resize(arr, Lsq ** 2).reshape(Lsq, Lsq)
	for n in range(1, Lsq):
		arr[:, n] *= arr[:, n - 1]
		arr[:, n] %= MOD
	for n in range(1, Lsq):
		arr[n] *= arr[n - 1, -1]
		arr[n] %= MOD
	return arr.ravel()[:L]

def make_fact(U, MOD):
	x = np.arange(U, dtype=np.int64)
	x[0] = 1
	fact = cumprod(x, MOD)
	x = np.arange(U, 0, -1, dtype=np.int64)
	x[0] = pow(int(fact[-1]), MOD - 2, MOD)
	fact_inv = cumprod(x, MOD)[::-1]
	return (fact, fact_inv)
MOD = 10 ** 9 + 7
U = 10 ** 6 * 2 + 10
(fact, fact_inv) = make_fact(U, MOD)

def mod_comb_k(n, k, mod):
	return fact[n] * fact_inv[k] % mod * fact_inv[n - k] % mod

def calc_rc(r, c):
	a = mod_comb_k(r + c + 2, r + 1, MOD)
	b = 1
	return a - b
ans = calc_rc(r2, c2) + calc_rc(r1 - 1, c1 - 1) - calc_rc(r1 - 1, c2) - calc_rc(r2, c1 - 1)
ans %= MOD
print(ans)


(r, c, R, C) = [int(_) for _ in input().split()]
mod = 10 ** 9 + 7
f = [1] * (2 * 10 ** 6 + 10)
for i in range(1, 2 * 10 ** 6 + 10):
	f[i] = i * f[i - 1] % mod

def comb(x, y):
	return f[x] * pow(f[y], mod - 2, mod) * pow(f[x - y], mod - 2, mod)
print((comb(C + R + 2, R + 1) - comb(c + R + 1, R + 1) - comb(C + r + 1, r) + comb(c + r, r)) % mod)


def main():
	M = 10 ** 9 + 7
	(r1, c1, r2, c2) = map(int, input().split())
	n = r2 + c2 + 2
	fac = [1]
	val = 1
	append = fac.append
	for i in range(1, n + 1):
		val = val * i % M
		append(val)
	f = lambda r, c: fac[r + c + 2] * pow(fac[c + 1], M - 2, M) * pow(fac[r + 1], M - 2, M) - c - r - 2
	print((f(r2, c2) - f(r2, c1 - 1) - f(r1 - 1, c2) + f(r1 - 1, c1 - 1)) % M)
main()


def mod_combination(n, k, mod=10 ** 9 + 7):

	def extended_gcd(a, b):
		if b == 0:
			return (a, 1, 0)
		(d, x, y) = extended_gcd(b, a % b)
		return (d, y, x - a // b * y)
	(p, q) = (1, 1)
	for i in range(n - k + 1, n + 1):
		p = p * i % mod
	for i in range(2, k + 1):
		q = q * i % mod
	return p * (extended_gcd(q, mod)[1] % mod) % mod
mod = 10 ** 9 + 7
(r1, c1, r2, c2) = map(int, input().split())

def f(i, j):
	return mod_combination(i + j, i)
print((f(r2 + 1, c2 + 1) - f(r2 + 1, c1) - f(r1, c2 + 1) + f(r1, c1)) % mod)


import sys
import socket
hostname = socket.gethostname()
if hostname == 'F451C':
	sys.stdin = open('f1.in')

def read_int_list():
	return list(map(int, input().split()))

def read_str_list():
	return input().split()

def read_int():
	return int(input())

def read_str():
	return input()
M = 10 ** 9 + 7
f = [1] * (2 * 10 ** 6 + 4)
for i in range(1, 2 * 10 ** 6 + 3):
	f[i] = f[i - 1] * i
	f[i] %= M

def g(r, s):
	res = 1
	frs = f[r + s + 2]
	fs = f[s + 1]
	fr = f[r + 1]
	res *= pow(fr, M - 2, M)
	res *= pow(fs, M - 2, M)
	res *= frs
	res %= M
	return res

def main():
	(r1, c1, r2, c2) = read_int_list()
	res = 0
	res += g(r2, c2) - g(r2, c1 - 1) - g(r1 - 1, c2) + g(r1 - 1, c1 - 1)
	res %= M
	print(res)
main()


(r1, c1, r2, c2) = map(int, input().split())
mod = 10 ** 9 + 7

def p_mod(m, n, p):
	a = 1
	for i in range(n):
		a = a * (m - i) % p
	return a

def c_mod(m, n, p):
	return p_mod(m, n, p) * pow(p_mod(n, n, p), p - 2, p) % p
print((c_mod(r2 + c2 + 2, r2 + 1, mod) - c_mod(r1 + c2 + 1, r1, mod) - c_mod(r2 + c1 + 1, c1, mod) + c_mod(r1 + c1, r1, mod)) % mod)


MOD = 10 ** 9 + 7
(r1, c1, r2, c2) = list(map(int, input().split()))
size = 1010000 * 2
f_list = [1] * size
for i in range(1, size):
	f_list[i] = f_list[i - 1] * i % MOD

def func(r, c):
	return f_list[r + c] * pow(f_list[r], MOD - 2, MOD) * pow(f_list[c], MOD - 2, MOD)
ans = func(r2 + 1, c2 + 1) - 1
ans += func(r1, c1) - 1
ans -= func(r2 + 1, c1) - 1
ans -= func(r1, c2 + 1) - 1
print(ans % MOD)


from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl = lambda : list(map(int, input().split()))
inm = lambda : map(int, input().split())
ins = lambda : input().strip()
DBG = True
BIG = 999999999
R = 10 ** 9 + 7

def ddprint(x):
	if DBG:
		print(x)

def modinv2(x, r):
	return pow(x, r - 2, r)

def f(r, c):
	d = c
	prod = 1
	div = 1
	divacc = 1
	for i in range(r - 1):
		prod = prod * d % R
		divacc = divacc * div % R
		d += 1
		div += 1
	ret = prod * modinv2(divacc, R) % R
	return ret
(r1, c1, r2, c2) = inm()
r1 += 1
c1 += 1
r2 += 1
c2 += 1
print((f(r2 + 1, c2 + 1) - f(r2 + 1, c1) - f(r1, c2 + 1) + f(r1, c1)) % R)


def f_many_many_paths():

	class Combination(object):
		__slots__ = ['mod', 'factorial', 'inverse']

		def __init__(self, max_val_arg: int=10 ** 6, mod: int=10 ** 9 + 7):
			(fac, inv) = ([1], [])
			(fac_append, inv_append) = (fac.append, inv.append)
			for i in range(1, max_val_arg + 1):
				fac_append(fac[-1] * i % mod)
			inv_append(pow(fac[-1], mod - 2, mod))
			for i in range(max_val_arg, 0, -1):
				inv_append(inv[-1] * i % mod)
			(self.mod, self.factorial, self.inverse) = (mod, fac, inv[::-1])

		def combination(self, n, r):
			if n < 0 or r < 0 or n < r:
				return 0
			return self.factorial[n] * self.inverse[r] * self.inverse[n - r] % self.mod
	(R1, C1, R2, C2) = [int(i) for i in input().split()]
	comb = Combination(R2 + C2 + 2).combination

	def g(r, c):
		return comb(r + c + 2, r + 1) - 1
	return (g(R2, C2) - g(R1 - 1, C2) - g(R2, C1 - 1) + g(R1 - 1, C1 - 1)) % (10 ** 9 + 7)
print(f_many_many_paths())


import sys
input = sys.stdin.buffer.readline

def main():
	(a, b, c, d) = map(int, input().split())
	MOD = 10 ** 9 + 7
	N = c + d + 5
	fac = [0 for _ in range(N + 1)]
	(fac[0], fac[1]) = (1, 1)
	for i in range(2, N + 1):
		fac[i] = fac[i - 1] * i % MOD

	def comb(g, h):
		return fac[g + h] * pow(fac[g], MOD - 2, MOD) * pow(fac[h], MOD - 2, MOD) % MOD
	print((comb(c + 1, d + 1) - comb(c + 1, b) - comb(d + 1, a) + comb(a, b)) % MOD)
main()


(a1, b1, a2, b2) = map(int, input().split())
import sys
sys.setrecursionlimit(2000000000)
p = 10 ** 9 + 7
N = a2 + b2 + 2
R = max(a2 + 1, b2 + 1)
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
for i in range(2, N + 1):
	fact.append(fact[-1] * i % p)
for i in range(2, R + 1):
	inv.append(-inv[p % i] * (p // i) % p)
	factinv.append(factinv[-1] * inv[-1] % p)

def comb(n, r, p):
	if r < 0 or n < r:
		return 0
	r = min(r, n - r)
	return fact[n] * factinv[r] * factinv[n - r] % p
score = comb(a2 + b2 + 2, a2 + 1, p) - comb(a2 + b1 + 1, a2 + 1, p) - comb(a1 + b2 + 1, a1, p) + comb(a1 + b1, a1, p)
print(score % (10 ** 9 + 7))


def main():
	mod = 10 ** 9 + 7
	N = 2 * 10 ** 6 + 3
	fac = [0] * N
	finv = [0] * N
	inv = [0] * N
	fac[0] = fac[1] = 1
	finv[0] = finv[1] = 1
	inv[1] = 1
	for i in range(2, N):
		fac[i] = fac[i - 1] * i % mod
	finv[N // 2] = pow(fac[N // 2], mod - 2, mod)
	for i in reversed(list(range(N // 2))):
		finv[i] = finv[i + 1] * (i + 1) % mod

	def com(r, c):
		ans = fac[r + c] * finv[r] * finv[c]
		return ans % mod

	def g(r, c):
		return (com(r + 1, c + 1) - 1) % mod
	(r1, c1, r2, c2) = list(map(int, input().split()))
	answer = g(r2, c2) - g(r2, c1 - 1) - g(r1 - 1, c2) + g(r1 - 1, c1 - 1)
	answer %= mod
	print(answer)

def __starting_point():
	main()
__starting_point()


(r1, c1, r2, c2) = list(map(int, input().split()))
MOD = 10 ** 9 + 7

def modInverse(x, p):
	return pow(x, p - 2, p)

def nCr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * modInverse(den, p) % p

def hockey(n, m):
	return nCr(n + m + 1, m, MOD)
tot1 = hockey(c2, r2 + 1) - hockey(c2, r1)
tot2 = hockey(c1 - 1, r2 + 1) - hockey(c1 - 1, r1)
print((tot1 - tot2) % MOD)


(r1, c1, r2, c2) = map(int, input().split())
L = 10 ** 9 + 7

def get_euclidian(A, B):
	if B == 1:
		return 1
	else:
		return int((1 - A * get_euclidian(B, A % B)) / B)
F = [1]
for i in range(1, r2 + c2 + 3):
	F.append(F[i - 1] * i % L)

def get_combi(n, r):
	Euc = get_euclidian(L, F[r] * F[n - r] % L)
	return F[n] * Euc % L
combi1 = get_combi(r2 + c2 + 2, r2 + 1)
combi2 = get_combi(r2 + c1 + 1, c1)
combi3 = get_combi(r1 + c2 + 1, r1)
combi4 = get_combi(r1 + c1, r1)
print((int(combi1 - combi2 - combi3 + combi4) + L) % L)


import sys
TEST_INPUT = ['\n    1 1 2 2\n    ', '\n    314 159 2653 589\n    ']
ANSWER = ['14', '602215194']

class InputHandler:

	def __init__(self, text_lines='', is_test=False):
		self.data = list(text_lines.split('\n'))
		self.index = 0
		self.is_test = is_test

	def input(self):
		if self.is_test:
			self.index += 1
			return self.data[self.index].strip()
		else:
			return sys.stdin.readline().rstrip()
LARGE = 10 ** 9 + 7

def solve(r1, c1, r2, c2):
	fact = [0] * (r2 + c2 + 3)
	fact[0] = 1
	for i in range(1, r2 + c2 + 3):
		fact[i] = fact[i - 1] * i % LARGE
	fact_inv = [0] * (r2 + c2 + 3)
	fact_inv[-1] = pow(fact[-1], LARGE - 2, LARGE)
	for i in range(r2 + c2 + 1, -1, -1):
		fact_inv[i] = fact_inv[i + 1] * (i + 1) % LARGE

	def solve_special(r, c):
		return (fact[r + c + 2] * fact_inv[r + 1] * fact_inv[c + 1] - 1) % LARGE
	res = solve_special(r2, c2) - solve_special(r1 - 1, c2) - solve_special(r2, c1 - 1) + solve_special(r1 - 1, c1 - 1)
	return res % LARGE

def input_and_solve(ih):
	(r1, c1, r2, c2) = list(map(int, ih.input().split()))
	res = solve(r1, c1, r2, c2)
	return res

def main():
	ih = InputHandler()
	res = input_and_solve(ih)
	print(res)

def test():
	for (test_input, ans) in zip(TEST_INPUT, ANSWER):
		ih = InputHandler(test_input, True)
		res = input_and_solve(ih)
		assert str(res) == str(ans)

def __starting_point():
	main()
__starting_point()


k = 72
K = 1 << k
nu = lambda L: int(''.join([bin(K + a)[-k:] for a in L[::-1]]), 2)
st = lambda n: bin(n)[2:] + '0'
li = lambda s, l: [int(a, 2) if len(a) else 0 for a in [s[-(i + 1) * k - 1:-i * k - 1] for i in range(l)]]

def grow(d, v, h):
	h += [0] * d
	f = [(-1 if (i + d) % 2 else 1) * fainv[i] * fainv[d - i] % P * h[i] % P for i in range(d + 1)]
	for (idx, a) in enumerate([d + 1, d * fa[v - 1] * fainv[v] % P, (d * fa[v - 1] * fainv[v] + d + 1) % P]):
		t = [1] * (2 * d + 2)
		for i in range(1, 2 * d + 2):
			t[i] = t[i - 1] * (a - d + i - 1) % P
		ti = [1] * (2 * d + 2)
		ti[-1] = pow(t[-1], P - 2, P)
		for i in range(1, 2 * d + 2)[::-1]:
			ti[i - 1] = ti[i] * (a - d + i - 1) % P
		g = [ti[i + 1] * t[i] % P for i in range(2 * d + 1)]
		fg = li(st(nu(f) * nu(g)), d * 2 + 2)
		if idx == 1:
			for i in range(d + 1):
				h[i] = h[i] * (fg[d + i] * t[d + i + 1] % P * ti[i] % P) % P
		elif idx == 0:
			for i in range(d):
				h[i + d + 1] = fg[d + i] * t[d + i + 1] % P * ti[i] % P
		elif idx == 2:
			for i in range(d):
				h[i + d + 1] = h[i + d + 1] * (fg[d + i] * t[d + i + 1] % P * ti[i] % P) % P
	return h

def create_table(v):
	s = 1
	X = [1, v + 1]
	while s < v:
		X = grow(s, v, X)
		s *= 2
	table = [1]
	for x in X:
		table.append(table[-1] * x % P)
	return table

def fact(i, table):
	a = table[i // v]
	for j in range(i // v * v + 1, i + 1):
		a = a * j % P
	return a
P = 10 ** 9 + 7
v = 1 << 11
fa = [1] * (2 * v + 2)
fainv = [1] * (2 * v + 2)
for i in range(2 * v + 1):
	fa[i + 1] = fa[i] * (i + 1) % P
fainv[-1] = pow(fa[-1], P - 2, P)
for i in range(2 * v + 1)[::-1]:
	fainv[i] = fainv[i + 1] * (i + 1) % P
T = create_table(v)
f = lambda a, b: fact(a + b + 2, T) * pow(fact(a + 1, T) * fact(b + 1, T), P - 2, P) % P
(r1, c1, r2, c2) = list(map(int, input().split()))
print((f(r2, c2) - f(r2, c1 - 1) - f(r1 - 1, c2) + f(r1 - 1, c1 - 1)) % P)


import sys
import numpy as np
sr = lambda : sys.stdin.readline().rstrip()
ir = lambda : int(sr())
lr = lambda : list(map(int, sr().split()))
MOD = 10 ** 9 + 7

def cmb(n, k):
	if k < 0 or k > n:
		return 0
	return fact[n] * fact_inv[k] % MOD * fact_inv[n - k] % MOD

def cumprod(arr, MOD):
	L = len(arr)
	Lsq = int(L ** 0.5 + 1)
	arr = np.resize(arr, Lsq ** 2).reshape(Lsq, Lsq)
	for n in range(1, Lsq):
		arr[:, n] *= arr[:, n - 1]
		arr[:, n] %= MOD
	for n in range(1, Lsq):
		arr[n] *= arr[n - 1, -1]
		arr[n] %= MOD
	return arr.ravel()[:L]

def make_fact(U, MOD):
	x = np.arange(U, dtype=np.int64)
	x[0] = 1
	fact = cumprod(x, MOD)
	x = np.arange(U, 0, -1, dtype=np.int64)
	x[0] = pow(int(fact[-1]), MOD - 2, MOD)
	fact_inv = cumprod(x, MOD)[::-1]
	return (fact, fact_inv)
U = 2 * 10 ** 6 + 3
(fact, fact_inv) = make_fact(U, MOD)
(r1, c1, r2, c2) = lr()
answer = cmb(r2 + c2 + 2, r2 + 1) - 1
answer -= cmb(r2 + c1 + 1, r2 + 1) - 1
answer -= cmb(r1 + c2 + 1, c2 + 1) - 1
answer += cmb(r1 + c1, r1) - 1
print(answer % MOD)


(r1, c1, r2, c2) = map(int, input().split())
mod = int(1000000000.0) + 7

def inved(x):
	(a, b, c, d, k, l) = (1, 0, 0, 1, x, mod)
	while l != 0:
		(a, b, c, d) = (c, d, a - c * (k // l), b - d * (k // l))
		(k, l) = (l, k % l)
	return a % mod
frac = [1]
for i in range(r2 + c2 + 2):
	frac.append((i + 1) * frac[i] % mod)
fracr2c2 = frac[r2 + c2 + 2]
fracr1c2 = frac[r1 + c2 + 1]
fracr2c1 = frac[r2 + c1 + 1]
fracr1c1 = frac[r1 + c1]
fracr2 = frac[r2 + 1]
fracr1 = frac[r1]
fracc2 = frac[c2 + 1]
fracc1 = frac[c1]
g = 0
g += fracr2c2 * inved(fracr2) * inved(fracc2) % mod
g %= mod
g += fracr1c1 * inved(fracr1) * inved(fracc1) % mod
g %= mod
g -= fracr1c2 * inved(fracr1) * inved(fracc2) % mod
g %= mod
g -= fracr2c1 * inved(fracr2) * inved(fracc1) % mod
g %= mod
print(g)


(r1, c1, r2, c2) = map(int, input().split())

class Combination:

	def __init__(self, N: int, MOD: int):
		fac = [0 for _ in range(N + 1)]
		fac[0] = 1
		for i in range(1, N + 1):
			fac[i] = fac[i - 1] * i % MOD
		self.fac = fac
		self.N = N
		self.MOD = MOD

	def _modpow(self, x: int, n: int) -> int:
		ret = 1
		while n > 0:
			if n % 2 == 1:
				ret = ret * x % self.MOD
			x = x * x % self.MOD
			n >>= 1
		return ret

	def _modinv(self, x: int) -> int:
		return self._modpow(x, self.MOD - 2)

	def combination(self, n: int, k: int) -> int:
		if n < k:
			return 0
		return self.fac[n] * self._modinv(self.fac[k]) % self.MOD * self._modinv(self.fac[n - k]) % self.MOD
MOD = 1000000007
comb = Combination(2 * 1000000 + 10, MOD)
ans = (2 * MOD + comb.combination(r1 + c1, r1) - comb.combination(r1 + c2 + 1, r1) - comb.combination(r2 + c1 + 1, r2 + 1) + comb.combination(r2 + c2 + 2, r2 + 1)) % MOD
print(ans)


(r1, c1, r2, c2) = map(int, input().split())
MOD = 10 ** 9 + 7
idx = r2 + c2 + 2
perm = [1] * (idx + 1)
perm_inv = [1] * (idx + 1)
for i in range(1, idx + 1):
	perm[i] = perm[i - 1] * i
	perm[i] %= MOD

def inv_mod(a):
	return pow(a, MOD - 2, MOD)
perm_inv[-1] = inv_mod(perm[-1])
for i in range(idx - 1, -1, -1):
	perm_inv[i] = perm_inv[i + 1] * (i + 1)
	perm_inv[i] %= MOD

def comb(i, j):
	buf = perm[i + j + 2]
	buf *= perm_inv[i + 1]
	buf %= MOD
	buf *= perm_inv[j + 1]
	buf %= MOD
	return buf
res = comb(r2, c2)
res -= comb(r2, c1 - 1)
res -= comb(r1 - 1, c2)
res += comb(r1 - 1, c1 - 1)
print(res % MOD)


mod = 10 ** 9 + 7

def find_power(n, mod):
	powlist = [0] * (n + 1)
	powlist[0] = 1
	powlist[1] = 1
	for i in range(2, n + 1):
		powlist[i] = powlist[i - 1] * i % mod
	return powlist

def pow_cal(x, n, mod):
	if n == 0:
		return 1
	elif n == 1:
		return x % mod
	elif n >= 2:
		if n % 2 == 0:
			return pow_cal(x, n // 2, mod) ** 2 % mod
		else:
			return x * pow_cal(x, n // 2, mod) ** 2 % mod

def find_inv_power(n, mod):
	c = 1
	uselist = [0 for i in range(n + 1)]
	for i in range(1, n + 1):
		c *= i
		c %= mod
	first = pow_cal(c, mod - 2, mod)
	uselist[n] = first
	for i in range(n, 0, -1):
		uselist[i - 1] = uselist[i] * i % mod
	return uselist
A = find_power(2 * 10 ** 6 + 10, mod)
B = find_inv_power(2 * 10 ** 6 + 10, mod)

def combi(n, r, mod):
	if n < r:
		return 0
	elif n >= r:
		return A[n] * B[r] * B[n - r] % mod
(r1, c1, r2, c2) = list(map(int, input().split()))
mod = 10 ** 9 + 7
K = combi(r2 + c2 + 2, c2 + 1, mod) - combi(r2 + c1 + 1, c1, mod) - combi(r1 + c2 + 1, r1, mod) + combi(r1 + c1, c1, mod)
print(K % mod)


(a, b, c, d) = map(int, input().split())
m = 10 ** 9 + 7

def f(r, c):
	s = t = 1
	for i in range(c):
		s = s * (r + c - i) % m
		t = t * -~i % m
	return s * pow(t, m - 2, m)
print((f(a, b) - f(c + 1, b) - f(a, d + 1) + f(c + 1, d + 1)) % m)


def comb(n, m, p=10 ** 9 + 7):
	if n < m:
		return 0
	if n < 0 or m < 0:
		return 0
	m = min(m, n - m)
	top = bot = 1
	for i in range(m):
		top = top * (n - i) % p
		bot = bot * (i + 1) % p
	bot = pow(bot, p - 2, p)
	return top * bot % p

def s(n, m):
	return comb(n + m + 2, m + 1, mod)
mod = 10 ** 9 + 7
(r1, c1, r2, c2) = map(int, input().split())
ans = s(r2, c2) - s(r2, c1 - 1) - s(r1 - 1, c2) + s(r1 - 1, c1 - 1)
ans %= mod
print(ans)


(r1, c1, r2, c2) = list(map(int, input().split()))
mod = 1000000007

def inversion(a):
	b = mod
	(u, v) = (1, 0)
	while b >= 1:
		t = a // b
		a -= t * b
		(a, b) = (b, a)
		u -= t * v
		(u, v) = (v, u)
	u %= mod
	if u < 0:
		u += mod
	return u
fact = [0 for i in range(2000003)]
for i in range(2000003):
	if i <= 1:
		fact[i] = 1
	else:
		fact[i] = fact[i - 1] * i % mod

def combination(n, r):
	return fact[n] * inversion(fact[r]) % mod * inversion(fact[n - r]) % mod
answer = combination(r2 + c2 + 2, r2 + 1) - combination(r2 + c1 + 1, r2 + 1) - combination(r1 + c2 + 1, c2 + 1) + combination(r1 + c1, c1)
answer %= mod
if answer < 0:
	answer += mod
print(answer)


mod = 10 ** 9 + 7
rng = 2000100
fctr = [1] + [0] * (rng - 1)
for i in range(1, rng):
	fctr[i] = fctr[i - 1] * i % mod

def finv(x):
	return pow(fctr[x], mod - 2, mod)

def cmb(n, k):
	if n < 0 or k < 0:
		return 0
	else:
		return fctr[n] * finv(n - k) * finv(k) % mod
(x1, y1, x2, y2) = map(int, input().split())
print((cmb(x2 + y2 + 2, x2 + 1) - cmb(x2 + y1 + 1, y1) - cmb(x1 + y2 + 1, x1) + cmb(x1 + y1, x1)) % mod)


def getComb(n, k, MOD):
	if n < k:
		return 0
	if n - k < k:
		k = n - k
	comb = 1
	for x in range(n - k + 1, n + 1):
		comb = comb * x % MOD
	d = 1
	for x in range(1, k + 1):
		d = d * x % MOD
	comb *= pow(d, MOD - 2, MOD)
	return comb % MOD
(r1, c1, r2, c2) = map(int, input().split())
MOD = 10 ** 9 + 7
ans = 0
ans += getComb(r2 + c2 + 2, r2 + 1, MOD)
ans -= getComb(r2 + c1 + 1, r2 + 1, MOD)
ans -= getComb(r1 + c2 + 1, r1, MOD)
ans += getComb(r1 + c1, r1, MOD)
print(ans % MOD)


def prepare(n, mod):
	fac = [1]
	for i in range(1, n + 1):
		fac.append(fac[-1] * i % mod)
	rec = pow(fac[-1], mod - 2, mod)
	den = [1 for _ in range(n + 1)]
	den[n] = rec
	for i in range(n - 1, 0, -1):
		rec = rec * (i + 1) % mod
		den[i] = rec
	return (fac, den)

def comb_mod(n, r, mod, fac, den):
	return fac[n] * den[r] * den[n - r] % mod
(r1, c1, r2, c2) = map(int, input().split())
mod = 10 ** 9 + 7
(fac, den) = prepare(r2 + c2 + 2, mod)
ans = comb_mod(r2 + 1 + c2 + 1, c2 + 1, mod, fac, den)
ans -= comb_mod(r2 + 1 + c1, c1, mod, fac, den)
ans -= comb_mod(r1 + c2 + 1, c2 + 1, mod, fac, den)
ans += comb_mod(r1 + c1, c1, mod, fac, den)
print(ans % mod)


(r1, c1, r2, c2) = map(int, input().split())
mod = 1000000007

def pow(x, n):
	ret = 1
	while n > 0:
		if n & 1 == 1:
			ret = ret * x % mod
		x = x * x % mod
		n //= 2
	return ret

def fac(n):
	ret = 1
	for i in range(1, n + 1):
		ret = ret * i % mod
	return ret

def facinv(n):
	return pow(fac(n), mod - 2)

def cmb(n, k):
	if k < 0 or k > n:
		return 0
	return fac(n) * facinv(k) % mod * facinv(n - k) % mod

def rect(r, c):
	return cmb(r + c, c)
ret = (rect(r2 + 1, c2 + 1) - rect(r1, c2 + 1) - rect(r2 + 1, c1) + rect(r1, c1) + mod + mod) % mod
print(ret)


def ncr(n, r):
	p = 10 ** 9 + 7
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
(r1, c1, r2, c2) = [int(i) for i in input().split()]
r1 += 1
c1 += 1
r2 += 1
c2 += 1
print((ncr(r2 + c2, c2) - ncr(r2 + c1 - 1, c1 - 1) - ncr(c2 + r1 - 1, r1 - 1) + ncr(r1 + c1 - 2, c1 - 1)) % (10 ** 9 + 7))


def solve():
	(r1, c1, r2, c2) = map(int, input().split())
	p = 10 ** 9 + 7
	N = r2 + c2 + 2
	fact = [1, 1]
	for i in range(2, N + 1):
		fact.append(fact[-1] * i % p)

	def comb(n, r):
		a = fact[n]
		b = pow(fact[r], p - 2, p)
		c = pow(fact[n - r], p - 2, p)
		return a * b * c % p

	def f(i, j):
		return comb(i + j, i)

	def g(i, j):
		return f(i + 1, j + 1) - 1
	ans = g(r2, c2) - g(r2, c1 - 1) - g(r1 - 1, c2) + g(r1 - 1, c1 - 1)
	print(ans % p)
solve()


import numpy as np
import sys
read = sys.stdin.read
(r1, c1, r2, c2) = list(map(int, read().split()))
MOD = 10 ** 9 + 7

def cumprod(A, MOD=MOD):
	L = len(A)
	Lsq = int(L ** 0.5 + 1)
	A = np.resize(A, Lsq ** 2).reshape(Lsq, Lsq)
	for n in range(1, Lsq):
		A[:, n] *= A[:, n - 1]
		A[:, n] %= MOD
	for n in range(1, Lsq):
		A[n] *= A[n - 1, -1]
		A[n] %= MOD
	return A.ravel()[:L]

def make_fact(U, MOD=MOD):
	x = np.arange(U, dtype=np.int64)
	x[0] = 1
	fact = cumprod(x, MOD)
	x = np.arange(U, 0, -1, dtype=np.int64)
	x[0] = pow(int(fact[-1]), MOD - 2, MOD)
	fact_inv = cumprod(x, MOD)[::-1]
	fact.flags.writeable = False
	fact_inv.flags.writeable = False
	return (fact, fact_inv)
(fac, finv) = make_fact(2 * 10 ** 6 + 10, MOD)

def comb(n, k, mod=MOD, fac=fac, finv=finv):
	if n < k:
		return 0
	if n < 0 or k < 0:
		return 0
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod
answer = comb(r2 + c2 + 2, r2 + 1) - comb(r1 + c2 + 1, r1) - comb(c1 + r2 + 1, c1) + comb(r1 + c1, r1)
answer %= MOD
print(answer)


mod = 10 ** 9 + 7
(r1, c1, r2, c2) = map(int, input().split())

def inv(x):
	m = mod
	u = 1
	v = 0
	while m:
		t = x // m
		x -= t * m
		(x, m) = (m, x)
		u -= t * v
		(u, v) = (v, u)
	u %= mod
	if u < 0:
		u += mod
	return u
fac = [1]
for i in range(1, r2 + c2 + 3):
	fac.append(fac[i - 1] * i % mod)

def paths(r, c):
	return fac[r + c + 2] * inv(fac[r + 1] * fac[c + 1]) % mod
f = paths(r2, c2) - paths(r2, c1 - 1) - paths(r1 - 1, c2) + paths(r1 - 1, c1 - 1)
f %= mod
if f < 0:
	f += mod
print(f)


MOD = 10 ** 9 + 7

def prepare(n):
	global MOD
	modFacts = [0] * (n + 1)
	modFacts[0] = 1
	for i in range(n):
		modFacts[i + 1] = modFacts[i] * (i + 1) % MOD
	invs = [1] * (n + 1)
	invs[n] = pow(modFacts[n], MOD - 2, MOD)
	for i in range(n, 1, -1):
		invs[i - 1] = invs[i] * i % MOD
	return (modFacts, invs)

def f(i, j):
	Fij = modFacts[i + j]
	Ii = invs[i]
	Ij = invs[j]
	rst = Fij * Ii * Ij % MOD
	return rst

def g(r1, r2, y):
	rst = 0
	for x in range(r1, r2 + 1):
		rst += f(x + 1, y)
		rst %= MOD
	return rst
(r1, c1, r2, c2) = map(int, input().split())
(modFacts, invs) = prepare(max(r1, c1, r2, c2) * 2 + 1)
ans = g(r1, r2, c2) - g(r1, r2, c1 - 1)
print(ans % MOD)


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return list(map(int, input().split()))

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class ModTools:

	def __init__(self, MAX, MOD):
		MAX += 1
		self.MAX = MAX
		self.MOD = MOD
		factorial = [1] * MAX
		factorial[0] = factorial[1] = 1
		for i in range(2, MAX):
			factorial[i] = factorial[i - 1] * i % MOD
		inverse = [1] * MAX
		inverse[MAX - 1] = pow(factorial[MAX - 1], MOD - 2, MOD)
		for i in range(MAX - 2, 0, -1):
			inverse[i] = inverse[i + 1] * (i + 1) % MOD
		self.fact = factorial
		self.inv = inverse

	def nCr(self, n, r):
		if n < r:
			return 0
		r = min(r, n - r)
		numerator = self.fact[n]
		denominator = self.inv[r] * self.inv[n - r] % self.MOD
		return numerator * denominator % self.MOD

	def div(self, x, y):
		return x * pow(y, self.MOD - 2, self.MOD) % self.MOD
(r1, c1, r2, c2) = MAP()
mt = ModTools(r2 + c2 + 2, MOD)

def calc(r, c):
	return mt.div((r + 2) * mt.nCr(c + r + 2, r + 2) - c - 1, c + 1)
ans = calc(r2, c2) - calc(r2, c1 - 1) - calc(r1 - 1, c2) + calc(r1 - 1, c1 - 1)
print(ans % MOD)


import math
import queue
import bisect
from collections import deque, defaultdict
import heapq as hpq
from sys import stdin, setrecursionlimit
ipt = stdin.readline
setrecursionlimit(10 ** 7)
mod = 10 ** 9 + 7

def main():
	(r1, c1, r2, c2) = list(map(int, ipt().split()))
	N = r2 + c2 + 2
	g1 = [1, 1]
	g2 = [1, 1]
	inverse = [0, 1]

	def cmb(n, r, mod=10 ** 9 + 7):
		if r < 0 or r > n:
			return 0
		r = min(r, n - r)
		return g1[n] * g2[r] * g2[n - r] % mod
	for i in range(2, N + 1):
		g1.append(g1[-1] * i % mod)
		inverse.append(-inverse[mod % i] * (mod // i) % mod)
		g2.append(g2[-1] * inverse[-1] % mod)
	print((cmb(r2 + c2 + 2, r2 + 1) + cmb(r1 + c1, r1) - cmb(r2 + c1 + 1, r2 + 1) - cmb(r1 + c2 + 1, r1)) % mod)
	return None

def __starting_point():
	main()
__starting_point()


MOD = int(1000000000.0) + 7

def fact(x):
	k = 1
	for i in range(1, x + 1):
		k = k * i % MOD
	return k

def inverse(b):
	r = 1
	e = MOD - 2
	while e:
		if e % 2 == 1:
			r = r * b % MOD
		b = b * b % MOD
		e >>= 1
	return r

def comb(i, j):
	if i == 0 or j == 0:
		return 0
	num = fact(i + j)
	num *= inverse(fact(i))
	num %= MOD
	num *= inverse(fact(j))
	num %= MOD
	return num
rc = list(map(int, input().split()))
ans = 0
ans += comb(rc[2] + 1, rc[3] + 1)
ans -= comb(rc[0], rc[3] + 1)
ans -= comb(rc[2] + 1, rc[1])
ans += comb(rc[0], rc[1])
ans += MOD
ans += MOD
ans %= MOD
print(ans)


def f(n, r, mod=10 ** 9 + 7):
	n += r
	assert n >= r >= 0

	def ex_euclid(x, y):
		(a, b) = (1, 0)
		while y != 0:
			(a, b) = (b, a - x // y * b)
			(x, y) = (y, x % y)
		return a
	p = q = 1
	for i in range(n - r + 1, n + 1):
		p *= i
		p %= mod
	for i in range(2, r + 1):
		q *= i
		q %= mod
	p *= ex_euclid(q, mod)
	p %= mod
	return p
(a, b, c, d) = map(int, input().split())
mod = 10 ** 9 + 7
print((f(c + 1, d + 1) + mod - f(a, d + 1) + mod - f(c + 1, b) + f(a, b)) % mod)


m = 1000000007
(r1, c1, r2, c2) = map(int, input().split())
nf = 10 ** 6 * 2 + 100
fact = [0] * (nf + 1)
fact[0] = 1
for i in range(nf):
	fact[i + 1] = fact[i] * (i + 1) % m

def F(r, c):
	path = fact[r + c + 2] % m * pow(fact[r + 1] * fact[c + 1], m - 2, m) % m
	return path - 1
r1 -= 1
c1 -= 1
ans = F(r2, c2)
ans -= F(r1, c2)
ans -= F(r2, c1)
ans += F(r1, c1)
ans = ans % m
print(ans)


from operator import mul
from functools import reduce
(r1, c1, r2, c2) = [int(i) for i in input().split()]
mod = 10 ** 9 + 7
num = 10 ** 6 * 2 + 3
fact = [0] * num
fact[0] = 1
for i in range(1, num):
	fact[i] = fact[i - 1] * i % mod

def combinations_count(n, r):
	r = min(r, n - r)
	numer = reduce(mul, range(n, n - r, -1), 1)
	denom = reduce(mul, range(1, r + 1), 1)
	return numer // denom

def f(rr, cc):
	return fact[rr + cc + 2] % mod * pow(fact[rr + 1] * fact[cc + 1], mod - 2, mod) % mod - 1
ans = f(r2, c2) - f(r2, c1 - 1) - f(r1 - 1, c2) + f(r1 - 1, c1 - 1)
print(ans % mod)


def main():
	import sys
	M = 10 ** 9 + 7
	(r1, c1, r2, c2) = map(int, sys.stdin.buffer.readline().split())
	n = r2 + c2 + 2
	val = 1
	fac = [val]
	append = fac.append
	for i in range(1, n + 1):
		val = val * i % M
		append(val)
	pr1 = pow(fac[r1], M - 2, M)
	pc1 = pow(fac[c1], M - 2, M)
	pr2 = pow(fac[r2 + 1], M - 2, M)
	pc2 = pow(fac[c2 + 1], M - 2, M)
	print((fac[r2 + c2 + 2] * pr2 * pc2 - fac[r2 + c1 + 1] * pr2 * pc1 - fac[r1 + c2 + 1] * pr1 * pc2 + fac[r1 + c1] * pr1 * pc1) % M)
main()


def prepare(n, MOD):
	f = 1
	factorials = [1]
	for m in range(1, n + 1):
		f *= m
		f %= MOD
		factorials.append(f)
	inv = pow(f, MOD - 2, MOD)
	invs = [1] * (n + 1)
	invs[n] = inv
	for m in range(n, 1, -1):
		inv *= m
		inv %= MOD
		invs[m - 1] = inv
	return (factorials, invs)
(r1, c1, r2, c2) = list(map(int, input().split()))
MOD = 10 ** 9 + 7
(facts, invs) = prepare(r2 + c2 + 1, MOD)
ans = 0
for i in range(r1, r2 + 1):
	d1 = facts[i + c2 + 1] * invs[c2] % MOD
	d2 = facts[i + c1] * invs[c1 - 1] % MOD
	ans = (ans + (d1 - d2) * invs[i + 1]) % MOD
print(ans)