import Data.List
mo=10^9+7
main=do
 [a,b,c,d]<-map read.words<$>getLine
 print$flip mod mo$(f a b)-(f(c+1)b)-(f a(d+1))+f(c+1)(d+1)
f x y=mod(g[x+1..x+y]*p(g[1..y])(mo-2))mo
p a b
 |b==0=1
 |odd b=mod(a*p a(b-1))mo
 |even b=p(mod(a*a)mo)$div b 2
g=foldl1'$(flip mod mo.).(*)