/*

  Author: klmcoder
  Date  : 20210213 1834 hrs.
  Info  : atcoder [arc112-A]

*/
#include <iostream>

int main(void)
{
  int t, a, b;
  long v1;
  unsigned long v2;

  std::cin >> t;
  while(t--)
  {
    std::cin >> a >> b;
    v1 = b - 2*(long)a + 1;
    if(v1<0)
      std::cout << "0\n";
    else
    {
      v2=(v1%2==0)?v1/2:(v1+1)/2;
      v2*=(v1%2==0)?(unsigned long)v1+1:v1;
      std::cout << v2 << "\n";
    }
  }

  return 0;
}

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

const ll mod = 1e9 + 7;

void solve() {
  ll l, r;
  cin >> l >> r;
  if (r < 2 * l) {
    cout << 0 << endl;
    return;
  }
  cout << (1 + r - 2*l + 1) * (r - 2*l + 1) / 2 << endl;
}

int main(void) {
  int t;
  cin >> t;
  for(int i = 0;i < t;++i) {
    solve();
  }
  return 0;
}
