import std.stdio, std.conv, std.string, std.range, std.math, std.algorithm; enum Mod = 1000000007; void main() { auto N = readln.strip.to!int; long[] C, D; foreach (_; 0 .. N) { auto input = readln.split.to!(long[]); C ~= input[0]; D ~= input[1]; } 0UL.reduce!((a,b) => (a+((C[b]+1)/2%Mod)*(D[b]%Mod))%Mod)(0.iota(N)).writeln; }