#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, i1, i2, k, m, j, j1, f, a1, i31, i3, j2, i5, i4, i6, i7, i;
    i4 = INT_MIN, i1 = 0;
    f = 0;
    long long int s1, s2, s3;
    s2 = 0;
    s1 = 0;
    i31 = 0;
    s3 = 0;
    long long int x;
    if (m == 0) {
      cout << 0 << endl;
      goto m;
    }
    cin >> n >> m;
    i1 = (n * (n + 1)) / 2;
    cout << i1 - (n - m) << endl;
  m:
    s2++;
  }
}
