#include #define REP(i,n,N) for(int i=(n);i<(int) N;i++) #define p(s) cout<<(s)<>N; ll ans=0; REP(i,0,N){ ll a,b; cin>>a>>b; a=((a+1)/2)%mod; b%=mod; ans+=a*b; ans%=mod; } p(ans); return 0; }