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