n = int(input()) result = 0 m = 10 ** 9 + 7 for _ in range(n): c, d = map(int, input().split()) result += ((c + 1) // 2 ) * d % m print(result)