n=int(input()) sum=0 for i in range(n): a=int(input()) b=int(input()) sum+=(a+1)/2*b print sum%1000000007