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