import math mod = 10 ** 9 + 7 N = input() res = 0 for i in range(N): C,D = map(long, raw_input().split()) a = math.ceil(C / 2.0) % mod b = D % mod res += a * b res %= mod print res