M = 10**9 + 7 def main(n, m): def f(): return map(int, input().split()) res = 0 for _ in range(n): c, d = f() x = (c % m + 1) // 2 x *= d % m res += x return res print(main(int(input()), M))