n = int(input()) mod = int(1e9+7) ans = 0 for i in range(n): c,d = map(int,input().split()) ans += ((c+1)//2 * d) %mod print(ans)