const MOD: usize = 1e9 as usize + 7; fn main() { let mut nmk = String::new(); std::io::stdin().read_line(&mut nmk).ok(); let nmk: Vec = nmk.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nmk[0]; let m = nmk[1]; let k = nmk[2]; let areas = (0..m).map(|_| { let mut temp = String::new(); std::io::stdin().read_line(&mut temp).ok(); let temp: Vec = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); (temp[0]-1, temp[1]-1) }) .collect::>(); let mut dp = vec![0usize; n]; dp[0] = 1; for _ in 0..k { let mut psummary = vec![0usize; n+1]; for i in 0..n { psummary[i+1] = psummary[i] + dp[i]; psummary[i+1] %= MOD; } let mut next_dp = vec![0usize; n]; for &(l, r) in areas.iter() { let people = MOD + psummary[r+1] - psummary[l]; let people = people % MOD; if people == 0 { continue; } next_dp[l] += people; next_dp[l] %= MOD; if r+1 < n { next_dp[r+1] += MOD - people; next_dp[r+1] %= MOD; } } for i in 0..n-1 { next_dp[i+1] += next_dp[i]; next_dp[i+1] %= MOD; } dp = next_dp; } println!("{}", dp[n-1]); }