#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 9;
const long long mod = 1e9 + 7;
vector<bool> prime(MAX, 1);
vector<int> spf(MAX, 1);
vector<int> primes;
void sieve() {
  prime[0] = prime[1] = 0;
  spf[2] = 2;
  for (long long i = 4; i <= MAX - 1; i += 2) {
    spf[i] = 2;
    prime[i] = 0;
  }
  primes.push_back(2);
  for (long long i = 3; i <= MAX - 1; i += 2) {
    if (prime[i]) {
      primes.push_back(i);
      spf[i] = i;
      for (long long j = i * i; j <= MAX - 1; j += i) {
        prime[j] = 0;
        if (spf[j] == 1) {
          spf[j] = i;
        }
      }
    }
  }
}
long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = res * a;
    }
    a = a * a;
    b = b >> 1;
  }
  return res;
}
long long power(long long a, long long b, long long m) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = (res * a) % m;
    }
    a = (a * a) % m;
    b = b >> 1;
  }
  return res % m;
}
void pre() {}
void solve() {
  long long n, m;
  cin >> n >> m;
  if (m == 0) {
    cout << 0 << "\n";
    return;
  }
  long long z = n - m;
  long long ans = (n * (n + 1)) / 2 - z;
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  pre();
  int test_cases = 1;
  cin >> test_cases;
  for (int i = 1; i <= test_cases; i++) {
    solve();
  }
  return 0;
}
