import std.algorithm, std.conv, std.range, std.stdio, std.string; const auto p = 10^^9 + 7; alias FactorRing!p mint; void main() { auto n = readln.chomp.to!size_t; auto r = mint(0); foreach (_; n.iota) { auto rd = readln.split.to!(long[]), c = rd[0], d = rd[1]; r += mint((c + 1) / 2) * mint(d); } writeln(r.toInt); } struct FactorRing(int m) { long v; @property int toInt() { return v.to!int; } alias toInt this; this(T)(T _v) { v = mod(_v); } ref FactorRing!m opAssign(int _v) { v = mod(_v); return this; } pure auto mod(long _v) const { return _v > 0 ? _v % m : ((_v % m) + m) % m; } pure auto opBinary(string op: "+")(int rhs) const { return FactorRing!m(v + rhs); } pure auto opBinary(string op: "-")(int rhs) const { return FactorRing!m(v - rhs); } pure auto opBinary(string op: "*")(int rhs) const { return FactorRing!m(v * rhs); } pure auto opBinary(string op)(FactorRing!m rhs) const if (op == "+" || op == "-" || op == "*") { return opBinary!op(rhs.v); } auto opOpAssign(string op: "+")(int rhs) { v = mod(v + rhs); } auto opOpAssign(string op: "-")(int rhs) { v = mod(v - rhs); } auto opOpAssign(string op: "*")(int rhs) { v = mod(v * rhs); } auto opOpAssign(string op)(FactorRing!m rhs) if (op == "+" || op == "-" || op == "*") { return opOpAssign!op(rhs.v); } }