import math n = int(input()) cnt = 0 for _ in range(n): c, d = map(int, input().split()) cnt += (math.ceil(c / 2) * d) % (10**9 + 7) print(cnt % (10**9 + 7))