use std::cmp::*; use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let q: usize = itr.next().unwrap().parse().unwrap(); let mut out = Vec::new(); for _ in 0..q { let mut n: i64 = itr.next().unwrap().parse().unwrap(); let mut i: i64 = itr.next().unwrap().parse().unwrap(); let mut j: i64 = itr.next().unwrap().parse().unwrap(); let k = min(min(n - i - 1, n - j - 1), min(i, j)); let time = 4 * k * (n - k); let diff = n - k * 2 - 1; i -= k; j -= k; n -= k * 2; let ans = if i == 0 { time + j } else if j == n - 1 { time + diff + i } else if i == n - 1 { time + diff * 2 + n - 1 - j } else { time + diff * 3 + n - 1 - i }; writeln!(out, "{}", ans).ok(); } stdout().write_all(&out).unwrap(); }