#include using namespace std; typedef long long ll; const ll MOD = 1e9 + 7; int main() { ll ans = 0; int N; cin >> N; for (int i = 0; i < N; i++) { ll Ci, Di; cin >> Ci >> Di; ll num = (Ci + 1) / 2 % MOD; Di %= MOD; ans += num * Di; ans %= MOD; } cout << ans << endl; }