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