Given a positive integer $$$n$$$. Find three distinct positive integers $$$a$$$, $$$b$$$, $$$c$$$ such that $$$a + b + c = n$$$ and $$$\operatorname{gcd}(a, b) = c$$$, where $$$\operatorname{gcd}(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$.

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Description of the test cases follows. The first and only line of each test case contains a single integer $$$n$$$ ($$$10 \le n \le 10^9$$$).

For each test case, output three distinct positive integers $$$a$$$, $$$b$$$, $$$c$$$ satisfying the requirements. If there are multiple solutions, you can print any. We can show that an answer always exists.

NoteIn the first test case, $$$6 + 9 + 3 = 18$$$ and $$$\operatorname{gcd}(6, 9) = 3$$$.In the second test case, $$$21 + 39 + 3 = 63$$$ and $$$\operatorname{gcd}(21, 39) = 3$$$.In the third test case, $$$29 + 43 + 1 = 73$$$ and $$$\operatorname{gcd}(29, 43) = 1$$$.

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
// 	redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

func solve() {
	var n int
	scan(&n)
	n--
	for a := 2; a < n-1; a++ {
		b := n - a
		if gcd(a, b) == 1 && a != b {
			printf("%v %v %v\n", a, b, 1)
			return
		}
	}
}

func gcd(a, b int) int {
	for a > 0 && b > 0 {
		if a > b {
			a %= b
		} else {
			b %= a
		}
	}
	return a + b
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
// 	redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

func solve() {
	var n int
	scan(&n)
	if (n-1)%2 == 1 {
		printf("%v %v %v\n", (n-1)/2, (n-1)/2+1, 1)
	} else {
		m := (n - 1) / 2
		if m%2 == 0 {
			printf("%v %v %v\n", m-1, m+1, 1)
		} else {
			printf("%v %v %v\n", m-2, m+2, 1)
		}
	}
}

package main

import (
	"fmt"
	"bufio"
	"os"
)

var (
	input = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assert!")}
}

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)

func main() {
    defer output.Flush()
    //solve()
    //return
	var t int64
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
}

type pair struct {a, b int}

func solve() {
    var n int
    fmt.Fscan(input, &n)

    v := n - 1
    // v should be sum of coprimes v = x + y
    for x := 2; x < v / 2; x++ {
        y := v - x
        if gcd(x, y) == 1 {
            assert(x + y + 1 == n)
            fmt.Fprintln(output, x, y, 1)
            return
        }
    }

    assert(false)
}

func gcd(a, b int) int {
    if b == 0 { return a }
    return gcd(b, a % b)
}

func abs(x int) int {
    if x < 0 { return - x}
    return x
}
func max(a, b int) int {
    if a > b { return a}
    return b
}

func min(a, b int) int {
    if a < b { return a}
    return b
}

func isPrime(v int) bool {
    if v == 1 { return false }
    for i := 2; i * i <= v; i++ {
        if v % i == 0 { return false }
    }
    return true
}

// 00
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func gcd(a int, b int) int {
	if b > a {
		return gcd(b, a)
	}
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

type Triple struct {
	a, b, c int
}

func write_int(f *bufio.Writer, a int) {
	f.Write([]byte(strconv.Itoa(a)))
}
func write_string(f *bufio.Writer, a string) {
	f.Write([]byte(a))
}

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	m := make(map[int]Triple)
	for t := 1; t <= T; t++ {
		var n int
		fmt.Fscan(reader, &n)
		if val, ok := m[n]; ok {
			write_int(f, val.a)
			write_string(f, " ")
			write_int(f, val.b)
			write_string(f, " ")
			write_int(f, val.c)
			write_string(f, "\n")
		} else {
			for i := 2; i > 0; i++ {
				if gcd(n-1-i, i) == 1 {
					write_int(f, i)
					write_string(f, " ")
					write_int(f, n-1-i)
					write_string(f, " ")
					write_int(f, 1)
					write_string(f, "\n")
					m[n] = Triple{a: i, b: n - 1 - i, c: 1}
					break
				}
			}
		}

	}
}

// 00
package main

import (
	"bufio"
	"fmt"
	"os"
)

func gcd(a int, b int) int {
	if b > a {
		return gcd(b, a)
	}
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

type Triple struct {
	a, b, c int
}

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	m := make(map[int]Triple)
	for t := 1; t <= T; t++ {
		var n int
		fmt.Fscan(reader, &n)
		if val, ok := m[n]; ok {
			fmt.Println(val.a, val.b, val.c)
		} else {
			for i := 2; i > 0; i++ {
				if gcd(n-1-i, i) == 1 {
					fmt.Println(i, n-1-i, 1)
					m[n] = Triple{a: i, b: n - 1 - i, c: 1}
					break
				}
			}
		}

	}
}

// 00
package main

import (
	"bufio"
	"fmt"
	"os"
)

func gcd(a int, b int) int {
	if b > a {
		return gcd(b, a)
	}
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n int
		fmt.Fscan(reader, &n)
		for i := 2; i > 0; i++ {
			if gcd(n-1-i, i) == 1 {
				fmt.Println(i, n-1-i, 1)
				break
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var in, out = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)

var m []int

var ans [][3]int

func gcd(a, b int) int {
	if b > 0 {
		return gcd(b, a%b)
	} else {
		return a
	}
}

func solve(t int) {
	n := m[t]
	if n&1 == 1 {
		for i := 3; ; i += 2 {
			x := n - i - 1
			if gcd(x, i) == 1 {
				ans[t][0] = i
				ans[t][1] = x
				ans[t][2] = 1
				return
			}
		}
	} else {
		ans[t][0] = n - 3
		ans[t][1] = 2
		ans[t][2] = 1
	}
}

func main() {
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	m = make([]int, t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &m[i])
	}
	ans = make([][3]int, t)
	for i := 0; i < t; i++ {
		solve(i)
	}
	for _, i := range ans {
		fmt.Fprintf(out, "%d %d %d\n", i[0], i[1], i[2])
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {

	reader := bufio.NewReader(os.Stdin)
	writter := bufio.NewWriter(os.Stdout)
	defer writter.Flush()

	t := 0
	fmt.Fscan(reader, &t)

	for t > 0 {

		n := 0
		fmt.Fscan(reader, &n)

		out := solve(n)
		for i := range out {
			fmt.Fprintf(writter, "%d ", out[i])
		}
		fmt.Fprintln(writter)

		t--
	}

	// n := 18
	// fmt.Println(solve(n))

}

func solve(n int) []int {

	for i := 1; i <= n-1; i++ {

		for j := i + 1; j < (n-i)/2; j++ {

			if gcd(j, n-i-j) == i {
				return []int{j, n - i - j, i}
			}

		}

	}

	return []int{}
}

func strToint(str string) int {
	num, _ := strconv.Atoi(str)
	return num
}

func max(a, b int64) int64 {
	if a >= b {
		return a
	}

	return b
}

func getFactor(num int) []int {
	result := []int{}

	for i := 1; i <= int(math.Sqrt(float64(num))); i++ {
		if num%i == 0 {
			result = append(result, i)
			result = append(result, num/i)
		}
	}

	return result
}

func gcd(a, b int) int {
	if a == 0 {
		return b
	}

	return gcd(b%a, a)
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strings"
)

/*

 */

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	bld := strings.Builder{}

	var t = 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		var n int
		scanf("%d\n", &n)

		for a := 2; a < n-2; a++ {
			b := n - a - 1
			if gcd(a, b) == 1 {
				fmt.Fprintln(&bld, a, b, 1)
				break
			}
		}

	}

	printf("%s", bld.String())
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

//goland:noinspection GoUnusedType
type pair struct {
	x int64
	y int64
}

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//goland:noinspection GoUnusedFunction
func isPrime(n int) bool {
	if n == 2 || n == 3 {
		return true
	}

	if n <= 1 || n%2 == 0 || n%3 == 0 {
		return false
	}

	for i := 5; i*i <= n; i += 6 {
		if n%i == 0 || n%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func split(n int) (int, int) {
	a := 2
	b := n - 2
	for gcd(a, b) != 1 {
		a++
		b--
	}
	return a, b
}

func main() {
	var ntc int
	fmt.Fscan(in, &ntc)
	for t := 0; t < ntc; t++ {
		var n int
		fmt.Fscan(in, &n)
		if n%2 == 0 {
			fmt.Fprintf(out, "%d %d 1\n", n/2-1, n/2)
		} else {
			a, b := split(n - 1)
			fmt.Fprintf(out, "%d %d 1\n", a, b)
		}
	}
	out.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	reader = bufio.NewReader(os.Stdin)
	t, n   int
)

func gcd(x, y int) int {
	if y > x {
		return gcd(y, x)
	}
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func solve(n int) (int, int, int) {
	for i := 2; i < n; i++ {
		if gcd(i, n-1-i) == 1 {
			return n - 1 - i, i, 1
		}
	}
	return 0, 0, 0
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		fmt.Println(solve(n))
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		a, b, c := 2, n-3, 1
		for b > a {
			if gcd(a, b) == 1 {
				break
			}
			a++
			b--
		}

		fmt.Fprintf(out, "%d %d %d\n", a, b, c)
	}
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	var buf bytes.Buffer
	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		a, b, c := solve(n)
		buf.WriteString(fmt.Sprintf("%d %d %d\n", a, b, c))
	}
	fmt.Print(buf.String())
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(n int) (a int, b int, c int) {
	// a = x * c
	// b = y * c
	// gcd(x, y) = 1
	// (x + y + 1) * c = n
	// a != b != c
	// if c == 1
	// then x + y + 1 = n
	// x + y = n - 1
	c = 1
	if n%2 == 0 {
		// n is even, and  n - 1 is odd
		a = (n - 1) / 2
		b = n - 1 - a
		return
	}
	// n % 2 == 1, if c == 1
	// then a + b + 1 = 2 * x + 1
	// a + b = 2 * x
	// a is odd, and b is odd, find gcd(a, b) = 1
	// if x is even, then a = x - 1, b = x + 1
	// else a = x - 2, b = x + 2
	x := n / 2
	if x%2 == 0 {
		a = x - 1
		b = x + 1
	} else {
		a = x - 2
		b = x + 2
	}
	return
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

// GCD of two numbers
// Euclid's algorithm
func GCD(a, b int) int {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func isPrime(n int) bool {
	if n <= 1 {
		return false
	}
	if n == 2 {
		return true
	}
	if n%2 == 0 {
		return false
	}
	m := int(math.Ceil(math.Sqrt(float64(n))))
	for i := 3; i <= m; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, sieve, x := 0, []int{1}, 0
	fmt.Fscan(f, &N)
	for i := 1; i <= 100; i++ {
		if isPrime(i) {
			sieve = append(sieve, i)
		}
	}
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &x)
		br := false
		for j := 0; j < len(sieve); j++ {
			d := x - sieve[j]
			a, b, c := 0, 0, sieve[j]
			for k := 1; k < d-1; k++ {
				a, b = k, d-k
				if GCD(k, d-k) == c && a+b+c == x && (a != b && b != c && a != c) {
					fmt.Fprintln(w, k, d-k, c)
					br = true
					break
				}
			}
			if br {
				break
			}
		}
	}
	w.Flush()
}

func main() {
	solve()
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		for a := 2; ; a++ {
			b := n-1-a
			if b <= a {
				panic(n)
			}
			if gcd(a,b) == 1 {
				Fprintln(out, a, b, 1)
				return
			}
		}
	}

	T := 1
	Fscan(in, &T)
	for Case := 1; Case <= T; Case++ {
		solve(Case)
	}

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}

}

func main() { run(os.Stdin, os.Stdout) }

func gcd(a, b int) int {
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
// 	redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

func solve() {
	var n int
	scan(&n)
	n--
	if n%2 == 1 {
		printf("%v %v %v\n", n/2, n/2+1, 1)
	} else {
		printf("%v %v %v\n", n/2-1, n/2+1, 1)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
// 	redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

func solve() {
	var n int
	scan(&n)

	n--

	if n%2 == 1 {
		printf("%v %v %v\n", n/2, n/2+1, 1)
		return
	}

	for a := 2; a*a <= n; a++ {
		if gcd(n-a, a) != 1 {
			continue
		}
		printf("%v %v %v\n", a, n-1-a, 1)
		return
	}

	panic("")
}

func gcd(a, b int) int {
	for a > 0 && b > 0 {
		if a > b {
			a %= b
		} else {
			b %= a
		}
	}
	return a + b
}

package main

import (
	"fmt"
	"bufio"
	"os"
)

var (
	input = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assert!")}
}

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)

func main() {
    defer output.Flush()
    //solve()
    //return
	var t int64
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
}

type pair struct {a, b int}

func solve() {
    var n int
    fmt.Fscan(input, &n)

    for i := 1; i * i <= n; i++ {
        if n % i == 0 {
            v := n / i - 1
                // v should be sum of coprimes v = x + y
                for x := 1; x < v / 2; x++ {
                    y := v - x
                    if gcd(x, y) == 1 {
                        assert(x * i + y * i + i == n)
                        fmt.Fprintln(output, x*i, y*i, i)
                        return
                    }
                }
        }
    }
    assert(false)
}

func gcd(a, b int) int {
    if b == 0 { return a }
    return gcd(b, a % b)
}

func abs(x int) int {
    if x < 0 { return - x}
    return x
}
func max(a, b int) int {
    if a > b { return a}
    return b
}

func min(a, b int) int {
    if a < b { return a}
    return b
}

func isPrime(v int) bool {
    if v == 1 { return false }
    for i := 2; i * i <= v; i++ {
        if v % i == 0 { return false }
    }
    return true
}

package main

import (
	"fmt"
	"bufio"
	"os"
)

var (
	input = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assert!")}
}

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)

func main() {
    defer output.Flush()
    //solve()
    //return
	var t int64
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
}

type pair struct {a, b int}

func solve() {
    var n int
    fmt.Fscan(input, &n)

    for i := 1; i * i <= n; i++ {
        if n % i == 0 {
            v := n / i - 1
                // v should be sum of coprimes v = x + y
                for x := 1; x < v / 2; x++ {
                    y := v - x
                    if y % x > 0 {
                        assert(x * i + y * i + i == n)
                        fmt.Fprintln(output, x*i, y*i, i)
                        return
                    }
                }
        }
    }
    assert(false)
}

func abs(x int) int {
    if x < 0 { return - x}
    return x
}
func max(a, b int) int {
    if a > b { return a}
    return b
}

func min(a, b int) int {
    if a < b { return a}
    return b
}

func isPrime(v int) bool {
    if v == 1 { return false }
    for i := 2; i * i <= v; i++ {
        if v % i == 0 { return false }
    }
    return true
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var in, out = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)

var m []int

var ans [][3]int

func gcd(a, b int) int {
	if b > 0 {
		return gcd(b, a%b)
	} else {
		return a
	}
}

func solve(t int) {
	n := m[t]
	if n&1 == 1 {
		for i := 3; ; i += 2 {
			x := n - i - 1
			if gcd(x, i) == 1 {
				ans[t][0] = i
				ans[t][1] = x
				ans[t][2] = 1
				return
			}
		}
	} else {
		ans[t][0] = n - 3
		ans[t][1] = 2
		ans[t][2] = 1
	}
}

func main() {
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	m = make([]int, t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &m[i])
	}
	ans = make([][3]int, t)
	for i := 0; i < t; i++ {
		go solve(i)
	}
	for _, i := range ans {
		fmt.Fprintf(out, "%d %d %d\n", i[0], i[1], i[2])
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {

	reader := bufio.NewReader(os.Stdin)
	writter := bufio.NewWriter(os.Stdout)
	defer writter.Flush()

	t := 0
	fmt.Fscan(reader, &t)

	for t > 0 {

		n := 0
		fmt.Fscan(reader, &n)

		out := solve(n)
		for i := range out {
			fmt.Fprintf(writter, "%d ", out[i])
		}
		fmt.Fprintln(writter)

		t--
	}

	// n := 18
	// fmt.Println(solve(n))

}

func solve(n int) []int {
	return []int{1, n - 2, 1}
}

func strToint(str string) int {
	num, _ := strconv.Atoi(str)
	return num
}

func max(a, b int64) int64 {
	if a >= b {
		return a
	}

	return b
}

func getFactor(num int) []int {
	result := []int{}

	for i := 1; i <= int(math.Sqrt(float64(num))); i++ {
		if num%i == 0 {
			result = append(result, i)
			result = append(result, num/i)
		}
	}

	return result
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {

	reader := bufio.NewReader(os.Stdin)
	writter := bufio.NewWriter(os.Stdout)
	defer writter.Flush()

	t := 0
	fmt.Fscan(reader, &t)

	for t > 0 {

		n := 0
		fmt.Fscan(reader, &n)

		fmt.Fprintln(writter, solve(n))

		t--
	}

	// n := 18
	// fmt.Println(solve(n))

}

func solve(n int) []int {
	return []int{1, n - 2, 1}
}

func strToint(str string) int {
	num, _ := strconv.Atoi(str)
	return num
}

func max(a, b int64) int64 {
	if a >= b {
		return a
	}

	return b
}

func getFactor(num int) []int {
	result := []int{}

	for i := 1; i <= int(math.Sqrt(float64(num))); i++ {
		if num%i == 0 {
			result = append(result, i)
			result = append(result, num/i)
		}
	}

	return result
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strings"
)

/*

 */

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	bld := strings.Builder{}

	var t = 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		var n int
		scanf("%d\n", &n)

		fmt.Fprintln(&bld, n-2, 1, 1)
	}

	printf("%s", bld.String())
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

//goland:noinspection GoUnusedType
type pair struct {
	x int64
	y int64
}

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//goland:noinspection GoUnusedFunction
func isPrime(n int) bool {
	if n == 2 || n == 3 {
		return true
	}

	if n <= 1 || n%2 == 0 || n%3 == 0 {
		return false
	}

	for i := 5; i*i <= n; i += 6 {
		if n%i == 0 || n%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func split(n int) (int, int) {
	a := 2
	b := n - 2
	for gcd(a, b) != 1 {
		a++
		b--
	}
	return a, b
}

func main() {
	var ntc int
	fmt.Fscan(in, &ntc)
	for t := 0; t < ntc; t++ {
		var n int
		fmt.Fscan(in, &n)
		if n%2 == 0 {
			fmt.Fprintf(out, "%d %d 1\n", n/2-1, n/2)
		} else {
			a, b := split(n / 2)
			fmt.Fprintf(out, "%d %d 1\n", a, b)
		}
	}
	out.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	reader = bufio.NewReader(os.Stdin)
	t, n   int
)

func solve(n int) (int, int, int) {
	return n - 2, 1, 1
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		fmt.Println(solve(n))
	}
}


Suppose you have two points $$$p = (x_p, y_p)$$$ and $$$q = (x_q, y_q)$$$. Let's denote the Manhattan distance between them as $$$d(p, q) = |x_p - x_q| + |y_p - y_q|$$$.Let's say that three points $$$p$$$, $$$q$$$, $$$r$$$ form a bad triple if $$$d(p, r) = d(p, q) + d(q, r)$$$.Let's say that an array $$$b_1, b_2, \dots, b_m$$$ is good if it is impossible to choose three distinct indices $$$i$$$, $$$j$$$, $$$k$$$ such that the points $$$(b_i, i)$$$, $$$(b_j, j)$$$ and $$$(b_k, k)$$$ form a bad triple.You are given an array $$$a_1, a_2, \dots, a_n$$$. Calculate the number of good subarrays of $$$a$$$. A subarray of the array $$$a$$$ is the array $$$a_l, a_{l + 1}, \dots, a_r$$$ for some $$$1 \le l \le r \le n$$$.Note that, according to the definition, subarrays of length $$$1$$$ and $$$2$$$ are good.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 5000$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$). It's guaranteed that the sum of $$$n$$$ doesn't exceed $$$2 \cdot 10^5$$$.

For each test case, print the number of good subarrays of array $$$a$$$.

package main

import (
	"bufio"
	"io/ioutil"
	"os"
	"strconv"
)

var bytes []byte
var l, max int

func ReadInt() int {
	b := bytes[l]

	for b < '0' || b > '9' {
		l++
		b = bytes[l]
	}

	result := 0
	for '0' <= b && b <= '9' {
		result = result*10 + int(b-'0')

		l++
		if l > max {
			return result
		}
		b = bytes[l]
	}
	return result
}

func main() {
	bytes, _ = ioutil.ReadAll(bufio.NewReader(os.Stdin))
	max = len(bytes) - 1
	writer := bufio.NewWriter(os.Stdout)

	t := ReadInt()
	for _t := 0; _t < t; _t++ {
		n := ReadInt()
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = ReadInt()
		}

		sum := int64(0)
		for i := 0; i < n; i++ {
			asc1 := a[i]
			asc2 := int(1e9 + 1)
			desc1 := a[i]
			desc2 := 0
			sum++
			for j := i + 1; j < n; j++ {
				if a[j] >= asc2 {
					break
				} else if a[j] >= asc1 {
					asc2 = a[j]
				} else {
					asc1 = a[j]
				}
				if a[j] <= desc2 {
					break
				} else if a[j] <= desc1 {
					desc2 = a[j]
				} else {
					desc1 = a[j]
				}
				sum++
			}
		}

		writer.WriteString(strconv.FormatInt(sum, 10) + "\n")
	}

	writer.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var in = bufio.NewReader(os.Stdin)

func isBadTriple(a, b, c int) bool {
	if (a <= b) && (b <= c) {
		return true
	}
	if (a >= b) && (b >= c) {
		return true
	}
	return false
}

func solve() {
	var n int
	fmt.Fscan(in, &n)

	a := make([]int, n)
	for i := range a {
		fmt.Fscan(in, &a[i])
	}

	var result int64 = int64(n) + int64(n-1)
	for i := 2; i < n; i++ {
		if !isBadTriple(a[i-2], a[i-1], a[i]) {
			result++
		}
	}

	for i := 3; i < n; i++ {
		if isBadTriple(a[i-3], a[i-2], a[i-1]) {
			continue
		}
		if isBadTriple(a[i-3], a[i-2], a[i]) {
			continue
		}
		if isBadTriple(a[i-3], a[i-1], a[i]) {
			continue
		}
		if isBadTriple(a[i-2], a[i-1], a[i]) {
			continue
		}
		result++
	}
	fmt.Println(result)
}

func main() {
	var t int
	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		solve()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func abs( x int ) int{
	if x<0{
		return -x
	}
	return x
}
func d(x1,y1,x2,y2 int) int{
	return abs(x1-x2) + abs(y1-y2)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for c:=1;c<=t;c++{
		var n int
		fmt.Fscan(in,&n)
		var a [200005]int
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&a[i])
		}
		var ans int
		ans = n+n-1 // 1s and 2s
		for i:=1;i<=n-2;i++{
			flag := false
			if d(a[i],i,a[i+2],i+2) == d(a[i+1],i+1,a[i],i) + d(a[i+1],i+1,a[i+2],i+2){
				if(i==1) {
				}
				flag = true
			}

			if flag == false{
				ans++
			}
		}
		for i:=1;i<=n-3;i++{
			flag := false
			for j:=i;j<=i+3;j++{
				for k:=j+1;k<=i+3;k++{
					for v:=k+1;v<=i+3;v++{
						if k!=j && v!=k &&j!=v{
							if d(a[j],j,a[v],v) == d(a[k],k,a[j],j) + d(a[k],k,a[v],v){
								flag = true
							}
						}
					}
				}
			}
			if flag == false{
				ans++
			}
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1550C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int64, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		ans := n*2 - 1
		for i := 0; i < n-2; i++ {
			if (a[i]-a[i+1])*(a[i+1]-a[i+2]) < 0 {
				ans++
			}
		}
		for i := 0; i < n-3; i++ {
			if (a[i+1]-a[i+3])*(a[i+3]-a[i+2]) > 0 && (a[i+1]-a[i])*(a[i]-a[i+2]) > 0 {
				ans++
			}
		}
		Fprintln(out, ans)
	}
}

func main() { CF1550C(os.Stdin, os.Stdout) }

package main

import "fmt"

func BinarySearch(a []int, l []int, length int, value int, flagAsc bool) int {
	lb := 0
	ub := length

	for lb < ub {
		mid := (lb + ub + 1) / 2
		if flagAsc {
			if a[l[mid]] <= value {
				lb = mid
			} else {
				ub = mid - 1
			}
		} else {
			if a[l[mid]] >= value {
				lb = mid
			} else {
				ub = mid - 1
			}
		}
	}

	return lb
}

func main() {
	var t int
	fmt.Scan(&t)
	for _t := 0; _t < t; _t++ {
		var n int
		fmt.Scan(&n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Scan(&a[i])
		}

		lAsc := make([]int, n+1)
		lDesc := make([]int, n+1)
		prevAsc := make([]int, n)
		prevDesc := make([]int, n)
		longestAsc := 0
		longestDesc := 0
		left := make([]int, n)
		for i := 0; i < n; i++ {
			indexAsc := BinarySearch(a, lAsc, longestAsc, a[i], true)
			indexDesc := BinarySearch(a, lDesc, longestDesc, a[i], false)
			if indexAsc == 0 {
				prevAsc[i] = -1
				left[i] = -1
			} else {
				prevAsc[i] = lAsc[indexAsc]
				left[i] = prevAsc[lAsc[indexAsc]]
			}
			if indexDesc == 0 {
				prevDesc[i] = -1
			} else {
				prevDesc[i] = lDesc[indexDesc]
				if prevDesc[lDesc[indexDesc]] > left[i] {
					left[i] = prevDesc[lDesc[indexDesc]]
				}
			}

			indexAsc++
			lAsc[indexAsc] = i
			if longestAsc < indexAsc {
				longestAsc = indexAsc
			}
			indexDesc++
			lDesc[indexDesc] = i
			if longestDesc < indexDesc {
				longestDesc = indexDesc
			}
		}

		sum := int64(0)
		min := make([]int, n)
		for i := 0; i < n; i++ {
			min[i] = n
			if left[i] == -1 {
				continue
			}
			if min[left[i]] > i {
				min[left[i]] = i
			}
		}

		right := n
		for i := n - 1; i >= 0; i-- {
			if min[i] < right {
				right = min[i]
			}
			sum += int64(right - i)
		}

		fmt.Println(sum)
	}
}

package main

import "fmt"

func BinarySearch(a []int, l []int, length int, value int, flagAsc bool) int {
	lb := 0
	ub := length

	for lb < ub {
		mid := (lb + ub + 1) / 2
		if flagAsc {
			if a[l[mid]] <= value {
				lb = mid
			} else {
				ub = mid - 1
			}
		} else {
			if a[l[mid]] >= value {
				lb = mid
			} else {
				ub = mid - 1
			}
		}
	}

	return lb
}

func main() {
	var t int
	fmt.Scan(&t)
	for _t := 0; _t < t; _t++ {
		var n int
		fmt.Scan(&n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Scan(&a[i])
		}

		lAsc := make([]int, n+1)
		lDesc := make([]int, n+1)
		prevAsc := make([]int, n)
		prevDesc := make([]int, n)
		longestAsc := 0
		longestDesc := 0
		left := make([]int, n)
		for i := 0; i < n; i++ {
			indexAsc := BinarySearch(a, lAsc, longestAsc, a[i], true)
			indexDesc := BinarySearch(a, lDesc, longestDesc, a[i], false)
			if indexAsc == 0 {
				prevAsc[i] = -1
				left[i] = -1
			} else {
				prevAsc[i] = lAsc[indexAsc]
				left[i] = prevAsc[lAsc[indexAsc]]
			}
			if indexDesc == 0 {
				prevDesc[i] = -1
			} else {
				prevDesc[i] = lDesc[indexDesc]
				if prevDesc[lDesc[indexDesc]] > left[i] {
					left[i] = prevAsc[lDesc[indexDesc]]
				}
			}

			indexAsc++
			lAsc[indexAsc] = i
			if longestAsc < indexAsc {
				longestAsc = indexAsc
			}
			indexDesc++
			lDesc[indexDesc] = i
			if longestDesc < indexDesc {
				longestDesc = indexDesc
			}
		}

		sum := int64(0)
		min := make([]int, n)
		for i := 0; i < n; i++ {
			min[i] = n
			if left[i] == -1 {
				continue
			}
			if min[left[i]] > i {
				min[left[i]] = i
			}
		}

		right := n
		for i := n - 1; i >= 0; i-- {
			if min[i] < right {
				right = min[i]
			}
			sum += int64(right - i)
		}

		fmt.Println(sum)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var in = bufio.NewReader(os.Stdin)

func isBadTriple(a, b, c int) bool {
	if (a <= b) && (b <= c) {
		return true
	}
	if (a >= b) && (b >= c) {
		return true
	}
	return false
}

func solve() {
	var n int
	fmt.Fscan(in, &n)

	a := make([]int, n)
	for i := range a {
		fmt.Fscan(in, &a[i])
	}

	var result int64 = int64(n) + int64(n-1)
	for i := 2; i < n; i++ {
		if !isBadTriple(a[i-2], a[i-1], a[0]) {
			result++
		}
	}

	for i := 3; i < n; i++ {
		if isBadTriple(a[i-3], a[i-2], a[i-1]) {
			continue
		}
		if isBadTriple(a[i-3], a[i-2], a[i]) {
			continue
		}
		if isBadTriple(a[i-3], a[i-1], a[i]) {
			continue
		}
		if isBadTriple(a[i-2], a[i-1], a[i]) {
			continue
		}
		result++
	}
	fmt.Println(result)
}

func main() {
	var t int
	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		solve()
	}
}


YouKn0wWho has an integer sequence $$$a_1, a_2, \ldots a_n$$$. Now he will split the sequence $$$a$$$ into one or more consecutive subarrays so that each element of $$$a$$$ belongs to exactly one subarray. Let $$$k$$$ be the number of resulting subarrays, and $$$h_1, h_2, \ldots, h_k$$$ be the lengths of the longest increasing subsequences of corresponding subarrays.For example, if we split $$$[2, 5, 3, 1, 4, 3, 2, 2, 5, 1]$$$ into $$$[2, 5, 3, 1, 4]$$$, $$$[3, 2, 2, 5]$$$, $$$[1]$$$, then $$$h = [3, 2, 1]$$$.YouKn0wWho wonders if it is possible to split the sequence $$$a$$$ in such a way that the bitwise XOR of $$$h_1, h_2, \ldots, h_k$$$ is equal to $$$0$$$. You have to tell whether it is possible.The longest increasing subsequence (LIS) of a sequence $$$b_1, b_2, \ldots, b_m$$$ is the longest sequence of valid indices $$$i_1, i_2, \ldots, i_k$$$ such that $$$i_1 \lt i_2 \lt \ldots \lt i_k$$$ and $$$b_{i_1} \lt b_{i_2} \lt \ldots \lt b_{i_k}$$$. For example, the LIS of $$$[2, 5, 3, 3, 5]$$$ is $$$[2, 3, 5]$$$, which has length $$$3$$$.An array $$$c$$$ is a subarray of an array $$$b$$$ if $$$c$$$ can be obtained from $$$b$$$ by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10\,000$$$)  — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 10^5$$$). The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$3 \cdot 10^5$$$.

For each test case, print "YES" (without quotes) if it is possible to split into subarrays in the desired way, print "NO" (without quotes) otherwise. You can print each letter in any register (upper or lower).

NoteIn the first test case, YouKn0wWho can split the sequence in the following way: $$$[1, 3, 4]$$$, $$$[2, 2]$$$, $$$[1, 5]$$$. This way, the LIS lengths are $$$h = [3, 1, 2]$$$, and the bitwise XOR of the LIS lengths is $$$3 \oplus 1 \oplus 2 = 0$$$.In the second test case, it can be shown that it is impossible to split the sequence into subarrays that will satisfy the condition.

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main()  {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var t int
	for fmt.Fscan(in,&t);t>0;t-- {
		var n int
		fmt.Fscan(in,&n)
		a:=make([]int,n)
		flag:=false
		for index,_:=range a {
			fmt.Fscan(in,&a[index])
		}
		for i:=1;i<n;i++ {
			if a[i-1]>=a[i] {
				flag=true
			}
		}
		if flag || n%2==0 {
			fmt.Fprintln(out,"YES")
		}else{
			fmt.Fprintln(out,"NO")
		}
	}
}

package main

import (
	"fmt"
	"bufio"
	"os"
)

var (
	input = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assert!")}
}

func main() {
    defer output.Flush()
    //solve()
    //return
	var t int64
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
}

func solve() {
    var n int
    fmt.Fscan(input, &n)
    a := make([]int, n)
    for i := 0; i < len(a); i++ {
        fmt.Fscan(input, &a[i])
    }
    if len(a) & 1 == 0 {
        fmt.Fprintln(output, "YES")
        return
    }
    for i := 1; i < len(a); i++ {
        if a[i - 1] >= a[i] {
            fmt.Fprintln(output, "YES")
            return
        }
    }

    fmt.Fprintln(output, "NO")
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		arr := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &arr[i])
		}

		var f bool
		for i := 1; i < n; i++ {
			if arr[i-1] >= arr[i] {
				f = true
				break
			}
		}

		if n%2 == 0 || f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")

		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		n := readInt(reader)
		a := readArrayInt64(reader)
		a = append(a, -1)

		var cnt = 1
		for i := 1; i <= n; i++ {
			if a[i-1] < a[i] {
				cnt++
			} else {
				break
			}
		}
		if cnt == n && cnt % 2 == 1 {
			fmt.Fprintln(writer, "NO")
		} else {
			fmt.Fprintln(writer, "YES")
		}

		t--
	}

	writer.Flush()
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var tc int
	fmt.Fscan(in, &tc)
	for ; tc > 0; tc-- {
		var n, a int
		fmt.Fscan(in, &n)
		allinc := true
		for i := 0; i < n; i++ {
			var aa int
			fmt.Fscan(in, &aa)
			if aa <= a {
				allinc = false
			}
			a = aa
		}
		if n%2 == 0 || (n >= 3 && !allinc) {
			out.WriteString("YES\n")
		} else {
			out.WriteString("NO\n")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
// 	redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		B()
	}
}

func B() {
	var n int
	scan(&n)
	var a = make([]int, n)
	for i := range a {
		scan(&a[i])
	}
	if n%2 == 0 {
		printf("YES\n")
		return
	}
	ok := false
	for i := 0; i < n-1; i++ {
		if a[i] >= a[i+1] {
			ok = true
		}
	}
	if !ok {
		printf("NO\n")
	} else {
		printf("YES\n")
	}
}

func solve() {
	var n int
	scan(&n)
	var g = make([][]int, n)
	for i := 0; i < n-1; i++ {
		var u, v int
		scan(&u, &v)
		u--
		v--
		g[u] = append(g[u], v)
		g[v] = append(g[v], u)
	}

	var (
		color     = make([]int, n)
		colorSize = [2]int{}
		bicolor   func(u, c int)
	)
	for i := range color {
		color[i] = -1
	}
	bicolor = func(u, c int) {
		if color[u] != -1 {
			return
		}
		color[u] = c
		colorSize[c]++
		for _, v := range g[u] {
			bicolor(v, c^1)
		}
	}
	bicolor(0, 0)

}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var N int
var a[]int

func main() {

	r := bufio.NewReader(os.Stdin)

	var t int

	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		fmt.Fscan(r, &N)

		a = make([]int, N)

		for j := 0; j < N; j++ {
			fmt.Fscan(r, &a[j])
		}

		ans := solve()

		fmt.Println(ans)
	}
}

func solve() string {
	if N % 2 == 0 {
		return "YES"
	}
	for i := 0; i < N - 1; i++ {
		if a[i] < a[i + 1] {
			continue
		}
		return "YES"
	}
	return "NO"
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

/*
7
7
1 3 4 2 2 1 5
3
1 3 4
5
1 3 2 4 2
4
4 3 2 1
5
2 3 4 4 5
3
1 1 1
3
1 2 3
---
YES
NO
YES
YES
YES
YES
NO
=======
1
5
1 6 3 4 5
*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	bld := strings.Builder{}

	var t int
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		var n int
		scanf("%d\n", &n)

		hasNonIncreasingConsecutivePair := false

		prev := -1
		for i := 0; i < n; i++ {
			var cur int
			scanf("%d", &cur)

			if prev > 0 && cur <= prev {
				hasNonIncreasingConsecutivePair = true
			}

			prev = cur
		}
		scanf("\n")

		possible := n%2 == 0 || hasNonIncreasingConsecutivePair

		if possible {
			fmt.Fprintln(&bld, "YES")
		} else {
			fmt.Fprintln(&bld, "NO")
		}
	}

	printf("%s", bld.String())
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

//goland:noinspection GoUnusedType
type pair struct {
	fst rune
	snd int
}

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//goland:noinspection GoUnusedFunction
func isPrime(n int) bool {
	if n == 2 || n == 3 {
		return true
	}

	if n <= 1 || n%2 == 0 || n%3 == 0 {
		return false
	}

	for i := 5; i*i <= n; i += 6 {
		if n%i == 0 || n%(i+2) == 0 {
			return false
		}
	}

	return true
}

package main

import (
	"fmt"
	"bufio"
	"os"
)

var (
	input = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assert!")}
}

func main() {
    defer output.Flush()
    //solve()
    //return
	var t int64
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
}

func solve() {
    var n int
    fmt.Fscan(input, &n)
    a := make([]int, n)
    for i := 0; i < len(a); i++ {
        fmt.Fscan(input, &a[i])
    }
    if len(a) == 1 {
        fmt.Fprintln(output, "NO")
        return
    }
    if len(a) & 1 == 0 {
        fmt.Fprintln(output, "YES")
        return
    }
    for i := 1; i < len(a); i++ {
        if a[i - 1] > a[i] {
            fmt.Fprintln(output, "YES")
            return
        }
    }

    fmt.Fprintln(output, "NO")
}

package main

import (
	"fmt"
	"bufio"
	"os"
)

var (
	input = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assert!")}
}

func main() {
    defer output.Flush()
    //solve()
    //return
	var t int64
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
}

func solve() {
    var n int
    fmt.Fscan(input, &n)
    a := make([]int, n)
    for i := 0; i < len(a); i++ {
        fmt.Fscan(input, &a[i])
    }
    if len(a) & 1 == 0 {
        fmt.Fprintln(output, "YES")
        return
    }
    for i := 1; i < len(a); i++ {
        if a[i - 1] > a[i] {
            fmt.Fprintln(output, "YES")
            return
        }
    }

    fmt.Fprintln(output, "NO")
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		n := readInt(reader)
		a := readArrayInt64(reader)
		a = append(a, -1)

		var cnt int = 1
		for i := 1; i <= n; i++ {
			if a[i-1] <= a[i] {
				cnt++
			} else {
				break
			}
		}
		if cnt == n && cnt % 2 == 1 {
			fmt.Fprintln(writer, "NO")
		} else {
			fmt.Fprintln(writer, "YES")
		}

		t--
	}

	writer.Flush()
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var tc int
	fmt.Fscan(in, &tc)
	for ; tc > 0; tc-- {
		var n, a int
		fmt.Fscan(in, &n)
		allinc := true
		for i := 0; i < n; i++ {
			var aa int
			fmt.Fscan(in, &aa)
			if aa < a {
				allinc = false
			}
			a = aa
		}
		if n%2 == 0 || (n >= 3 && !allinc) {
			out.WriteString("YES\n")
		} else {
			out.WriteString("NO\n")
		}
	}
}