#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; int main(){ int N; cin>>N; vector A(N),T(N); for(int i=0;i>A[i]>>T[i]; int Q; cin>>Q; for(int i=0;i>d>>l>>r; l = 1; r = 100000; long long ans = 0; for(int j=l-1;j