/*
    More power comes with more responsibilities.
    
        _.-;;-._.-;;
    '-..-'|   ||   |
    '-..-'|_.-;;-._|
    '-..-'|   ||   |
    '-..-'|_.-''-._|

*/
#define SUP ios::sync_with_stdio(0); cin.tie(0);

#include <bits/stdc++.h>
#include <iostream>
#define ll long long
#define ull unsigned long long
#define modulo 10000003
#define br "\n"
#define pb push_back
using namespace std;

int main()
{
	SUP 
    int t; cin >> t;
    while(t--)
    {
        int l, r; cin >> l >> r;
        ll ans=0;
        ans = max(0, (r-l+1)-l);
        ans = ans*(ans+1)/2;
        cout << ans << br;
    }
    return 0; 
}
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i=1; i < (int)(n); i++)
#define rrep(i, n) for (int i=((int)(n)-1); i>=0; i--)
#define rreps(i, n) for (int i=((int)(n)-1); i>0; i--)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;
using p = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  lint T; cin >> T;
  lint l, r;
  rep (i, T) {
    cin >> l >> r;
    if (2*l > r) {
      cout << 0 << endl;
      continue;
    } else {
      cout << (r-2*l+2)*(r-2*l+1) / 2 << endl;
      continue;
    }
  }
  return 0;
}
