import java.util.*; import java.math.*; import java.io.*; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); BigInteger bi = new BigInteger("0"); int n = sc.nextInt(); BigInteger sum = new BigInteger("0"); for(int i = 0; i < n; i++) { BigInteger c = sc.nextBigInteger(); BigInteger d = sc.nextBigInteger(); BigInteger e = new BigInteger("0"); e = c.divide(new BigInteger("2")).add(new BigInteger("1")); if(c.mod(new BigInteger("2")).equals(new BigInteger("0"))) { e = e.subtract(new BigInteger("1")); } sum = sum.add(e.multiply(d)); sum = sum.mod(new BigInteger("1000000007")); } System.out.println(sum.toString()); } }