#!/usr/bin/env python3 import math import sys N = int(input()) num = 0 mod = ((10 ** 9) + 7) desk = [] for line in sys.stdin: desk.append([int(x) for x in line.split()]) num = math.fmod(sum([math.ceil(c / 2) * d for c, d in desk]), mod) print(int(num))