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;

const int MOD = 1000000007;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n, q; cin >> n >> q;
	vector<pair<int, int>> wydarzenia (n);

	for (int i = 0; i < n; i++) cin >> wydarzenia[i].first >> wydarzenia[i].second;

	while (q--) {
		long long x, l, r; cin >> x >> l >> r;
		for (int i = l; i < r; i++) {
			x = max(x + wydarzenia[i].first, x * wydarzenia[i].second) % MOD;
		}
		cout << x << "\n";

	}

}