#include using namespace std; using ll=unsigned long long; const ll N=pow(10,9)+7; int main(){ int n; cin >> n; ll c,d,ans; for(int i=0;i> c >> d; ans+=(c+1)/2%N*d%N; ans%=N; } cout << ans << endl; return 0; }