1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <vector>
using namespace std;
long long n,q,x,l,r;
pair <long long,long long> w;
vector <pair <long long,long long>> gra;
int main()
{
    cin >> n >> q;
    for(int i=0;i<n;i++)
    {
        cin >> w.first >> w.second;
        gra.push_back(w);
    }
    for(int i=0;i<q;i++)
    {
        cin >> x >> l >> r;
        for(int j=l;j<r;j++)
        {
            x=max(x+gra[j].first,x*gra[j].second);
            //cout << x << '\n';
        }
        cout << x%1000000007 << '\n';
    }
    return 0;
}