/** * @FileName a.cpp * @Author kanpurin * @Created 2022.01.07 23:38:28 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int main() { int t;cin >> t; for (int _ = 0; _ < t; _++) { ll n,m;cin >> n >> m; if (m <= n) { cout << (m+1)/2 << endl; } else { cout << (m-n-1)*(m-n+4)/2+((2*n-m)/2) << endl; } } return 0; }