n = int(input()) res = 0 mod = 10**9 + 7 for _ in range(n): c, d = [int(x) for x in input().split()] if c % 2 == 0: can = c // 2 else: can = c // 2 + 1 res += (can % mod * d % mod) % mod res %= mod print(res)