#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

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; }

using namespace std;
typedef long long ll;
using P = pair<int, string>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n; cin >> n;
    vector<P> v;
    for(int i = 0; i < n; i++){
        string s; int t; cin >> s >> t;
        v.push_back(P(t, s));
    }
    sort(v.begin(), v.end(), greater<P>());
    cout << v[1].second << endl;
}
#include<iostream>
using namespace std;
using ll = long long;

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