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

int main() {
  
  int T;
  cin>>T;
  
  for(int i=0;i<T;i++){
    
    int64_t L,R;
    cin>>L>>R;
    
    int64_t A=R-L*2+1;
    
    if(A<1) cout<<0;
    else{
      cout<<A*(A+1)/2;
    }
    cout<<endl;
    
  }
  
      
  
}

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

void solve() {
    ll l, r;
    cin >> l >> r;

    ll ans;

    if (2 * l <= r)
        ans = (r - 2 * l + 2) * (r - 2 * l + 1) / 2;
    else
        ans = 0;

    cout << ans << '\n';
}

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

    while (t--)
        solve();

    return 0;
}