#include #include using namespace std; int main(){ int Q; cin >> Q; for(int i = 0; i < Q; i++){ long long N, I, J; cin >> N >> I >> J; long long sou = min(I, min(J, min(N - 1 - I, N - 1 - J))); long long t = (N - 1)*4, s = t - 8 * sou; long long tim = (t + s + 8)*sou/2; tim = tim + 2*(s/4); long long x = N - 1 - sou, y = N - 1 - sou; if(J == y || I == x - s) cout << tim + (I + J - x - y) << endl; else if(I == x || J == y - s/ 4) cout << tim - (I + J - x - y) << endl; } }