#include using namespace std; typedef long long ll; const ll mod=1000000007; int main(){ ll N; cin>>N; ll ans=0; while(N--){ ll a,b; cin>>a>>b; a=(a+1)/2; a%=mod; b%=mod; ans+=(a*b)%mod; ans%=mod; } printf("%lld\n",ans); return 0; }