package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) func Scanner() string { sc.Scan() return sc.Text() } func main() { buf := make([]byte, 0) sc.Buffer(buf, 100000007) sc.Split(bufio.ScanWords) q, _ := strconv.Atoi(Scanner()) for i := 0; i < q; i++ { n, _ := strconv.Atoi(Scanner()) i, _ := strconv.Atoi(Scanner()) j, _ := strconv.Atoi(Scanner()) ans := n*n - (n-2*min(i, j, n-1-i, n-1-j))*(n-2*min(i, j, n-1-i, n-1-j)) n, i, j = n-2*min(i, j, n-1-i, n-1-j), i-min(i, j, n-1-i, n-1-j), j-min(i, j, n-1-i, n-1-j) if i == 0 { ans += j } else if j == n-1 { ans += n - 1 + i } else if i == n-1 { ans += 2*(n-1) + (n - 1) - j } else if j == 0 { ans += 3*(n-1) + (n - 1) - i } fmt.Println(ans) } } func min(a int, b int, c int, d int) int { if a < b { if a < c { if a < d { return a } else { return d } } else if c < d { return c } else { return d } } else if b < c { if b < d { return b } else { return d } } else if c < d { return c } else { return d } }