#include using namespace std; using ll=long long; const int MOD=1e9+7; ll ans; signed main(){ int n;cin>>n; while(n--){ ll c,d;cin>>c>>d; c=(c+1)>>1; c%=MOD;d%=MOD;ans+=c*d;ans%=MOD; } cout<