#include <bits/stdc++.h>

using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> p;
 
#define MOD 1000000007

int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

	int N;
	cin >> N;

	bool c = false;

	ll ans = 1e15;

	for(int i = 0; i < N; i++) {
		ll A, P, X;
		cin >> A >> P >> X;

		X -= A;

		if(X > 0LL) {
			c = true;
			ans = min(ans, P);
		}
	}

	if(c) {
		cout << ans << endl;
		return 0;
	}

	cout << -1 << endl;
}
#include <bits/stdc++.h>
using namespace std;

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