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 = Integer.parseInt(sc.nextLine()); long c=0; long d=0; long ans = 0; int MOD = 1000000007; for (int i = 0; i < N; i++) { String[] s = sc.nextLine().split(" "); c = Long.parseLong(s[0]); d = Long.parseLong(s[1]); c = (c+1)/2; c %= MOD; d %= MOD; ans = (ans+c*d)%MOD; } System.out.println(ans); } }