#include #define K 1000000007 int main(void){ unsigned long long int n,c,d,r=0,i; scanf("%llu",&n); for(i = 1;i <= n;i++){ scanf("%llu%llu",&c,&d); if(c%2){c = (c+1)/2;}else{c/=2;} r+=(((c%K)*(d%K))%K); r%=K; } printf("%llu\n",r); return 0; }