N = int(input()) m = 10**9 + 7 sum = 0 for i in range(N): c,d = map(int,input().split()) sum += (((c+1)//2)*d) % m sum %= m print(sum)