import java.util.*; public class Main { static final int MOD = 1000000007; public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long ans = 0; for (int i = 0; i < n; i++) { long c = sc.nextLong(); long d = sc.nextLong() % MOD; ans += (c + 1) / 2 % MOD * d % MOD; ans %= MOD; } System.out.println(ans); } }