def main(): N = int(input()) CD = tuple(tuple(map(int, input().split())) for _ in [0] * N) n = 0 m = 1000000007 for c, d in CD: n += ((c + 1) // 2 * d) % m print(n % m) main()