import java.io.IOException; import java.util.Scanner; 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 = sc.nextLong(); long d = sc.nextLong(); c = (c + 1) / 2; c = c % mod; d = d % mod; accomodates += (c * d); accomodates %= mod; } System.out.println(accomodates); } }