Scanf.scanf "%d %d %d %d" (fun r1 c1 r2 c2 ->
    let m = 1_000_000_007 in

    let extgcd x y =
        let rec eg r0 r1 a0 a1 b0 b1 =
            if r1 = 0 then a0 else
                let q1 = r0 / r1 in
                eg r1 (r0 mod r1) a1 (a0 - q1 * a1) b1 (b0 - q1 * b1)
        in
        eg x y 1 0 0 1
    in
    let inv x y = (* 1/x in mod y *)
        let c = extgcd x y in
        if c < 0 then c + y else c
    in
    let ( */) a b = ((a mod m) * (b mod m) ) mod m in
    let ( //) a b = a */ inv b m in
    let ( +/) a b = (a + b) mod m in
    let ( -/) a b = (((a - b) mod m) + m) mod m in

    let wholesum r c =
        let rec loop cur acc a b i =
            if i > c then acc else loop (cur */ a // b) (acc + cur) (a + 1) (b + 1) (i + 1)
        in
        loop (r + 1) 0 (r + 2) 2 0
    in
    let ans = wholesum r2 c2 -/ wholesum (r1 - 1) c2 -/ wholesum r2 (c1 - 1) +/ wholesum (r1 - 1) (c1 - 1) in
    Printf.printf "%d\n" ans
)