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