MOD = 10 ** 9 + 7 N = int(input()) ans = 0 for i in range(N): C, D = map(int, input().split()) ans = (ans + D * ((C + 1) // 2)) % MOD print(ans)