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