import java.io.*; import java.util.*; import java.math.*; class Main { public static void out (Object o) { System.out.println(o); } public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); BigDecimal ans = BigDecimal.ZERO; long m = 1000000007L; BigDecimal m2 = BigDecimal.valueOf(m); for (int i = 0; i < n; i++) { String[] line = br.readLine().split(" "); long c = (Long.valueOf(line[0]) + 1) / 2 % m; long d = Long.valueOf(line[1]) % m; ans = ans.add(BigDecimal.valueOf(c).multiply(BigDecimal.valueOf(d))).remainder(m2); } out(ans ); } }