#!/usr/bin/env python3 import math N = int(input()) num = 0 mod = ((10 ** 9) + 7) for i in range(N): C, D = [int(x) for x in input().split()] num += ((int(math.ceil(C / 2)) % mod) * D) num %= mod num = num % mod print(int(num))