/* ---------- STL Libraries ---------- */ // IO library #include #include #include #include #include // algorithm library #include #include #include #include #include // container library #include #include #include #include #include #include #include #include #include #include #include /* ---------- Namespace ---------- */ using namespace std; /* ---------- Type ---------- */ using ll = long long; #define int ll #define P pair /* ---------- Constants */ const double PI = 3.141592653589793238462643383279; const ll MOD = 1e9 + 7; const int INF = 1LL << 55; /* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */ signed main() { // dp[i][j]: i回の移動でj階に移動する場合の数 // [dp[i+1][Li], dp[i+1][Ri]] <- [dp[i][Li], dp[i][Ri]] int N, M, K; cin >> N >> M >> K; vector L(M); vector R(M); for (int i = 0; i < M; i++) { cin >> L[i] >> R[i]; L[i]--; R[i]--; } vector> dp(K + 1, vector(N + 1, 0)); dp[0][0] = 1; for (int i = 0; i < K; i++) { vector S(N + 1, 0); for (int j = 0; j < N; j++) (S[j + 1] = S[j] + dp[i][j]) %= MOD; for (int j = 0; j < M; j++) { int s = S[R[j] + 1] - S[L[j]] + MOD; (dp[i+1][R[j] + 1] += -s + MOD) %= MOD; (dp[i+1][L[j]] += s) %= MOD; } for (int j = 0; j < N; j++) (dp[i+1][j+1] += dp[i+1][j]) %= MOD; } cout << dp[K][N - 1] << endl; return 0; }