n, q = map(int, input().split())
tab = [[0,0] for i in range(n)]
for i in range(n):
tab[i][0], tab[i][1] = map(int, input().split())
for i in range(q):
x, l, r = map(int, input().split())
for round in range(l,r):
if x * tab[round][1] > x + tab[round][0]:
x = x * tab[round][1]
else:
x = x + tab[round][0]
x = x % (10**9+7)
print(x)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | n, q = map(int, input().split()) tab = [[0,0] for i in range(n)] for i in range(n): tab[i][0], tab[i][1] = map(int, input().split()) for i in range(q): x, l, r = map(int, input().split()) for round in range(l,r): if x * tab[round][1] > x + tab[round][0]: x = x * tab[round][1] else: x = x + tab[round][0] x = x % (10**9+7) print(x) |
English