#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 / 2 + Ci % 2; ll CiDi = (num * Di) % MOD; ans = (ans + CiDi) % MOD; } cout << ans << endl; }