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