import math mod = pow(10, 9) + 7 n = int(input()) p = 0 for i in range(n): chair, num = map(int, input().split()) p += (math.ceil(chair / 2) * num) % mod print(p % mod)