macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize,
        l: usize,
        r: usize
    }
    let d = 1000000007;
    let ans = (solve(r, n, m, d) + d - solve(l - 1, n, m, d)) % d;
    println!("{}", ans);
}

fn solve(r: usize, n: usize, m: usize, d: usize) -> usize {
    let mut st = vec![1; n + r + 1];
    for i in 1..n + r + 1 {
        st[i] = st[i - 1] * i % d;
    }
    let sti: Vec<usize> = st.iter().map(|&x| inv_m(x, d)).collect();
    let mut a = vec![0; r + 1];
    for i in 0..r + 1 {
        a[i] = st[n + i] * sti[n] % d * sti[i] % d;
    }
    for i in (m..r + 1).rev() {
        a[i] = (a[i] + d - a[i - m]) % d;
    }
    let mut b = vec![0; r + 1];
    for i in 0..n - m + 1 {
        let c = st[n - m] * sti[i] % d * sti[n - m - i] % d;
        for j in 1..r {
            if (i + m) * j > r {
                break;
            }
            if i % 2 == 0 {
                b[(i + m) * j] = (b[(i + m) * j] + c) % d;
            } else {
                b[(i + m) * j] = (b[(i + m) * j] + d - c) % d;
            }
        }
    }
    let cr = a.iter().zip(b.iter().rev()).fold(0, |ac, (&x, &y)| (ac + x * y) % d);
    (st[n + r] * sti[n] % d * sti[r] % d + d - st[n] * sti[m] % d * sti[n - m] % d * cr % d) % d
}

fn pow_m(n: usize, mut p: usize, d: usize) -> usize {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % d;
            p /= 2;
        } else {
            ret = ret * r % d;
            p -= 1;
        }
    }
    ret
}

fn inv_m(n: usize, d: usize) -> usize {
    pow_m(n, d - 2, d)
}


Measured memory_bytes: 24828