N = int(input()) ans = 0 for i in range(N): c, d = map(int, input().split()) if c % 2 == 0: ans += d * (c // 2) else: ans += d * (c // 2 + 1) print(ans % 1000000007)