package main

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

const (
	MOD = 998244353
	N   = 1000005
)

func solve(in io.Reader, out io.Writer) {
	var n int
	var k int
	Fscan(in, &n, &k)

	var v int32
	var ans int64 = 1
	for i := 0; i < n; i++ {
		Fscan(in, &v)
		if i >= n-k {
			if v > 0 {
				ans = 0
			}
		} else if v == -1 {
			ans = ans * int64(i+k+1) % MOD
		} else if v == 0 {
			ans = ans * int64(k+1) % MOD
		}
	}
	if ans != 0 {
		for i := 1; i <= k; i++ {
			ans = ans * int64(i) % MOD
		}
	}

	Fprintln(out, ans)

}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var T int
	for Fscan(in, &T); T > 0; T-- {
		solve(in, out)
	}
}

package main

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

const (
	MOD = 998244353
	N   = 1000005
)

var fac []int64

func initialize() {
	fac = make([]int64, N)
	fac[0] = 1
	for i := 1; i < N; i++ {
		fac[i] = fac[i-1] * int64(i) % MOD
	}
}
func solve(in io.Reader, out io.Writer) {
	var n int
	var k int
	Fscan(in, &n, &k)

	var v int32
	ans := fac[k]
	for i := 0; i < n; i++ {
		Fscan(in, &v)
		if i >= n-k {
			if v > 0 {
				ans = 0
			}
		} else if v == -1 {
			ans = ans * int64(i+k+1) % MOD
		} else if v == 0 {
			ans = ans * int64(k+1) % MOD
		}
	}

	Fprintln(out, ans)

}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	initialize()
	var T int
	for Fscan(in, &T); T > 0; T-- {
		solve(in, out)
	}
}

package main

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

const (
	MOD = 998244353
	N   = 1000005
)

var fac []int64

func initialize() {
	fac = make([]int64, N)
	fac[0] = 1
	for i := 1; i < N; i++ {
		fac[i] = fac[i-1] * int64(i) % MOD
	}
}
func solve(in io.Reader, out io.Writer) {
	var n int
	var k int
	Fscan(in, &n, &k)

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

	for i := n - 1; i >= n-k; i-- {
		if v[i] > 0 {
			Fprintln(out, 0)
			return
		}
	}

	ans := fac[k]
	for i := 0; i < n-k; i++ {
		if v[i] == -1 {
			ans = ans * int64(i+k+1) % MOD
		} else if v[i] == 0 {
			ans = ans * int64(k+1) % MOD
		}
	}
	Fprintln(out, ans)

}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	initialize()
	var T int
	for Fscan(in, &T); T > 0; T-- {
		solve(in, out)
	}
}

package main

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

