n = int(input()) import math ans = 0 for i in range(n): c,d = map(int,input().split(" ")) ans = ans + int(math.ceil(c/2)*d) print(ans%(10**9+7))