#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair P; #define yn {puts("Yes");}else{puts("No");} const int MAX_N = 3005; ll bit[MAX_N]; int n; // 1-index const ll MOD = 1e9+7; void adds(int a, ll w){ for(int x = a; x <= n; x += x & -x) bit[x] += w; } ll sums(int a){ ll ret = 0; for(int x = a; x > 0; x -= x & -x) ret += bit[x]; return ret; } ll dp[MAX_N][MAX_N]; int main() { int m, k; cin >> n >> m >> k; int l[m], r[m]; rep(i,m)cin >> l[i] >> r[i]; dp[0][1] = 1; srep(i,1,k+1){ rep(j,MAX_N)bit[j] = 0; ll sum[MAX_N] = {}; srep(j,1,MAX_N){ sum[j] = sum[j-1] + dp[i-1][j]; } rep(j,m){ ll wa = sum[r[j]] - sum[l[j] - 1]; wa %= MOD; adds(l[j], wa); adds(r[j]+1, -wa); } srep(j,1,n+1){ dp[i][j] = sums(j); dp[i][j] %= MOD; } /* srep(j,1,n+1){ cout << sums(j) << ' '; } cout << endl; */ } dp[k][n] %= MOD; cout << dp[k][n] << endl; return 0; }