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