#!/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 = (num + (C + 1) // 2 * D % mod) % mod print(num)