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