#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int t;
  cin >> t;
  REP(i, t) {
    ll l, r, ans = 0;
    cin >> l >> r;
    if (r - l * 2 >= 0) {
      ans += (r - l * 2 + 2) * (r - l * 2 + 1) / 2;
    }
    cout << ans << endl;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif

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

inline void solve()
{
	int L,R;
	cin>>L>>R;
	if (2*L>R) cout<<0<<endl;
		else cout<<(R-2ll*L+1ll)*(R-2ll*L+2ll)/2ll<<endl;
}

signed main()
{
	ios::sync_with_stdio(false); cout.tie(NULL);
	int t;
	cin>>t;
	for (int i=1;i<=t;i++) solve(); 
} 