long a,b,s,x=1e9+7;main(){for(gets(&a);~scanf("%ld%ld",&a,&b);s%=x)s-=~a/2%x*(b%x);a=!printf("%d",s);}