import java.util.Scanner; public class Yuki146 { int MOD = 1000000007; public Yuki146() { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); long ans = 0; for (int i = 0; i < N; i++) { long C = (scanner.nextLong() + 1) / 2 % MOD; long D = scanner.nextLong() % MOD; ans = ans + C * D; ans %= MOD; } System.out.println(ans); } public static void main(String[] args) { Yuki146 hoge = new Yuki146(); } }