#include <bits/stdc++.h>

#define rep(i, n) for (auto i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()

using namespace std;

using ll = long long int;

const int MOD_NUM = 1e9 + 7;

int main() {
    // Input
    int T;
    cin >> T;

    rep(i, T) {
        // Input
        int L, R;
        cin >> L >> R;

        // Process
        ll x = max(R - L * 2 + 1, 0);
        ll ans = x * (x + 1) / 2;

        // Output
        cout << ans << endl;
    }

    return 0;
}

#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) (vec).begin(),(vec).end()
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n;
long long a[200100],b[200100],ma,res;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cin>>b[i];
	for(int i=1;i<=n;i++){
		ma=max(ma,a[i]);
		res=max(res,ma*b[i]);
		cout<<res<<endl;
	}
	return 0;
}
