#include<bits/stdc++.h>
using namespace std;

int main()
{
    int tc,o;
    scanf("%d",&tc);
    for(o=1;o<=tc;o++)
    {

        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz=0,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x=0,y=0,cnt=0,res=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr; string str,ttr,ntr;

        //scanf("%lld",&n);

        scanf("%lld %lld",&n,&m);

        g=m-n;

        if(g>=n)
        {
            h=g-n+1;

            f=h*(h+1); f=f/2; ans=f;

        }

        printf("%lld\n",ans);









    }

    return 0;
}





#include <bits/stdc++.h>
using namespace std;
int main(void) {
	long long int T,ans;
  scanf("%lld",&T);
  long long int L[T],R[T];
  for(int i=0;i<T;i++){
    ans = 0;
    scanf("%lld %lld",&L[i],&R[i]);
    if(R[i]-2*L[i]>=0){
	ans=(R[i]-2*L[i]+2)*(R[i]-2*L[i]+1)/2;
    }
    printf("%lld\n",ans);
  }
}