const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<16),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()
	neg := false

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
		if b == '-' {
			neg = true
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	if neg {
		return -x
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

const mod = 998244353

func main() {
	myio := NewIO(os.Stdin, os.Stdout)
	defer myio.Flush()

	t := myio.ReadInt()
	sol := func() {
		n := myio.ReadInt()
		k := myio.ReadInt()
		var ans int64 = 1
		for i := 1; i <= k; i++ {
			ans = ans * (int64)(i) % mod
		}
		for j := 0; j < n; j++ {
			vj := myio.ReadInt()
			i := j + k
			if i >= n {
				if vj > 0 {
					ans = 0
				}
			} else {
				if vj == -1 {
					ans = ans * (int64)(i+1) % mod //
				} else if vj == 0 {
					ans = ans * (int64)(k+1) % mod // 0-k
				}
			}
		}
		myio.Println(ans)
	}
	for ; t > 0; t-- {
		sol()
	}
}

package main

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

const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<12),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()
	neg := false

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
		if b == '-' {
			neg = true
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	if neg {
		return -x
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

const mod = 998244353

func main() {
	myio := NewIO(os.Stdin, os.Stdout)
	defer myio.Flush()

	t := myio.ReadInt()
	sol := func() {
		n := myio.ReadInt()
		k := myio.ReadInt()
		var ans int64 = 1
		for i := 1; i <= k; i++ {
			ans = ans * (int64)(i) % mod
		}
		for j := 0; j < n; j++ {
			vj := myio.ReadInt()
			i := j + k
			if i >= n {
				if vj > 0 {
					ans = 0
				}
			} else {
				if vj == -1 {
					ans = ans * (int64)(i+1) % mod
				} else if vj == 0 {
					ans = ans * (int64)(k+1) % mod
				}
			}
		}
		myio.Println(ans)
	}
	for ; t > 0; t-- {
		sol()
	}
}

package main

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

const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<12),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()
	neg := false

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
		if b == '-' {
			neg = true
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	if neg {
		return -x
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

const mod = 998244353

func main() {
	myio := NewIO(os.Stdin, os.Stdout)
	defer myio.Flush()

	t := myio.ReadInt()
	sol := func() {
		n := myio.ReadInt()
		k := myio.ReadInt()
		var ans int64 = 1
		for i := 1; i <= k; i++ {
			ans = ans * (int64)(i) % mod
		}
		for j := 0; j < n; j++ {
			vj := myio.ReadInt()
			i := j + k
			if i >= n {
				if vj > 0 {
					ans = 0
				}
			} else {
				if vj == -1 {
					ans = ans * (int64)(i+1) % mod //
				} else if vj == 0 {
					ans = ans * (int64)(k+1) % mod // 0-k
				}
			}
		}
		myio.Println(ans)
	}
	for ; t > 0; t-- {
		sol()
	}
}

package main

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

const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<12),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()
	neg := false

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
		if b == '-' {
			neg = true
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	if neg {
		return -x
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

const mod = 998244353

func main() {
	myio := NewIO(os.Stdin, os.Stdout)
	defer myio.Flush()

	t := myio.ReadInt()
	sol := func() {
		n := myio.ReadInt()
		k := myio.ReadInt()
		v := make([]int, n)
		var ans int64 = 1
		for i := 1; i <= k; i++ {
			ans = ans * (int64)(i) % mod
		}
		for i := 0; i < n; i++ {
			v[i] = myio.ReadInt()
		}
		for i := k; i < n; i++ {
			j := i - k
			if v[j] == -1 {
				ans = ans * (int64)(i+1) % mod //
			} else if v[j] == 0 {
				ans = ans * (int64)(k+1) % mod // 0-k
			}
		}
		for i := n - k; i < n; i++ {
			if v[i] > 0 {
				ans = 0
				break
			}
		}
		myio.Println(ans)
	}
	for ; t > 0; t-- {
		sol()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int     { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }
func gis(n int) []int  { res := make([]int,n); for i:=0;i<n;i++ { res[i] = gi() }; return res }
const MOD int64 = 998244353
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	T := gi()
	for tt:=1;tt<=T;tt++ {
		N,K := gi(),gi()
		V := gis(N)
		bad := false; ans := int64(1)
		// First, the last K entries should be the last entries of P in sorted order, so Vi should be 0 or -1
		for i:=1;i<=K;i++ { ans *= int64(i); ans %= MOD }
		for i,v := range V {
			if i < N-K {
				if v == -1 { ans *= int64(i+K+1); ans %= MOD }
				if v == 0  { ans *= int64(K+1); ans %= MOD }
			} else {
				if v != -1 && v != 0 { bad = true }
			}
		}
		if bad { ans = 0 }
		fmt.Fprintln(wrtr,ans)
	}
}

package main

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

const (
	MOD = 998244353
	N   = 1000005
)

func solve(myio *MyIO) {
	var n int
	var k int
	//Fscan(in, &n, &k)
	n = myio.ReadInt()
	k = myio.ReadInt()

	var v int32
	var ans int64 = 1
	for i := 0; i < n; i++ {
		v = int32(myio.ReadInt())
		if i >= n-k {
			if v > 0 {
				ans = 0
			}
		} else if v == -1 {
			ans = ans * int64(i+k+1) % MOD
		} else if v == 0 {
			ans = ans * int64(k+1) % MOD
		}
	}
	if ans != 0 {
		for i := 1; i <= k; i++ {
			ans = ans * int64(i) % MOD
		}
	}

	myio.Println(ans)
}

const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<16),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()
	neg := false

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
		if b == '-' {
			neg = true
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	if neg {
		return -x
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return Fprint(myio.out, a...)
}

func main() {
	//in := bufio.NewReader(os.Stdin)
	//out := bufio.NewWriter(os.Stdout)
	//defer out.Flush()
	myio := NewIO(os.Stdin, os.Stdout)
	defer myio.Flush()
	var T int
	for T = myio.ReadInt(); T > 0; T-- {
		solve(myio)
	}
}

package main

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

const (
	MOD = 998244353
	N   = 1000005
)

var fac []int64

func initialize() {
	fac = make([]int64, N)
	fac[0] = 1
	for i := 1; i < N; i++ {
		fac[i] = fac[i-1] * int64(i) % MOD
	}
}
func solve(in io.Reader, out io.Writer) {
	var n int
	var k int
	Fscan(in, &n, &k)

	var v int32
	ans := fac[k]
	for i := 0; i < n; i++ {
		Fscan(in, &v)
		if i >= n-k {
			if v > 0 {
				ans = 0
			}
		} else if v == 0 {
			ans = ans * int64(i+k+1) % MOD
		} else if v == -1 {
			ans = ans * int64(k+1) % MOD
		}
	}

	Fprintln(out, ans)

}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	initialize()
	var T int
	for Fscan(in, &T); T > 0; T-- {
		solve(in, out)
	}
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		line := readLine(reader)
		n, _ := strconv.Atoi(string(line))
		line = readLine(reader)
		ans := strings.Split(string(line), " ")
		m := make(map[int]int)
		an := make([]int, n)
		flag := false
		for i := 0; i < n; i++ {
			x, _ := strconv.Atoi(ans[i])
			an[i] = x
			if i>=1 {
				v := m[x]
				v++
				m[x] = v
			}
		}
		// fmt.Println(m)
		for i := 1; i < n-1; i++ {
			if v := m[an[i]]; v==1 {
				delete(m, an[i])
			} else {
				m[an[i]] = v-1
			}
			if _, ok := m[an[i-1]]; ok {
				flag = true
				break
			}
		}
		if flag {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

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

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

	var T, n, e int
	fmt.Fscan(r, &T)
	for t := 0; t < T; t++ {
		fmt.Fscan(r, &n)
		m := make(map[int]int)
		suc := false
		for i := 0; i < n; i++{
			fmt.Fscan(r, &e)
			v, ok := m[e]
			if ok && i-v > 1 {
				suc = true
			}
			if !ok {
				m[e] = i
			}
		}
		if suc {
			fmt.Fprint(w, "YES\n")
		}else {
			fmt.Fprint(w, "NO\n")
		}
	}

}

package main

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

func readInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	return t
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	t := readInt(scanner)
	for i := 0; i < t; i++ {
		n := readInt(scanner)
		idx := make([]int, n+1)

		for j := range(idx) {
			idx[j] = -1
		}

		found := false
		for j := 0; j < n; j++ {
			x := readInt(scanner)
			if idx[x] == -1 {
				idx[x] = j
			} else if j - idx[x] > 1 {
				found = true
			}
		}

		if found {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

func main(){

	var t,n int
	fmt.Scan(&t)

	for T := 0 ; T < t ; T ++ {
		fmt.Scan(&n)
		a := make([]int , n)

		for i := 0 ; i < n ; i ++ {
			fmt.Scan(&a[i])
		}

		m := make(map[int]int)
		q := 0
		for i := 0 ; i < n ; i ++ {
			val , ok := m[a[i]]
			if ok == true {
				if  (i - val) > 1 {
					q = 1
					break
				}
			} else {
				m[a[i]] = i
			}
		}

		if q == 1 {
			fmt.Println("YES")
		} else {
			fmt.Println( "NO")
		}
	}
}

package main

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

const N int = 5005

var y [N]int
var t int

func null() {
	for i := 0; i < N; i++ {
		y[i] = 0
	}
}

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		null()
		var n int
		fmt.Fscan(input, &n)

		ok := false
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(input, &arr[i])
			y[arr[i]]++

			if y[arr[i]] == 3 {
				ok = true
			}

			if i > 0 && y[arr[i]] == 2 && arr[i] != arr[i-1] {
				ok = true
			}
		}

		if ok == true {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

var inf int = 0x3f3f3f3f
var reader *bufio.Reader

func init() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader = bufio.NewReaderSize(stdin, 1<<20)
}

var t, n int

func main() {
	fmt.Fscan(reader, &t)
	for ; t != 0; t-- {
		fmt.Fscan(reader, &n)
		m := make(map[int][]int)
		for i := 0; i < n; i++ {
			var a int
			fmt.Fscan(reader, &a)
			m[a] = append(m[a], i)
		}
		ans := "NO"
		for _, v := range m {
			if len(v) == 1 {
				continue
			}
			for i := 1; i < len(v); i++ {
				if v[i] != v[i-1]+1 {
					ans = "YES"
					break
				}
				if i > 1 && v[i] == v[i-1]+1 && v[i] == v[i-2]+2 {
					ans = "YES"
					break
				}
			}
			if ans == "YES" {
				break
			}
		}
		fmt.Println(ans)
	}
}

package main

import (
	"fmt"
	"math"
)

// Node
type N struct {
	count    int
	position []int
}

func main() {
	var t, n, x int
	fmt.Scan(&t)
	for t != 0 {
		fmt.Scan(&n)
		var count map[int]*N = make(map[int]*N)
		for i := 0; i < n; i++ {
			fmt.Scan(&x)
			if count[x] == nil {
				count[x] = new(N)
			}
			count[x].count++
			count[x].position = append(count[x].position, i)
		}
		// fmt.Println(count)
		ans := false
		for _, v := range count {
			if v.count >= 3 {
				ans = true
				break
			} else if v.count == 2 {
				if int(math.Abs(float64(v.position[0]-v.position[1]))) != 1 {
					ans = true
					break
				}
			}
		}
		if ans == true {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
		t--
	}
}

package main

import (
   "bufio"
   "fmt"
   "math"
   "os"
   "sort"
   "strconv"
   "strings"
   "sync"
)

func main() {
   for t := ScanInt(); t > 0; t-- {
      n := ScanInt()
      a := ScanIntSlice(n)
      r := false
   outer:
      for i := 0; i < n; i++ {
         for k := i + 2; k < n; k++ {
            if a[i] == a[k] {
               r = true
               break outer
            }
         }
      }
      if r {
         P("YES")
      } else {
         P("NO")
      }
   }

   close(O)
   oWg.Wait()
}

/*********************** I/O ***********************/

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P = fmt.Println //func(a ...interface{}) (n int, err error)

func init() {
   //P = fmt.Println

   in = bufio.NewScanner(os.Stdin)
   in.Buffer(make([]byte, 1024), int(1e+9))
   in.Split(bufio.ScanWords)

   O = make(chan string, 16)
   oWg = &sync.WaitGroup{}
   oWg.Add(1)

   writer := bufio.NewWriter(os.Stdout)
   go func() {
      defer oWg.Done()
      defer writer.Flush()

      for line := range O {
         writer.WriteString(line + "\n")
      }
   }()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
   s := make([]string, n)
   for i := 0; i < n; i++ {
      s[i] = ScanWord()
   }
   return s
}
func ScanIntSlice(n int) []int {
   arr := make([]int, n)
   for i := 0; i < n; i++ {
      arr[i] = ScanInt()
   }
   return arr
}
func ScanInt64Slice(n int) []int64 {
   arr := make([]int64, n)
   for i := 0; i < n; i++ {
      arr[i] = ScanInt64()
   }
   return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
   sb := strings.Builder{}
   sb.Grow(len(a) * 9)
   for i := range a {
      sb.WriteString(strconv.Itoa(a[i]) + " ")
   }
   return sb.String()
}
func SArr64(a []int64) string {
   sb := strings.Builder{}
   sb.Grow(len(a) * 9)
   for i := range a {
      sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
   }
   return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
   minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
   for _, v := range args {
      if v < minVal {
         minVal = v
      }
      if v > maxVal {
         maxVal = v
      }
   }
   return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
   if a == 0 {
      return b
   }
   return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
   if x < 0 {
      return -x
   }
   return x
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(r, &t)
	for tc := 0; tc < t; tc++ {
		var n int
		fmt.Fscan(r, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &a[i])
		}
		rls := solve(a)
		if rls {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func solve(a []int) bool {
	m := make(map[int]int)
	for i, v := range a {
		idx, ok := m[v]
		if ok {
			if idx+1 != i {
				return true
			}
		} else {
			m[v] = i
		}
	}
	return false
}

package main

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

type heap struct {
	array []int
}

func (h *heap) push(val int) {
	h.array = append(h.array, val)
	cur := len(h.array) - 1
	for cur > 0 {
		var parent int
		if (cur & 1) == 1 {
			parent = (cur - 1) / 2
		} else {
			parent = (cur - 2) / 2
		}
		if h.array[cur] < h.array[parent] {
			h.array[cur], h.array[parent] = h.array[parent], h.array[cur]
			cur = parent
		} else {
			break
		}
	}
}

func (h *heap) pop() int {
	res := h.array[0]
	h.array[0], h.array[len(h.array)-1] = h.array[len(h.array)-1], h.array[0]
	h.array = h.array[:len(h.array)-1]
	cur := 0
	for cur < len(h.array) {
		smallest := cur
		if cur*2+1 < len(h.array) && h.array[smallest] > h.array[cur*2+1] {
			smallest = cur*2 + 1
		}
		if cur*2+2 < len(h.array) && h.array[smallest] > h.array[cur*2+2] {
			smallest = cur*2 + 2
		}
		if smallest != cur {
			h.array[smallest], h.array[cur] = h.array[cur], h.array[smallest]
			cur = smallest
		} else {
			break
		}
	}
	return res
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var T int
	Fscan(in, &T)
	for T > 0 {
		T--
		var n, tmp int
		Fscan(in, &n)
		cnt := make(map[int][]int)
		for i := 0; i < n; i++ {
			Fscan(in, &tmp)
			cnt[tmp] = append(cnt[tmp], i)
		}
		flag := false
		for _, arr := range cnt {
			if len(arr) > 2{
				flag = true
				break
			}
			for i := 1; i < len(arr); i++ {
				if arr[i] != arr[i-1]+1 {
					flag = true
					break
				}
			}
		}
		if flag {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
}

package main

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

var (
	reader Reader = NewReader()
	writer Writer = NewWriter()
)

type Reader interface {
	NextInt() int
	NextInt64() int64
	NextString() string
}

type Writer interface {
	Printf(format string, a ...interface{})
	Flush()
}

type readerImpl struct {
	*bufio.Scanner
}

func NewReader() Reader {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return &readerImpl{Scanner: s}
}

func (i *readerImpl) NextInt() int {
	i.Scan()
	ret, _ := strconv.Atoi(i.Text())
	return ret
}

func (i *readerImpl) NextInt64() int64 {
	i.Scan()
	ret, _ := strconv.ParseInt(i.Text(), 10, 64)
	return ret
}

func (i *readerImpl) NextString() string {
	i.Scan()
	return i.Text()
}

type writerImpl struct {
	*bufio.Writer
}

func NewWriter() Writer {
	return &writerImpl{Writer: bufio.NewWriter(os.Stdout)}
}

func (i *writerImpl) Printf(f string, a ...interface{}) {
	fmt.Fprintf(i.Writer, f, a...)
}

func (i *writerImpl) Flush() {
	i.Writer.Flush()
}

func main() {
	defer writer.Flush()
	t := reader.NextInt()
	for ; t > 0; t-- {
		n := reader.NextInt()
		tmp := []int{}
		for ; n > 0; n-- {
			tmp = append(tmp, reader.NextInt())
		}
		writer.Printf("%s\n", sol(tmp))
	}
}

func sol(aa []int) string {
	if len(aa) < 3 {
		return "NO"
	}
	lmap := map[int]int{}
	rmap := map[int]int{}
	for i := 0; i < len(aa); i++ {
		rmap[aa[i]]++
	}
	for i := 0; i < len(aa); i++ {
		rmap[aa[i]]--
		for k, v := range lmap {
			if v > 0 && rmap[k] > 0 {
				return "YES"
			}
		}
		lmap[aa[i]]++
	}
	return "NO"
}

package main

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

var (
	reader Reader = NewReader()
	writer Writer = NewWriter()
)

type Reader interface {
	NextInt() int
	NextInt64() int64
	NextString() string
}

type Writer interface {
	Printf(format string, a ...interface{})
	Flush()
}

type readerImpl struct {
	*bufio.Scanner
}

func NewReader() Reader {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return &readerImpl{Scanner: s}
}

func (i *readerImpl) NextInt() int {
	i.Scan()
	ret, _ := strconv.Atoi(i.Text())
	return ret
}

func (i *readerImpl) NextInt64() int64 {
	i.Scan()
	ret, _ := strconv.ParseInt(i.Text(), 10, 64)
	return ret
}

func (i *readerImpl) NextString() string {
	i.Scan()
	return i.Text()
}

type writerImpl struct {
	*bufio.Writer
}

func NewWriter() Writer {
	return &writerImpl{Writer: bufio.NewWriter(os.Stdout)}
}

func (i *writerImpl) Printf(f string, a ...interface{}) {
	fmt.Fprintf(i.Writer, f, a...)
}

func (i *writerImpl) Flush() {
	i.Writer.Flush()
}

func main() {
	defer writer.Flush()
	t := reader.NextInt()
	for ; t > 0; t-- {
		n := reader.NextInt()
		tmp := map[int][]int{}
		for i := 0; i < n; i++ {
			a := reader.NextInt()
			tmp[a] = append(tmp[a], i)
		}
		writer.Printf("%s\n", sol(tmp))
	}
}

func sol(aa map[int][]int) string {
    //writer.Printf("%v\n", aa)
	for _, pp := range aa {
        if len(pp) >= 3 {
            return "YES"
        }
        if (len(pp) == 2) && pp[1] - pp[0] > 1 {
            return "YES"
        }
	}
	return "NO"
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		var n, a, prev int
		fmt.Fscan(in, &n)
		d := make(map[int]bool, n)
		fmt.Fscan(in, &prev)
		result := "NO"
		for i := 1; i < n; i++ {
			fmt.Fscan(in, &a)
			if d[a] {
				result = "YES"
			}
			d[prev] = true
			prev = a
		}
		fmt.Fprintln(out, result)
	}
	out.Flush()
}

package main

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

func solve(in *bufio.Reader) string {
	var n, a, prev int
	fmt.Fscan(in, &n)
	d := make(map[int]bool)
	fmt.Fscan(in, &prev)
	for i := 1; i < n; i++ {
		fmt.Fscan(in, &a)
		if d[a] {
			return "YES"
		}
		d[prev] = true
		prev = a
	}
	return "NO"
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		fmt.Fprintln(out, solve(in))
	}
	out.Flush()
}

package main

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

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

	var T, n, e int
	fmt.Fscan(r, &T)
	for t := 0; t < T; t++ {
		fmt.Fscan(r, &n)
		m := make(map[int]int)
		suc := false
		for i := 0; i < n; i++{
			fmt.Fscan(r, &e)
			if v, ok := m[e]; ok && i-v > 1 {
				suc = true
			}
			m[e] = i
		}
		if suc {
			fmt.Fprint(w, "YES\n")
		}else {
			fmt.Fprint(w, "NO\n")
		}
	}

}

package main

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

const N int = 5005

var y [N]int
var t int

func null() {
	for i := 0; i < N; i++ {
		y[i] = 0
	}
}

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		null()
		var n int
		fmt.Fscan(input, &n)

		ok := false
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(input, &arr[i])
			y[arr[i]]++
			if i > 0 && y[arr[i]] >= 2 && arr[i] != arr[i-1] {
				ok = true
			}
		}

		if ok == true {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(input, &t)

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

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

		ok := false
		for i := 1; i < (n - 1); i++ {
			if arr[i-1] == arr[i+1] {
				ok = true
				break
			}

			if (i + 2) < n {
				if arr[i-1] == arr[i+2] && arr[i] == arr[i+1] {
					ok = true
					break
				}
			}
		}

		if ok == true {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(input, &t)

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

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

		if n == 4 {
			if arr[0] == arr[3] && arr[1] == arr[2] {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
			continue
		}

		ok := false
		for i := 1; i < (n - 1); i++ {
			if arr[i-1] == arr[i+1] {
				ok = true
				break
			}
		}

		if ok == true {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

var inf int = 0x3f3f3f3f
var reader *bufio.Reader

func init() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader = bufio.NewReaderSize(stdin, 1<<20)
}

var t, n int

func main() {
	fmt.Fscan(reader, &t)
	for ; t != 0; t-- {
		fmt.Fscan(reader, &n)
		m := make(map[int][]int)
		for i := 0; i < n; i++ {
			var a int
			fmt.Fscan(reader, &a)
			m[a] = append(m[a], i)
		}
		ans := "NO"
		for _, v := range m {
			if len(v) == 1 {
				continue
			}
			for i := 1; i < len(v); i++ {
				if v[i] != v[i-1]+1 {
					ans = "YES"
					break
				}
			}
			if ans == "YES" {
				break
			}
		}
		fmt.Println(ans)
	}
}

package main

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

type heap struct {
	array []int
}

func (h *heap) push(val int) {
	h.array = append(h.array, val)
	cur := len(h.array) - 1
	for cur > 0 {
		var parent int
		if (cur & 1) == 1 {
			parent = (cur - 1) / 2
		} else {
			parent = (cur - 2) / 2
		}
		if h.array[cur] < h.array[parent] {
			h.array[cur], h.array[parent] = h.array[parent], h.array[cur]
			cur = parent
		} else {
			break
		}
	}
}

func (h *heap) pop() int {
	res := h.array[0]
	h.array[0], h.array[len(h.array)-1] = h.array[len(h.array)-1], h.array[0]
	h.array = h.array[:len(h.array)-1]
	cur := 0
	for cur < len(h.array) {
		smallest := cur
		if cur*2+1 < len(h.array) && h.array[smallest] > h.array[cur*2+1] {
			smallest = cur*2 + 1
		}
		if cur*2+2 < len(h.array) && h.array[smallest] > h.array[cur*2+2] {
			smallest = cur*2 + 2
		}
		if smallest != cur {
			h.array[smallest], h.array[cur] = h.array[cur], h.array[smallest]
			cur = smallest
		} else {
			break
		}
	}
	return res
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var T int
	Fscan(in, &T)
	for T > 0 {
		T--
		var n, tmp int
		Fscan(in, &n)
		cnt := make(map[int][]int)
		for i := 0; i < n; i++ {
			Fscan(in, &tmp)
			cnt[tmp] = append(cnt[tmp], i)
		}
		flag := false
		for _, arr := range cnt {
			for i := 1; i < len(arr); i++ {
				if arr[i] != arr[i-1]+1 {
					flag = true
					break
				}
			}
		}
		if flag {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
}

package main

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

var (
	reader Reader = NewReader()
	writer Writer = NewWriter()
)

type Reader interface {
	NextInt() int
	NextInt64() int64
	NextString() string
}

type Writer interface {
	Printf(format string, a ...interface{})
	Flush()
}

type readerImpl struct {
	*bufio.Scanner
}

func NewReader() Reader {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return &readerImpl{Scanner: s}
}

func (i *readerImpl) NextInt() int {
	i.Scan()
	ret, _ := strconv.Atoi(i.Text())
	return ret
}

func (i *readerImpl) NextInt64() int64 {
	i.Scan()
	ret, _ := strconv.ParseInt(i.Text(), 10, 64)
	return ret
}

func (i *readerImpl) NextString() string {
	i.Scan()
	return i.Text()
}

type writerImpl struct {
	*bufio.Writer
}

func NewWriter() Writer {
	return &writerImpl{Writer: bufio.NewWriter(os.Stdout)}
}

func (i *writerImpl) Printf(f string, a ...interface{}) {
	fmt.Fprintf(i.Writer, f, a...)
}

func (i *writerImpl) Flush() {
	i.Writer.Flush()
}

func main() {
	defer writer.Flush()
	t := reader.NextInt()
	for ; t > 0; t-- {
		n := reader.NextInt()
		tmp := map[int][]int{}
		for i := 0; i < n; i++ {
			a := reader.NextInt()
			tmp[a] = append(tmp[a], i)
		}
		writer.Printf("%s\n", sol(tmp))
	}
}

func sol(aa map[int][]int) string {
	for _, pp := range aa {
		for k := range pp {
			if k-1 >= 0 && pp[k]-pp[k-1] > 1 {
				return "YES"
			}
			if k+1 < len(pp) && pp[k+1]-pp[k] > 1 {
				return "YES"
			}
		}
	}
	return "NO"
}


package main

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

func main() {
	sc := NewScanner()
	_, M, K := sc.NextInt(), sc.NextInt64(), sc.NextInt64()
	P := sc.NextInt64Array()

	a := int64(0)
	page := int64(1)
	cnt := 0
	geta := int64(0)
	for a < M {
		//fmt.Println(page)
		if P[a]-geta > K*page {
			page = 1 + (P[a]-geta)/K
			if (P[a]-geta)%K == 0 {
				page--
			}
			continue
		}
		for b := a; b < M; b++ {
			if P[b]-geta > K*page {
				cnt++
				geta += b - 1 - a + 1
				a = b
				break
			}
			if b == M-1 {
				geta += b - a + 1
				a = b + 1
				cnt++
			}
		}
		//fmt.Println(a, geta, page)
	}
	fmt.Println(cnt)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

// Author: sighduck
// URL: https://codeforces.com/contest/1191/problem/C

package main

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

func ceilDiv(n int64, d int64) int64 {
	return (n + d - 1) / d
}

func Solve(n int64, m int64, k int64, p []int64) int64 {
	removed := int64(0)
	moves := int64(0)
	for len(p) > 0 {
		specialPage := ceilDiv(p[0]-removed, k)
		count := int64(0)
		for len(p) > 0 && k*(specialPage-1) < (p[0]-removed) && (p[0]-removed) <= specialPage*k {
			p = p[1:]
			count += 1
		}
		removed += count
		moves += 1
	}
	return moves
}

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

	var n, m, k int64
	fmt.Fscanf(reader, "%d %d %d\n", &n, &m, &k)
	p := make([]int64, m)
	for i := int64(0); i < m; i++ {
		fmt.Fscanf(reader, "%d ", &p[i])
	}

	fmt.Fprintf(writer, "%d\n", Solve(n, m, k, p))
}

package main

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

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

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

func main() {
	defer writer.Flush()
	var n, m, t, k int64
	scanf("%d %d %d\n", &n, &m, &k)
	p := []int64{}

	for i := 0; i < int(m); i++ {
		scanf("%d", &t)
		p = append(p, t)
	}
	pos := 0
	deleted := int64(0)
	op := 0
	for {
		window := (p[pos] - deleted - 1) / k
		var ps int
		for ps = pos; ps < len(p); ps++ {
			windo := (p[ps] - deleted - 1) / k
			if windo != window {
				deleted = int64(ps-pos) + deleted
				op++
				pos = ps
				break
			}
		}
		// fmt.Println(pos, deleted)
		if ps == len(p) {
			op++
			break
		}
	}

	printf("%d", op)

}

package main

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

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

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

func main() {
	defer writer.Flush()
	var n, m, t, k int64
	scanf("%d %d %d\n", &n, &m, &k)
	p := []int64{}

	for i := 0; i < int(m); i++ {
		scanf("%d", &t)
		p = append(p, t)
	}
	pos := 0
	deleted := int64(0)
	op := 0
	for {
		window := (p[pos] - deleted) / k
		var ps int
		for ps = pos; ps < len(p); ps++ {
			windo := (p[ps] - deleted - 1) / k
			if windo != window {
				deleted = int64(ps-pos) + deleted
				op++
				pos = ps
			}
		}
		if ps == len(p) {
			op++
			break
		}
	}

	printf("%d", op)

}

package main

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

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

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

func main() {
	defer writer.Flush()
	var n, m, t, k int64
	scanf("%d %d %d\n", &n, &m, &k)
	p := []int64{}

	for i := 0; i < int(m); i++ {
		scanf("%d", &t)
		p = append(p, t)
	}
	pos := 0
	deleted := int64(0)
	op := 0
	for {
		window := (p[pos] - deleted - 1) / k
		var ps int
		for ps = pos; ps < len(p); ps++ {
			windo := (p[ps] - deleted - 1) / k
			if windo != window {
				deleted = int64(ps-pos) + deleted
				op++
				pos = ps
			}
		}
		// fmt.Println(pos, deleted)
		if ps == len(p) {
			op++
			break
		}
	}

	printf("%d", op)

}

package main

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

func main() {
	sc := NewScanner()
	_, M, K := sc.NextInt(), sc.NextInt64(), sc.NextInt64()
	P := sc.NextInt64Array()

	a := int64(0)
	page := int64(1)
	cnt := 0
	geta := int64(0)
	for a < M {
		//fmt.Println(page)
		if P[a]-geta > K*page {
			page = 1 + (P[a]-geta)/K
			continue
		}
		for b := a; b < M; b++ {
			if P[b]-geta > K*page {
				cnt++
				geta += b - 1 - a + 1
				a = b
				break
			}
			if b == M-1 {
				geta += b - a + 1
				a = b + 1
				cnt++
			}
		}
		//fmt.Println(a, geta, page)
	}
	fmt.Println(cnt)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

func main() {
	sc := NewScanner()
	_, M, K := sc.NextInt(), sc.NextInt64(), sc.NextInt64()
	P := sc.NextInt64Array()

	a := int64(0)
	page := int64(1)
	cnt := 0
	geta := int64(0)
	for a < M {
		//fmt.Println(page)
		if P[a]-geta > K*page {
			W := 1 + (P[a]-geta)/K
			if (P[a]-geta)%page > 0 {
				W++
			}
			page = W
			continue
		}
		for b := a; b < M; b++ {
			if P[b]-geta > K*page {
				cnt++
				geta += b - 1 - a + 1
				a = b
				break
			}
			if b == M-1 {
				geta += b - a + 1
				a = b + 1
				cnt++
			}
		}
		//fmt.Println(a, geta, page)
	}
	fmt.Println(cnt)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

func main() {
	sc := NewScanner()
	_, M, K := sc.NextInt(), sc.NextInt64(), sc.NextInt64()
	P := sc.NextInt64Array()

	a := int64(0)
	page := int64(1)
	cnt := 0
	geta := int64(0)
	for a < M {
		//fmt.Println(page)
		if P[a]-geta > K*page {
			page = 1 + (P[a]-geta)/K
			if (P[a]-geta)%page > 0 {
				page++
			}
			continue
		}
		for b := a; b < M; b++ {
			if P[b]-geta > K*page {
				cnt++
				geta += b - 1 - a + 1
				a = b
				break
			}
			if b == M-1 {
				geta += b - a + 1
				a = b + 1
				cnt++
			}
		}
		//fmt.Println(a, geta, page)
	}
	fmt.Println(cnt)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

func main() {
	sc := NewScanner()
	_, M, K := sc.NextInt(), sc.NextInt(), sc.NextInt()
	P := sc.NextIntArray()

	a := 0
	page := 1
	cnt := 0
	geta := 0
	for a < M {
		//fmt.Println(page)
		if P[a]-geta > K*page {
			page = 1 + (P[a]-geta)/K
			continue
		}
		for b := a; b < M; b++ {
			if P[b]-geta > K*page {
				cnt++
				geta += b - 1 - a + 1
				a = b
				break
			}
			if b == M-1 {
				geta += b - a + 1
				a = b + 1
				cnt++
			}
		}
		//fmt.Println(a, geta, page)
	}
	fmt.Println(cnt)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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 (
	"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--
	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 (
	"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"
	"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))
	}
}


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 (
	"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 "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()
	}
}


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")
		}
	}
}