import java.util.Scanner; public class N146 { public static void main(String[] args) { Scanner sca = new Scanner(System.in); int n = sca.nextInt(); long A = 0; long mod = 100000007; for (int i = 0; i < n; i++) { Long C = sca.nextLong(); Long D = sca.nextLong(); if (C % 2 == 0) { long t = C / 2; t %= mod; D %= mod; A += t * D; } else { long t = C / 2 + 1; t %= mod; D %= mod; A += t * D; } A %= mod; } System.out.println(A); } }