#include <iostream>
#include <math.h>
#include <iomanip>
#include <bits/stdc++.h>
#include <string.h>
#include <string>
#include <algorithm>
#define ll long long int
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))

using namespace std;

ll binomialCoeff(ll n,ll k)
{
    ll res = 1;
    if(k >n - k)
        k = n - k;
    for(int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

ll power(ll x,ll y,ll mod = 0)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y/2,mod);
    if(!mod)
    {
        if(y%2)
            return temp*temp;
        else
            return temp*temp*x;
    }
    if (y%2 == 0)
        return (temp*temp)%mod;
    else
        return (((x*temp)%mod)*temp)%mod;
}


//nCr % mod
//ll mod = 1e9 + 7;
//const int N0 = 2e5 + 5;
//ll fact[6*N0];
//ll inv[6*N0],invfac[6*N0];
//
//void factorial()
//{
//    fact[0] = invfac[0] = fact[1] = invfac[1] = 1;
//    inv[1] = 1;
//    for(int i=2;i<=5*N0 + 10;i++)
//    {
//        fact[i] = (fact[i-1]*i)%mod;
//        inv[i] = (inv[mod%i]*(mod - mod/i))%mod;
//        invfac[i] = (invfac[i-1]*inv[i])%mod;
//    }
//}

vector<ll> primes;

void Sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primes.push_back(p);
}

//******************************************************    CHECK CONSTRAINTS   ***************************************************************//

const int N = 1005;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;
    cin >> t;
    while(t--)
    {
        ll l,r;
        cin >> l >> r;
        ll ans = 0;
        ll take = r - l;
        ll x = r - l - l + 1;
        if(x <= 0)
        {
            cout << 0 << "\n";
            continue;
        }
        ans = x*(x + 1)/2;
        cout << ans << "\n";
    }
}

#include<bits/stdc++.h>
using namespace std;

#define   fi(a,b) for(int i=a;i<b;i++)
#define   fj(a,b) for(int j=a;j<b;j++)
#define   ff first
#define   ss second
#define   ll long long
#define   ld long double
#define   ull unsigned long long
#define   bp(x) __builtin_popcount(x)
#define   pr(x) for(auto it: x) cout<<it<<" "; cout<<endl;
#define   getMax(x) max_element(x.begin(),x.end())
#define   getMin(x) min_element(x.begin(),x.end())
#define   endl "\n"
typedef   vector<int> vi;
typedef   vector< pair<int, int> > vii;
typedef   vector<long long> vl;
typedef   pair<int, int> pii;
typedef   pair<ll, ll> pll;
typedef   vector< pair<ll, ll> > vll;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// auto dist = uniform_int_distribution<int>(l, r);
// int dx[] = {1, 0, -1, 0};
// int dy[] = {0, 1, 0, -1};
// int dx[] = { -1, 0, 1, 1, 1, 0, -1, -1};
// int dy[] = { -1, -1, -1, 0, 1, 1, 1, 0};


void omae_wa_mou_shindeiru(int tc) {
    ll n, k;
    cin >> n >> k;
    vl dp2(3 * n + 3);
    vl dp3(3 * n + 3);
    fi(1, n + 1) {
        dp2[i + 1]++;
        dp2[i + n + 1]--;
    }
    fi(1, 3 * n + 2) dp2[i] += dp2[i - 1];
    fi(1, 2 * n + 2) {
        dp3[i + 1] += dp2[i];
        dp3[i + n + 1] -= dp2[i];
    }
    fi(1, 3 * n + 1) dp3[i] += dp3[i - 1];
    ll x;
    for (int i = 3; i <= 3 * n; i++) {
        if (k <= dp3[i]) {x = i; break;}
        else {k -= dp3[i];}
    }
    for (int i = 1; i <= n; i++) {
        int jmi = max(1LL, x - i - n);
        int jma = min(n, x - i - 1);
        if (jmi > jma) {continue;}
        if (k > (jma - jmi + 1)) {k -= (jma - jmi + 1); continue;}
        int y = jmi + k - 1;
        int z = x - i - y;
        cout << i << ' ' << y << ' ' << z << '\n';
        return;
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int tc = 1;
    // cin >> tc;
    fi(1, tc + 1) {
        omae_wa_mou_shindeiru(i);
    }
}
