t = int(input()) mod = 1000000007 total = 0 for i in range(t): p, n = map(int,input().split()) if p % 2 == 0: c = p//2 else: c = p//2 + 1 total += c*n total = total%mod print(total)