n = int(input()) cnt = 0 for _ in range(n): c, d = map(int, input().split()) cnt += ((c + 1) // 2 * d) % (10**9 + 7) print(cnt % (10**9 + 7))