import java.util.*; import java.math.*; import java.io.*; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long sum = 0L; for(int i = 0; i < n; i++) { long c = sc.nextLong() % 1000000007; long d = sc.nextLong() % 1000000007; sum += d * (c/2 + 1 -(c%2==0?1:0)) % 1000000007; sum %= 1000000007; } System.out.println(sum); } }