n = int(input()) v = 0 mod = 10**9+7 for _ in range(n): a, b = map(int, input().split()) v += b*((a+1)//2) print(v % mod)