#include using namespace std; using ll = long long; ll mod = 1e9 + 7; int main() { int N; ll ans = 0; cin >> N; while (N--) { ll C, D; cin >> C >> D; (C += 1) /= 2; C %= mod; D %= mod; ans += (C * D) % mod; ans %= mod; } cout << ans << endl; }