#include using namespace std; using ll = long long; #define rep(i, s, e) for (int i = (int)s; i < (int)e; i++) ll mod = 1e9 + 7; int main() { cin.tie(nullptr); int N; cin >> N; ll ans = 0; rep(i, 0, N) { ll C, D; cin >> C >> D; D %= mod; ans += ((C + 1) / 2) % mod * D; ans %= mod; } cout << ans << '\n'; }