#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll t;
    cin >> t;

    rep(loop, t) {
        ll L, R;
        cin >> L >> R;
        if(R - 2*L < 0) {
            out(0);
        }
        else {
            out((R - 2*L + 1)*(R - 2*L + 2)/2);
        }
    }
    
    re0;
}
#include <bits/stdc++.h>
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
ll int mod=998244353;//1e9+7;


struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return hash<int>()(((int)x.first)^(((int)x.second)));
  }
};


struct HASH1{
  size_t operator()(const int&x)const{
    return hash<int>()((x));
  }
};


ll int mul(ll int x, ll int y)
{
    return (x * 1ll * y) % mod;
}


ll int add(ll int x,ll int y)
{
    x += y;
    while(x >= mod) x -= mod;
    while(x < 0) x += mod;
    return x;
}



 int main() {
    IOS;
    int t;
    cin>>t;
    while(t--)
    {
       ll int l,r;
       cin>>l>>r;
       ll int x=r-l;
       if(x==0 && l!=0)
       {
       cout<<0<<endl;
        continue;
       }
       if(x<l)
       {
           cout<<0<<endl;
          continue;
       }
       x=x-l+1;
       x=(x*(x+1))/2;
       cout<<x<<endl;
    }
}
