n = int(input()) r=0 t=10**9+7 for i in range(n): c1,c2=map(int,input().split()) r+=(c1+1)//2*c2 print(r%t)