#include using namespace std; template T inverse(T a, T m) { T u = 0, v = 1; while (a != 0) { T t = m / a; m -= t * a; u -= t * v; std::swap(a, m); std::swap(u, v); } assert(m == 1); return u; } template class Modular { public: using Type = std::decay_t; constexpr Modular() : value() {} template Modular(const U &x) : value(normalize(x)) {} template Type normalize(const U &x) { Type v; if (-mod <= x && x < mod) { v = static_cast(x); } else { v = static_cast(x % mod); } if (v < 0) v += mod; return v; } const Type &operator()() const { return value; } template explicit operator U() const { return static_cast(value); } constexpr static Type mod = T::value; Modular &operator+=(const Modular &rhs) { if ((value += rhs.value) >= mod) value -= mod; return *this; } Modular &operator-=(const Modular &rhs) { if ((value -= rhs.value) < 0) value += mod; return *this; } template Modular &operator+=(const U &rhs) { return *this += Modular(rhs); } template Modular &operator-=(const U &rhs) { return *this -= Modular(rhs); } Modular &operator++() { return *this += 1; } Modular &operator--() { return *this -= 1; } Modular operator++(int) { Modular res(*this); *this += 1; return res; } Modular operator--(int) { Modular res(*this); *this -= 1; return res; } template std::enable_if_t::Type, int>::value, Modular> &operator*=( const Modular &rhs) { value = normalize(static_cast(value) * static_cast(rhs.value)); return *this; } template std::enable_if_t::Type, int64_t>::value, Modular> &operator*=( const Modular &rhs) { value = normalize(static_cast<__int128>(value) * static_cast<__int128>(rhs.value)); return *this; } Modular &operator/=(const Modular &rhs) { return *this *= Modular(inverse(rhs.value, mod)); } template friend bool operator==(const Modular &lhs, const Modular &rhs); template friend bool operator<(const Modular &lhs, const Modular &rhs); template friend bool operator>(const Modular &lhs, const Modular &rhs); template friend std::istream &operator>>(std::istream &stream, Modular &rhs); template friend std::ostream &operator<<(std::ostream &stream, const Modular &rhs); private: Type value; }; template bool operator==(const Modular &lhs, const Modular &rhs) { return lhs.value == rhs.value; } template bool operator==(const Modular &lhs, U rhs) { return lhs == Modular(rhs); } template bool operator==(U lhs, const Modular &rhs) { return Modular(lhs) == rhs; } template bool operator!=(const Modular &lhs, const Modular &rhs) { return !(lhs == rhs); } template bool operator!=(const Modular &lhs, U rhs) { return !(lhs == rhs); } template bool operator!=(U lhs, const Modular &rhs) { return !(lhs == rhs); } template bool operator<(const Modular &lhs, const Modular &rhs) { return lhs.value < rhs.value; } template bool operator>(const Modular &lhs, const Modular &rhs) { return lhs.value > rhs.value; } template Modular operator+(const Modular &lhs, const Modular &rhs) { return Modular(lhs) += rhs; } template Modular operator+(const Modular &lhs, U rhs) { return Modular(lhs) += rhs; } template Modular operator+(U lhs, const Modular &rhs) { return Modular(lhs) += rhs; } template Modular operator-(const Modular &lhs, const Modular &rhs) { return Modular(lhs) -= rhs; } template Modular operator-(const Modular &lhs, U rhs) { return Modular(lhs) -= rhs; } template Modular operator-(U lhs, const Modular &rhs) { return Modular(lhs) -= rhs; } template Modular operator*(const Modular &lhs, const Modular &rhs) { return Modular(lhs) *= rhs; } template Modular operator*(const Modular &lhs, U rhs) { return Modular(lhs) *= rhs; } template Modular operator*(U lhs, const Modular &rhs) { return Modular(lhs) *= rhs; } template Modular operator/(const Modular &lhs, const Modular &rhs) { return Modular(lhs) /= rhs; } template Modular operator/(const Modular &lhs, U rhs) { return Modular(lhs) /= rhs; } template Modular operator/(U lhs, const Modular &rhs) { return Modular(lhs) /= rhs; } template Modular pow(const Modular &a, const U &b) { assert(b >= 0); Modular x = a, res = 1; U n = b; while (n > 0) { if (n & 1) res *= x; x *= x; n >>= 1; } return res; } template std::istream &operator>>(std::istream &stream, Modular &rhs) { typename std::common_type::Type, int64_t>::type x; stream >> x; rhs = Modular(x); return stream; } template std::ostream &operator<<(std::ostream &stream, const Modular &rhs) { stream << rhs.value; return stream; } constexpr int mod = 1000000007; // constexpr int mod = 998244353; using mint = Modular, mod>>; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; mint res = 0; for (int i = 0; i < N; i++) { int c, d; cin >> c >> d; res += ((c + 1) / 2) * static_cast(d); } cout << res << '\n'; return 0; }