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