# -*- coding: utf-8 -*- import math N = int(input()) C = [] D = [] for i in range(N): c,d = map(int, input().split()) C.append(c) D.append(d) answer = 0 M = pow(10,9) + 7 for i in range(N): a = math.ceil(C[i]/2) % M b = D[i] % M answer += a*b answer %= M print(answer)