#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	
	int Q;
	
	cin>>Q;
	
	for(int _ = 0; _ < Q; _++){
		int N, I, J;
		int a, b, c, d, e;
		int ans = 0;
		
		cin>>N>>I>>J;
		
		a = I;
		b = N - 1 - J;
		c = N - 1 - I;
		d = J;
		
		e = min(min(a, b), min(c, d));
		
		ans = 4 * (N - e) * e;
		
		//cout<<e<<" "<<ans<<endl;
		
		if(a == e) {
			ans += (N - e - 1) * 0;
			ans += J - e;
		} else if(b == e) {
			ans += (N - e - 1) * 1;
			ans += I - e;
		} else if(c == e) {// cout<<"<>"<<endl;
			ans += (N - e - 1) * 2;
			ans += N - 1 - J - e;
		} else {
			ans += (N - e - 1) * 3;
			ans +=  N - 1 - I - e;
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}