import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner koko = new Scanner(System.in); int n = Integer.parseInt(koko.nextLine()); long total = 0; for (int i = 0; i < n; i++) { String[] input = koko.nextLine().split(" "); long c = Long.parseLong(input[0]); long d = Long.parseLong(input[1]); d = d % 1000000007; if (c % 2 == 0) { long e = c / 2; e = e % 1000000007; long t = e * d; t = t % 1000000007; total = total + t; } else { long e = (c + 1) / 2; e = e % 1000000007; long t = e * d; t = t % 1000000007; total = total + t; } total = total % 1000000007; } System.out.println(total); } }