#include using namespace std; #define all(x) (x).begin(),(x).end() #define SP <<" "<< #define MOD 1000000007 #define IINF 1000000000 #define LINF 1000000000000000000 typedef long long LL; typedef long double LD; LL inv(LL x){ int n=MOD-2; LL ans=1; while(n){ if(n&1) ans=(ans*x)%MOD; n/=2; x=x*x%MOD; } return ans; } LL inv2; struct LazySegmentTree { private: int n; vector node, lazy; public: LazySegmentTree(int size) { int sz = size; n = 1; while(n < sz) n *= 2; node.resize(2*n-1, 0); lazy.resize(2*n-1, 0); } void init(){ for(int i=0;i<2*n-1;i++){ node[i]=lazy[i]=0; } } void eval(int k, int l, int r) { if(lazy[k] != 0) { node[k] = (node[k]+lazy[k])%MOD; if(r - l > 1) { lazy[2*k+1] = (lazy[2*k+1]+lazy[k] *inv2)%MOD; lazy[2*k+2] = (lazy[2*k+2]+lazy[k] *inv2)%MOD; } 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(b <= l || r <= a) return; if(a <= l && r <= b) { lazy[k] = (lazy[k]+(r - l) * x%MOD)%MOD; eval(k, l, r); }else { 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 getsum(int a, int b, int k=0, int l=0, int r=-1) { if(r < 0) r = n; if(b <= l || r <= a) return 0; eval(k, l, r); if(a <= l && r <= b) return node[k]; LL vl = getsum(a, b, 2*k+1, l, (l+r)/2); LL vr = getsum(a, b, 2*k+2, (l+r)/2, r); return (vl + vr)%MOD; } }; int main(){ int n,m,k; cin >> n >> m >> k; inv2=inv(2); vector> p(m); for(int i=0;i> p[i].first >> p[i].second; p[i].first--; } LazySegmentTree seg(n); seg.add(0,1,1); vector sum(n); for(int i=0;i