n=int(input()) def f(n): if n%2==1: return n//2 + 1 else: return n//2 ans=0 for i in range(n): c,d=map(int,input().split()) ans+=d*f(c) ans%=(10**9+7) print(ans)