import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); long sum = 0, e = 1000000007, n, m; for(int i = 0; i < num; i++){ n = (sc.nextLong()+1) % e; m = sc.nextLong() % e; sum += n*m; sum %= e; } System.out.println(sum); } }