#include <bits/stdc++.h>
using namespace std;
template <typename T, typename V>
inline void bugp(const pair<T, V> &x) {
  cerr << '{' << x.first << ", " << x.second << "}\n";
}
template <typename T, typename U, typename V>
inline void bugpp(const pair<T, pair<U, V> > &x) {
  cerr << '{' << x.first << ", {" << x.second.first << ", " << x.second.second
       << "}}\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t, n, r, a;
  long long ans;
  cin >> t;
  while (t--) {
    cin >> n >> r;
    a = min(r, n - 1);
    ans = (long long)a * (a + 1) / 2;
    if (r >= n) ++ans;
    cout << ans << '\n';
  }
  return 0;
}
