#include using namespace std; const long long MOD = 1000000007; int main(){ int N; cin >> N; int ans = 0; for (int i = 0; i < N; i++){ long long C, D; cin >> C >> D; C = (C + 1) / 2; ans += (C % MOD) * (D % MOD) % MOD; ans %= MOD; } cout << ans << endl; }