#include #include using namespace std; typedef long long ll; const ll mod = 1e9 + 7; #define inRange(x,a,b) (a <= x && x < b) class STlazy{ private: int n; vector node, lazy; public: STlazy(int siz){ n = 1; while(n < siz) n *= 2; node.resize(2*n-1, 0); lazy.resize(2*n-1, 0); } void eval(int k, int l, int r){ if(lazy[k] == 0) return; node[k] += lazy[k]; node[k] %= mod; if(r-l > 1){ lazy[2*k+1] += lazy[k]/2; lazy[2*k+2] += lazy[k]/2; } lazy[k] = 0; } void add(int a, int b, ll x, int k=0, int l=0, int r=-1){ if(r < 0) r = n; eval(k, l, r); if(r <= a || b <= l) return; if(a <= l && r <= b){ lazy[k] += (r-l)*x; lazy[k] %= mod; eval(k, l, r); return; } add(a, b, x, 2*k+1, l, (l+r)/2); add(a, b, x, 2*k+2, (l+r)/2, r); node[k] = (node[2*k+1] + node[2*k+2])%mod; } ll query(int a, int b, int k=0, int l=0, int r=-1){ if(r < 0) r = n; if(r <= a || b <= l) return 0; eval(k, l, r); if(a <= l && r <= b) return node[k]; ll lx = query(a, b, 2*k+1, l, (l+r)/2); ll rx = query(a, b, 2*k+2, (l+r)/2, r); return (lx+rx)%mod; } }; // 重複を除去しきれていない int main(){ int n, m, k; cin >> n >> m >> k; vector l(m), r(m); for(int i = 0; i < m; i++) cin >> l[i] >> r[i], l[i]--, r[i]--; STlazy st(n); st.add(0, 1, 1); for(int i = 0; i < k; i++){ STlazy next(n); for(int j = 0; j < m; j++){ next.add(l[j], r[j]+1, st.query(l[j], r[j]+1)); } st = next; } cout << st.query(n-1, n) << endl; return 0; }