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