#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int T;cin>>T;
  for(int X=0;X<T;X++){
    int L,R;cin>>L>>R;
    if(L*2>R)cout<<0<<endl;
    else cout<<(R-L*2+1)*(R-L*2+2)/2<<endl;
  }
}
#include <bits/stdc++.h>
#define ll long long int
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,n) for (int i = 0; i < n; i++)
#define loop1(i,n) for (int i = 1; i < n; i++)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::floatfield );std::cout.precision(15)
#define PI 3.14159265
#define endl '\n'
using namespace std;
int mod = 1000000007;
int m_inf = INT_MIN;

void init_code()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE
}
 
void solve()
{
    ll l,r;
    cin>>l>>r;
    ll minm=l,maxm=r-l;
    if(minm>maxm)
        cout<<0<<endl;
    else
    {
        ll a=r-maxm-l+1;
        ll b=r-minm-l+1;
        ll ans=(a+b)*(b-a+1)/2;
        cout<<ans<<endl;
    }
}
 
int main()
{
    init_code();
    int t=1;
    cin>>t;
    while(t--)
    {
        solve();
    }
}