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
27
28
29
30
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
using namespace std;
using ll=long long;
int main()
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  int n, q, l, r;
  ll x;
  cin >> n >> q;
  int a[n], b[n];
  for (int i=0;i<n;i++)
  {
    cin >> a[i] >> b[i];
  }
  for (int j=0;j<q;j++)
  {
    cin >> x >> l >> r;
    for (int i=l;i<r;i++)
    {
      x=max(x+a[i], x*b[i]);
      x%=1000000007;
    }
    cout << x << "\n";
  }
}