import java.util.*; import java.io.*; public class Main { static final int MOD = 1000000007; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); long total = 0; for (int i = 0; i < n; i++) { String[] line = br.readLine().split(" ", 2); long c = (Long.parseLong(line[0]) + 1) / 2 % MOD; long d = Long.parseLong(line[1]) % MOD; total += (c * d) % MOD; total %= MOD; } System.out.println(total); } }