#include using namespace std; typedef long long ll; const ll MOD = 1e9+7; int main(){ int n; cin >> n; ll ans = 0; for(int i=0; i> c >> d; if(c%2 == 0) c--; ans += ((c/2+1) % MOD) * (d % MOD); } cout << ans%MOD << endl; return 0; }