import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.Arrays; import java.util.Scanner; import static java.lang.System.in; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); int N = Integer.parseInt(sc.next()); long accomodates = 0; int mod = 1000000007; for (long i = 0; i < N; i++) { long c = Long.parseLong(sc.next()); long d = Long.parseLong(sc.next()); c = (c+1)/2; c = c % mod; d = d % mod; accomodates+= (c*d)%mod; } System.out.println(accomodates); } }