#include #include using namespace std; #define ll long long #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++) #define revrep(i,n) for(int (i)=(n)-1;i>=0; i--) ll dp[3000+2][3000+2]; const ll p=1e9+7; int main() { cin.tie(0); ios::sync_with_stdio(false); cout<::max_digits10); int n,m,K; cin>>n>>m>>K; vector l(m); vector r(m); rep(i,m)cin>>l[i]>>r[i]; memset(dp,0,sizeof(dp)); dp[0][1]=1; repeat(k,1,K+1) { vector acc(n+1); repeat(x,1,n+1) { acc[x]+=acc[x-1]+dp[k-1][x]; acc[x]%=p; } rep(i,m) { ll s=(acc[r[i]]-acc[l[i]-1]+p)%p; // imos dp[k][l[i]]+=s; dp[k][l[i]]%=p; dp[k][r[i]+1]+=(p-s); dp[k][r[i]+1]%=p; } repeat(x,1,n+2) { dp[k][x]+=dp[k][x-1]; dp[k][x]%=p; } } cout << dp[K][n] << endl; return 0; }