#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

void testcase(){
	int l, r;
	cin>>l>>r;

	int flag = 0;
	ll count = 0;
	ll inc = 2;
	if(r-2*l+1>=1){
		ll times = r-2*l+1;
		count = (times*(times+1))/2;
	}
	cout<<count<<endl;
}

int main(){
	ios_base::sync_with_stdio();
	cin.tie(NULL);

	int test;
	cin>>test;
	while(test-->0){
		testcase();
	}
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using Pll = pair<long long,long long>;
using vec = vector<int>;
using vecll = vector<long long>;
using mat = vector<vector<int>>;
using matll = vector<vector<long long>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define _GLIBCXX_DEBUG
 
constexpr int MOD = 1000000007;
const int INF = 1 << 30;
 
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }


int main(){
 int n;

  int  max1=-1,max2=-1;

  cin >> n;
  
  vector<vector<int>> a,b;
  
  rep(i,n){
    int x1,y1;
    cin>>x1>>y1;
    a.push_back({x1,y1,i+1});
    b.push_back({y1,x1,i+1});
  }
  sort(all(a));
  sort(all(b));

  set<int> num;
	vec x,y;
    rep(i,2){
      if(!num.count(a[i][2])){
        x.push_back(a[i][0]);
        y.push_back(a[i][1]);
        num.insert(a[i][2]);
      }
      if(!num.count(a[n-1-i][2])){
        x.push_back(a[n-1-i][0]);
        y.push_back(a[n-1-i][1]);
        num.insert(a[n-1-i][2]);
      }  
         }
             rep(i,2){
      if(!num.count(b[i][2])){
        y.push_back(b[i][0]);
        x.push_back(b[i][1]);
        num.insert(b[i][2]);
      }
      if(!num.count(b[n-1-i][2])){
        y.push_back(b[n-1-i][0]);
        x.push_back(b[n-1-i][1]);
        num.insert(b[n-1-i][2]);
      }  
         }
	n = x.size();
  rep(i,n-1){
      for ( int j = i+1; j<n;j++){
        int dis = max(abs(x[j]-x[i]),abs(y[j]-y[i])); 
      	if(dis > max1 ){
          max2 =max1;
          max1 = dis;
        }
        else if(dis > max2) max2 = dis;
          
      }
    }
  cout<<max2<<endl;
      
}