import std; long calc(long n, long row, long col) { long k = min(row, col, n - 1 - row, n - 1 - col); row -= k; col -= k; long step = n^^2 - (n - 2 * k)^^2; n -= 2 * k; if (row == 0) return step + col; if (col == n - 1) return step + (n - 1) + row; if (row == n - 1) return step + (n - 1) * 2 + (n - 1 - col); if (col == 0) return step + (n - 1) * 3 + (n - 1 - row); assert(false); } void main() { int q; scan(q); foreach (_; 0..q) { int n, i, j; scan(n, i, j); writeln(calc(n, i, j)); } } void scan(T...)(ref T a) { string[] ss = readln.split; foreach (i, t; T) a[i] = ss[i].to!t; } T read(T)() { return readln.chomp.to!T; } T[] reads(T)() { return readln.split.to!(T[]); } alias readint = read!int; alias readints = reads!int;