import java.util.Scanner; public class No146 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); long tot = 0 , mod = (long)Math.pow(10, 9) + 7l; for(int i = 0;i < n;i++){ long c = s.nextLong() , d = s.nextLong(); long c2 = ((c + 1) / 2) % mod, d2 = d % mod; tot += (c2 * d2) % mod; } s.close(); System.out.println(tot); } }