import std.algorithm, std.array, std.container, std.range; import std.string, std.conv; import std.numeric, std.math, std.bigint, std.bitmanip, std.random; import std.stdio, std.typecons; const auto mod = 10 ^^ 9 + 7; void main() { auto n = readln.chomp.to!long; auto cdi = iota(n) .map!(_ => readln.split.map!(to!long)) .map!(rd => tuple(rd[0], rd[1])); auto r = 0; foreach (cd; cdi) { auto a = (cd[0] / 2 + (cd[0] % 2 == 0 ? 0 : 1)) % mod; auto b = cd[1] % mod; r = (r + (a * b) % mod) % mod; } writeln(r); }