/*
{
######################
#       Author       #
#        Gary        #
#        2021        #
######################
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
//inline int read(){
//    int x=0;
//    char ch=getchar();
//    while(ch<'0'||ch>'9'){
//        ch=getchar();
//    }
//    while(ch>='0'&&ch<='9'){
//        x=(x<<1)+(x<<3)+(ch^48);
//        ch=getchar();
//    }
//    return x;
//}
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/

int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		int l,r;
		scanf("%d%d",&l,&r);
		int t=r-(2*l)+1;
		if(t<=0){
			cout<<0<<endl;
		}
		else{
			cout<<1ll*t*(t+1)/2<<endl;
		}
	}
	return 0;
}

#include <iostream>
#include <unordered_set>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll maxn = 1e9 + 7;
const double eps = 1e-6;
const ll N = 9e5 + 999;

struct node {
	ll x, y;
}a[N];
ll cas;
ll dis(ll i, ll j) {
	return (a[i].x - a[j].x) * (a[i].x - a[j].x) + (a[i].y - a[j].y ) * (a[i].y - a[j].y);
}
ll sum(ll x) {
	if (x == 1)return 1;
	return (1 + (2 *x - 1)) * x / 2;
}
ll d[N];
bool check(string num, ll n) {
	ll ret = 0;
	for (int i = 0; i < num.size(); i++) {
		ret *= 10;
		ret += num[i];
		ret %= n;
	}
	if (ret == 0)return 1;
	return 0;
}
ll n;
ll c;
ll f(ll x) {
	return -x * x * n + x * c;
}
void solve() {
	ll l, r;cin >> l >> r;
	ll dis = r-l + 1;
	ll ans = 0;
	if (dis == 0) {
		if (l == r && r == 0) {
			cout << 1 ;
		} else cout << 0;
		cout << endl;
		return;
	}
	if (l == 0) {
		ans += dis;
		l = 1;
	}
	 l = max((ll)0,dis - l);
	 r = max((ll)0, dis - r);
	ans += (l + r) * (l-r + 1) / 2;
	cout << ans << endl;

}
signed main() {
	ios::sync_with_stdio(0);
	ll t = 1;cin >> t;
	while (t--)
	solve();	
}