#!/usr/bin/env python3 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((int(C / 2) % mod) * D) if C % 2 == 1: num += D num = num % mod print(int(num))