import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long MOD = (long)Math.pow(10, 9) + 7; int N = sc.nextInt(); long ans = 0; for(int i = 0; i < N; i++) { long c = sc.nextLong(); long d = sc.nextLong(); c = ((c + 1) / 2) % MOD; d = d % MOD; ans = (ans + c * d) % MOD; } System.out.println(ans); } }