using System; using System.Linq; class Program { static void Main() { long ans = 0; int n = int.Parse(Console.ReadLine()); long mod = (long)1e9 + 7; for (int i = 0; i < n; i++) { long[] cd = Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); long cm = (cd[0] + 1) / 2 % mod; long dm = cd[1] % mod; ans += cm * dm % mod; ans %= mod; } Console.WriteLine(ans); } }