import java.util.Scanner; public class Yuki146 { int MOD = 1000000007; public Yuki146() { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); //一行目の改行 scanner.nextLine(); long ans = 0; for (int i = 0; i < N; i++) { //通常のnextLongだと時間がかかる String[] d = scanner.nextLine().split(" "); long C = Long.parseLong(d[0]); long D = Long.parseLong(d[1]); C = (C + 1) / 2 % MOD; D = D % MOD; ans = ans + C * D; ans %= MOD; } System.out.println(ans); } public static void main(String[] args) { Yuki146 hoge = new Yuki146(); } }