A permutation of length $$$n$$$ is an array $$$p=[p_1,p_2,\dots,p_n]$$$, which contains every integer from $$$1$$$ to $$$n$$$ (inclusive) and, moreover, each number appears exactly once. For example, $$$p=[3,1,4,2,5]$$$ is a permutation of length $$$5$$$.For a given number $$$n$$$ ($$$n \ge 2$$$), find a permutation $$$p$$$ in which absolute difference (that is, the absolute value of difference) of any two neighboring (adjacent) elements is between $$$2$$$ and $$$4$$$, inclusive. Formally, find such permutation $$$p$$$ that $$$2 \le |p_i - p_{i+1}| \le 4$$$ for each $$$i$$$ ($$$1 \le i < n$$$).Print any such permutation for the given integer $$$n$$$ or determine that it does not exist.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is described by a single line containing an integer $$$n$$$ ($$$2 \le n \le 1000$$$).

Print $$$t$$$ lines. Print a permutation that meets the given requirements. If there are several such permutations, then print any of them. If no such permutation exists, print -1.

package main

import (
	"bufio"
	"fmt"
	"os"

	//"os"

	//"os"
	"strconv"
	"strings"
)

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

func Assert(b bool) {
	if !b {
		panic("Assertion error")
	}
}

func main() {
	input := os.Stdin
	/*
			input := strings.NewReader(`6
		10
		2
		4
		6
		7
		13`)
	*/
	scanner := bufio.NewScanner(input)

	getLine := func() string {
		if !scanner.Scan() {
			panic("expected line")
		}
		return scanner.Text()
	}

	parseNumber := func(s string) int {
		t, err := strconv.ParseInt(s, 10, 64)
		CheckError(err)
		return int(t)
	}

	getNumber := func() int {
		return parseNumber(getLine())
	}

	t := getNumber()
	for i := 0; i < t; i++ {
		n := getNumber()

		//fmt.Println(n)
		constructPermutation(n)
	}

}

var (
	lst4 = []int{2, 4, 1, 3}
	lst5 = []int{2, 4, 1, 3, 5}
	lst6 = []int{2, 4, 1, 5, 3, 6}
	lst7 = []int{2, 6, 3, 1, 4, 7, 5}
)

func constructPermutation(n int) {
	if n < 4 {
		fmt.Println("-1")
		return
	}

	printList := func(lst []int) {
		// f := "%d" + strings.Repeat(" %d", len(lst)-1) + "\n"

		// b := make([]interface{}, len(lst))
		// for i := range lst {
		//   b[i] = lst[i]
		// }

		// fmt.Printf(f, b...)
		var sLst []string
		for _, v := range lst {
			sLst = append(sLst, strconv.Itoa(v))
		}
		fmt.Println(strings.Join(sLst, " "))
	}

	if n == 4 {
		printList(lst4)
		return
	}

	if n == 5 {
		printList(lst5)
		return
	}

	if n == 6 {
		printList(lst6)
		return
	}

	if n == 7 {
		printList(lst7)
		return
	}

	p := n / 4
	q := n % 4

	var lst []int
	appendShiftedList := func(aLst []int, shift int) {
		for _, v := range aLst {
			lst = append(lst, v+shift)
		}
	}

	for i := 0; i < p-1; i++ {
		shift := i * 4
		appendShiftedList(lst4, shift)
	}

	if q == 0 {
		appendShiftedList(lst4, (p-1)*4)
		printList(lst)
		return
	}

	if q == 1 {
		appendShiftedList(lst5, (p-1)*4)
		printList(lst)
		return
	}

	if q == 2 {
		appendShiftedList(lst6, (p-1)*4)
		printList(lst)
		return
	}

	if q == 3 {
		appendShiftedList(lst7, (p-1)*4)
		printList(lst)
		return
	}
}

package main

import (
	"fmt"
)

func solve() {
	var n int
	fmt.Scanf("%d\n", &n)
	if n >= 4 {
		for i := n; i >= 0; i-- {
			if i&1 == 1 {
				fmt.Printf("%d ", i)
			}
		}
		fmt.Printf("4 2 ")
		for i := 6; i <= n; i += 2 {
			fmt.Printf("%d ", i)
		}
		fmt.Println()
	} else {
		fmt.Printf("-1\n")
	}

}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		solve()
	}
}

package main

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

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

	scanner.Scan()

	t := scanner.Text()

	testCases, err := strconv.Atoi(t)

	if err != nil {
		panic(err)
	}

	for j := 0; j < int(testCases); j ++ {

		scanner.Scan()

		nn := scanner.Text()

		n, _  := strconv.Atoi(nn)

		res := solve4(n)

		if res == nil {
			fmt.Println(-1)

		} else {
			for _, r := range res {
				fmt.Println(r)
				fmt.Print(" ")
			}
		}
	}
}

func solve4 (n int ) []int {
	if n <= 3 {
		return  nil
	}

	if n % 4 == 0 {
		ans := make([]int, n)

		ans[0] = 2
		ans[1] = 4
		ans[2] = 1
		ans[3] = 3

		for i := 4 ; i < n; i += 4 {
			ans[i] = i + 2
			ans[i + 1] = i + 4
			ans[i + 2] = i + 1
			ans[i + 3] = i + 3
		}

		return ans

	} else if n % 4 == 1 {
		ans := make([]int, n)

		ans[0] = 2
		ans[1] = 4
		ans[2] = 1
		ans[3] = 3
		ans[4] = 5

		for i := 5 ; i < n; i += 4 {
			ans[i] = i + 2
			ans[i + 1] = i + 4
			ans[i + 2] = i + 1
			ans[i + 3] = i + 3
		}

		return ans

	} else if n % 4 == 2 {
		ans := make([]int, n)

		ans[0] = 1
		ans[1] = 3
		ans[2] = 5
		ans[3] = 2
		ans[4] = 4
		ans[5] = 6

		for i := 6 ; i < n; i += 4 {
			ans[i] = i + 2
			ans[i + 1] = i + 4
			ans[i + 2] = i + 1
			ans[i + 3] = i + 3
		}

		return ans

	} else {
		ans := make([]int, n)

		ans[0] = 2
		ans[1] = 4
		ans[2] = 7
		ans[3] = 5
		ans[4] = 1
		ans[5] = 3
		ans[6] = 6

		for i := 7 ; i < n; i += 4 {
			ans[i] = i + 2
			ans[i + 1] = i + 4
			ans[i + 2] = i + 1
			ans[i + 3] = i + 3
		}

		return ans
	}
}

/*
URL:
https://codeforces.com/contest/1352/problem/G
*/

package main

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

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

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

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t int
	n int
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		n = ReadInt()
		if n <= 3 {
			fmt.Println(-1)
			continue
		}

		solve(n)
	}
}

func solve(n int) {
	if n%2 == 1 {
		odd(n)
	} else {
		even(n)
	}
}

func odd(n int) {
	answers := []int{}
	for i := 1; i <= n; i += 2 {
		answers = append(answers, i)
	}
	answers = append(answers, n-3)
	answers = append(answers, n-1)

	for i := n - 5; i >= 1; i -= 2 {
		answers = append(answers, i)
	}

	fmt.Println(PrintIntsLine(answers...))
}

func even(n int) {
	A := []int{}
	for i := 2; i <= n; i += 2 {
		A = append(A, i)
	}
	A = append(A, n-3)
	A = append(A, n-1)

	for i := n - 5; i >= 1; i -= 2 {
		A = append(A, i)
	}

	fmt.Println(PrintIntsLine(A...))
}

/*******************************************************************/

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

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func run(_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)
		if n <= 3 {
			Fprintln(out, -1)
			continue
		}
		ans := make([]interface{}, 0, n)
		if n&1 == 1 {
			for i := n; i > 0; i -= 2 {
				ans = append(ans, i)
			}
			n--
		} else {
			for i := n-1; i > 0; i -= 2 {
				ans = append(ans, i)
			}
		}
		if n%4==0 {
			for i :=4;i<=n;i+=4 {
				ans = append(ans, i)
			}
			for i:=n-2;i>0;i-=4 {
				ans = append(ans, i)
			}
		} else {
			for i :=4;i<n;i+=4 {
				ans = append(ans, i)
			}
			for i:=n;i>0;i-=4 {
				ans = append(ans, i)
			}
		}
		Fprintln(out, ans...)
	}
}

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

package main

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

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

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

func solve() {
	n := 0
	scanf("%d\n", &n)
	if n < 4 {
		printf("-1\n")
	} else if n == 4 {
		printf("3 1 4 2\n")
	} else {
		i := 1
		for i <= n {
			printf("%d ", i)
			i += 2
		}
		printf("%d ", i - 5)
		if n & 1 == 0 {
			printf("%d ", i - 1)
		}
		i -= 3
		printf("%d ", i)
		i -= 4
		for i > 0 {
			printf("%d ", i)
			i -= 2
		}
		printf("\n")
	}
}

func main() {
	t := 0
	scanf("%d\n", &t)
	for t > 0 {
		solve()
		t--
	}
	writer.Flush()
}

package main

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

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

type writerImpl struct {
	*bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

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

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

type WordScanner interface {
	NextInt64() int64
	NextUInt64() uint64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt64() int64 {
	impl.Scan()
	bb := impl.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextUInt64() uint64 {
	impl.Scan()
	bb := impl.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}

func gcd(x, y int64) int64 {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

const (
	INF = math.MaxInt64
	MOD = 1e9 + 7
)

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n := reader.NextInt64()
		res := sol(n)
		if res == nil {
			writer.Printf("-1\n")
		} else {
			for _, r := range res {
				writer.Printf("%d ", r)
			}
			writer.Printf("\n")
		}
	}
}

func sol(n int64) []int64 {
	if n <= 3 {
		return nil
	}
	if n & 1 == 0 {
		ret := []int64{}
		for i := int64(2); i <= n; i += 2 {
			ret = append(ret, i)
		}
		ret = append(ret, n-3, n-1)
		for i := n-5; i >= 1; i -= 2 {
			ret = append(ret, i)
		}
		return ret
	}
	ret := []int64{}
	for i := int64(1); i <= n; i+= 2 {
		ret = append(ret, i)
	}
	ret = append(ret, n-3, n-1)
	for i := n-5; i >= 1; i-= 2 {
		ret = append(ret, i)
	}
	return ret
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		N := float64(a) / 10
		x := math.Ceil(float64(N))
		var number int = 2
		var list []int
		list = append(list, number)
		var (
			lst4  = []int{2, 4, 1, 3}
			lst5  = []int{2, 4, 1, 3, 5}
			lst6  = []int{2, 4, 1, 5, 3, 6}
			lst7  = []int{2, 6, 3, 1, 4, 7, 5}
			lst10 = []int{2, 4, 1, 3, 6, 8, 5, 9, 7, 10}
		)
		if a < 4 {
			fmt.Println("-1")
		} else if a == 4 {
			for j := 0; j < len(lst4); j++ {
				fmt.Print(lst4[j], " ")
			}
			fmt.Println()

		} else if a == 5 {

			for j := 0; j < len(lst5); j++ {

				fmt.Print(lst5[j], " ")

			}
			fmt.Println()
		} else if a == 6 {

			for j := 0; j < len(lst6); j++ {

				fmt.Print(lst6[j], " ")

			}
			fmt.Println()
		} else if a == 7 {

			for j := 0; j < len(lst7); j++ {

				fmt.Print(lst7[j], " ")

			}
			fmt.Println()
		} else if a == 10 {

			for j := 0; j < len(lst10); j++ {

				fmt.Print(lst10[j], " ")

			}
			fmt.Println()
		} else {
			for j := 0; j < int(x)*3; j++ {
				number += 2
				list = append(list, number)
				number -= 3
				list = append(list, number)
				number += 2
				list = append(list, number)
				number += 3
				list = append(list, number)
			}
			//var newList []int
			for j := 0; j < len(list); j++ {
				if list[j] <= a {
					fmt.Print(list[j], " ")
				}
			}
			fmt.Println()
		}

	}
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		N := float64(a) / 10
		x := math.Ceil(float64(N))
		var number int = 2
		var list []int
		list = append(list, number)
		if a < 4 {
			fmt.Println("-1")
		} else {
			for j := 0; j < int(x)*3; j++ {
				number += 2
				list = append(list, number)
				number -= 3
				list = append(list, number)
				number += 2
				list = append(list, number)
				number += 3
				list = append(list, number)
			}
			//var newList []int
			for j := 0; j < len(list); j++ {
				if list[j] <= a {
					fmt.Print(list[j], " ")
				}
			}
			fmt.Println()
		}

	}
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		N := float64(a) / 10
		x := math.Ceil(float64(N))
		var number int = 2
		var list []int
		list = append(list, number)
		var (
			lst4 = []int{2, 4, 1, 3}
			lst5 = []int{2, 4, 1, 3, 5}
			lst6 = []int{2, 4, 1, 5, 3, 6}
			lst7 = []int{2, 6, 3, 1, 4, 7, 5}
		)
		if a < 4 {
			fmt.Println("-1")
		} else if a == 4 {
			for j := 0; j < len(lst4); j++ {
				fmt.Print(lst4[j], " ")
			}
			fmt.Println()

		} else if a == 5 {

			for j := 0; j < len(lst5); j++ {

				fmt.Print(lst5[j], " ")

			}
			fmt.Println()
		} else if a == 6 {

			for j := 0; j < len(lst6); j++ {

				fmt.Print(lst6[j], " ")

			}
			fmt.Println()
		} else if a == 7 {

			for j := 0; j < len(lst7); j++ {

				fmt.Print(lst7[j], " ")

			}
			fmt.Println()
		} else {
			for j := 0; j < int(x)*3; j++ {
				number += 2
				list = append(list, number)
				number -= 3
				list = append(list, number)
				number += 2
				list = append(list, number)
				number += 3
				list = append(list, number)
			}
			//var newList []int
			for j := 0; j < len(list); j++ {
				if list[j] <= a {
					fmt.Print(list[j], " ")
				}
			}
			fmt.Println()
		}

	}
}

package main

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

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

	scanner.Scan()

	t := scanner.Text()

	testCases, err := strconv.Atoi(t)

	if err != nil {
		panic(err)
	}

	for j := 0; j < int(testCases); j ++ {

		scanner.Scan()

		nn := scanner.Text()

		n, _  := strconv.Atoi(nn)

		res := solve4(n)

		if res == nil {
			fmt.Println(-1)

		} else {
			fmt.Println(res)
		}
	}
}

func solve4 (n int ) []int {
	if n <= 3 {
		return  nil
	}

	if n % 4 == 0 {
		ans := make([]int, n)

		ans[0] = 2
		ans[1] = 4
		ans[2] = 1
		ans[3] = 3

		for i := 4 ; i < n; i += 4 {
			ans[i] = i + 2
			ans[i + 1] = i + 4
			ans[i + 2] = i + 1
			ans[i + 3] = i + 3
		}

		return ans

	} else if n % 4 == 1 {
		ans := make([]int, n)

		ans[0] = 2
		ans[1] = 4
		ans[2] = 1
		ans[3] = 3
		ans[4] = 5

		for i := 5 ; i < n; i += 4 {
			ans[i] = i + 2
			ans[i + 1] = i + 4
			ans[i + 2] = i + 1
			ans[i + 3] = i + 3
		}

		return ans

	} else if n % 4 == 2 {
		ans := make([]int, n)

		ans[0] = 1
		ans[1] = 3
		ans[2] = 5
		ans[3] = 2
		ans[4] = 4
		ans[5] = 6

		for i := 6 ; i < n; i += 4 {
			ans[i] = i + 2
			ans[i + 1] = i + 4
			ans[i + 2] = i + 1
			ans[i + 3] = i + 3
		}

		return ans

	} else {
		ans := make([]int, n)

		ans[0] = 2
		ans[1] = 4
		ans[2] = 7
		ans[3] = 5
		ans[4] = 1
		ans[5] = 3
		ans[6] = 6

		for i := 7 ; i < n; i += 4 {
			ans[i] = i + 2
			ans[i + 1] = i + 4
			ans[i + 2] = i + 1
			ans[i + 3] = i + 3
		}

		return ans
	}
}

package main

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

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

type writerImpl struct {
	*bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

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

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

type WordScanner interface {
	NextInt64() int64
	NextUInt64() uint64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt64() int64 {
	impl.Scan()
	bb := impl.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextUInt64() uint64 {
	impl.Scan()
	bb := impl.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}

func gcd(x, y int64) int64 {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

const (
	INF = math.MaxInt64
	MOD = 1e9 + 7
)

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n := reader.NextInt64()
		res := sol(n)
		if res == nil {
			writer.Printf("-1\n")
		} else {
			for _, r := range res {
				writer.Printf("%d ", r)
			}
			writer.Printf("\n")
		}
	}
}

func sol(n int64) []int64 {
	if n <= 3 {
		return nil
	}
	ret := []int64{}
	for i := int64(2); i <= n; i += 2 {
		ret = append(ret, i)
	}
	if ret[len(ret)-1] == n {
		ret = append(ret, n-3, n-1)
		for i := n-5; i >= 1; i -= 2 {
			ret = append(ret, i)
		}
		return ret
	}
	ret = append(ret, n-2, n)
	for i := n-4; i >= 1; i -= 2 {
		ret = append(ret, i)
	}
	return ret
}


Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.Galya doesn't know the ships location. She can shoot to some cells and after each shot she is told if that cell was a part of some ship (this case is called "hit") or not (this case is called "miss").Galya has already made k shots, all of them were misses.Your task is to calculate the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship.It is guaranteed that there is at least one valid ships placement.

The first line contains four positive integers n, a, b, k (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ n, 0 ≤ k ≤ n - 1) — the length of the grid, the number of ships on the grid, the length of each ship and the number of shots Galya has already made. The second line contains a string of length n, consisting of zeros and ones. If the i-th character is one, Galya has already made a shot to this cell. Otherwise, she hasn't. It is guaranteed that there are exactly k ones in this string.

In the first line print the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship. In the second line print the cells Galya should shoot at. Each cell should be printed exactly once. You can print the cells in arbitrary order. The cells are numbered from 1 to n, starting from the left. If there are multiple answers, you can print any of them.

NoteThere is one ship in the first sample. It can be either to the left or to the right from the shot Galya has already made (the "1" character). So, it is necessary to make two shots: one at the left part, and one at the right part.

package main

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

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1<<13)
	writer := bufio.NewWriterSize(os.Stdout, 1<<13)
	var n, a, b, k int
	fmt.Fscanln(reader, &n, &a, &b, &k)
	var shots string
	fmt.Fscanln(reader, &shots)

	ans := getCells([]byte(shots), a, b, n)
	fmt.Fprintln(writer, len(ans))
	for i, value := range ans {
		if i == n {
			break
		}
		fmt.Fprint(writer, value+1, " ")
	}
	fmt.Fprintln(writer)
	writer.Flush()
}

func getCells(shots []byte, a, b, n int) []int {
	res := make([]int, 0)
	empty := 0
	for i, shot := range shots {
		if shot == '0' {
			empty++
		} else {
			empty = 0
		}
		if empty == b {
			res = append(res, i)
			empty = 0
		}
	}
	return res[:len(res)-a+1]
}

func ReadInt(reader *bufio.Reader) int {
	b, err := reader.ReadByte()
	for !isValid(b, err) {
		b, err = reader.ReadByte()
	}
	res := 0
	for isValid(b, err) {
		res = res*10 + int(b-'0')
		b, err = reader.ReadByte()
	}
	return res
}

func isValid(b byte, err error) bool {
	return err == nil && '0' <= b && b <= '9'
}

package main

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

func solve() {
    _, a, b, _, s := readInt(), readInt(), readInt(), readInt(), readString() + "1"
    slots, start := []int{}, -1
    for i, ch := range s {
        if ch == '1' {
            for i-start-1 >= b {
                slots, start = append(slots, start+b), start+b
            }
            start = i
        }
    }
    ans := len(slots)-a+1
    fmt.Println(ans)
    for i := 0; i < ans; i++ {
        fmt.Print(slots[i]+1, " ")
    }
    fmt.Println()
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

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

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
    v, _ := strconv.ParseInt(readString(), 10, 64)
    return v;
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readArray(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = readInt()
	}
	return res
}

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

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

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1<<13)
	writer := bufio.NewWriterSize(os.Stdout, 1<<13)
	n, a, b, _ := ReadInt(reader), ReadInt(reader), ReadInt(reader), ReadInt(reader)
	shots := make([]int, n)
	for i := 0; i < n; i++ {
		b, err := reader.ReadByte()
		if err != nil {
			panic(err)
		}
		shots[i] = int(b - '0')
	}
	ans := getCells(shots, a, b, n)
	fmt.Fprintln(writer, len(ans))
	for _, value := range ans {
		fmt.Fprint(writer, value+1, " ")
	}
	writer.Flush()
}

func getCells(shots []int, a, b, n int) []int {
	res := make([]int, 0)
	empty := 0
	for i, shot := range shots {
		if shot == 0 {
			empty++
		} else {
			empty = 0
		}
		if empty == b {
			res = append(res, i)
			empty = 0
		}
	}
	return res[:len(res)-a+1]
}

func ReadInt(reader *bufio.Reader) int {
	b, err := reader.ReadByte()
	for !isValid(b, err) {
		b, err = reader.ReadByte()
	}
	res := 0
	for isValid(b, err) {
		res = res*10 + int(b-'0')
		b, err = reader.ReadByte()
	}
	return res
}

func isValid(b byte, err error) bool {
	return err == nil && '0' <= b && b <= '9'
}

package main

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

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1<<13)
	writer := bufio.NewWriterSize(os.Stdout, 1<<13)
	n, a, b, _ := ReadInt(reader), ReadInt(reader), ReadInt(reader), ReadInt(reader)
	shots := make([]int, n)
	for i := 0; i < n; i++ {
		b, err := reader.ReadByte()
		if err != nil {
			panic(err)
		}
		shots[i] = int(b - '0')
	}
	ans := getCells(shots, a, b, n)
	fmt.Fprintln(writer, len(ans))
	for _, value := range ans {
		fmt.Fprint(writer, value+1, " ")
	}
	fmt.Fprintln(writer)
	writer.Flush()
}

func getCells(shots []int, a, b, n int) []int {
	res := make([]int, 0)
	empty := 0
	for i, shot := range shots {
		if shot == 0 {
			empty++
		} else {
			empty = 0
		}
		if empty == b {
			res = append(res, i)
			empty = 0
		}
	}
	return res[:len(res)-a+1]
}

func ReadInt(reader *bufio.Reader) int {
	b, err := reader.ReadByte()
	for !isValid(b, err) {
		b, err = reader.ReadByte()
	}
	res := 0
	for isValid(b, err) {
		res = res*10 + int(b-'0')
		b, err = reader.ReadByte()
	}
	return res
}

func isValid(b byte, err error) bool {
	return err == nil && '0' <= b && b <= '9'
}


You are given a connected undirected graph without cycles (that is, a tree) of $$$n$$$ vertices, moreover, there is a non-negative integer written on every edge.Consider all pairs of vertices $$$(v, u)$$$ (that is, there are exactly $$$n^2$$$ such pairs) and for each pair calculate the bitwise exclusive or (xor) of all integers on edges of the simple path between $$$v$$$ and $$$u$$$. If the path consists of one vertex only, then xor of all integers on edges of this path is equal to $$$0$$$.Suppose we sorted the resulting $$$n^2$$$ values in non-decreasing order. You need to find the $$$k$$$-th of them.The definition of xor is as follows.Given two integers $$$x$$$ and $$$y$$$, consider their binary representations (possibly with leading zeros): $$$x_k \dots x_2 x_1 x_0$$$ and $$$y_k \dots y_2 y_1 y_0$$$ (where $$$k$$$ is any number so that all bits of $$$x$$$ and $$$y$$$ can be represented). Here, $$$x_i$$$ is the $$$i$$$-th bit of the number $$$x$$$ and $$$y_i$$$ is the $$$i$$$-th bit of the number $$$y$$$. Let $$$r = x \oplus y$$$ be the result of the xor operation of $$$x$$$ and $$$y$$$. Then $$$r$$$ is defined as $$$r_k \dots r_2 r_1 r_0$$$ where:$$$$$$ r_i = \left\{ \begin{aligned} 1, ~ \text{if} ~ x_i \ne y_i \\ 0, ~ \text{if} ~ x_i = y_i \end{aligned} \right. $$$$$$

The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 10^6$$$, $$$1 \le k \le n^2$$$) — the number of vertices in the tree and the number of path in the list with non-decreasing order. Each of the following $$$n - 1$$$ lines contains two integers $$$p_i$$$ and $$$w_i$$$ ($$$1 \le p_i \le i$$$, $$$0 \le w_i < 2^{62}$$$) — the ancestor of vertex $$$i + 1$$$ and the weight of the corresponding edge.

Print one integer: $$$k$$$-th smallest xor of a path in the tree.

NoteThe tree in the second sample test looks like this:For such a tree in total $$$9$$$ paths exist:   $$$1 \to 1$$$ of value $$$0$$$  $$$2 \to 2$$$ of value $$$0$$$  $$$3 \to 3$$$ of value $$$0$$$  $$$2 \to 3$$$ (goes through $$$1$$$) of value $$$1 = 2 \oplus 3$$$  $$$3 \to 2$$$ (goes through $$$1$$$) of value $$$1 = 2 \oplus 3$$$  $$$1 \to 2$$$ of value $$$2$$$  $$$2 \to 1$$$ of value $$$2$$$  $$$1 \to 3$$$ of value $$$3$$$  $$$3 \to 1$$$ of value $$$3$$$

package main

import (
	"bufio"
	"fmt"
	"math/rand"
	"os"
	"sort"
)

var scanner *bufio.Scanner

func init() {
	scanner = bufio.NewScanner(bufio.NewReaderSize(os.Stdin, 1<<20))
	scanner.Split(bufio.ScanWords)
}

func NextInt64() int64 {
	scanner.Scan()
	var res int64
	var negative bool
	bytes := scanner.Bytes()
	if bytes[0] == '-' {
		negative = true
		bytes = bytes[1:]
	}
	for _, c := range bytes {
		res = res*10 + int64(c - '0')
	}
	if negative {
		res = -res
	}
	return res
}

func NextInt() int {
	return int(NextInt64())
}

var xx []uint64

func calculateForBit(prefix uint64, bit uint, old []uint64, new []uint64) (int64, []uint64) {
	res := int64(0)
	l, r := 0, 0

	for i := 0; i < len(old); {
		var j1, j2 int

		left := (((old[i] ^ prefix) >> bit) ^ 1) << bit
		right := left + (1 << bit)

		for ; l < len(xx) && xx[l] < left; l++ {
		}
		for ; r < len(xx) && xx[r] < right; r++ {
		}

		for j1 = i; j1 < len(old) && old[j1]>>bit == old[i]>>bit; j1++ {
			res += int64(r - l)
		}

		if j1 != len(old) {
			left = (((old[j1] ^ prefix) >> bit) ^ 1) << bit
			right = left + (1 << bit)

			for ; l < len(xx) && xx[l] < left; l++ {
			}
			for ; r < len(xx) && xx[r] < right; r++ {
			}
		}

		for j2 = j1; j2 < len(old) && old[j2]>>(bit+1) == old[i]>>(bit+1); j2++ {
			res += int64(r - l)
		}

		copy(new[i:i+j2-j1], old[j1:j2])
		copy(new[i+j2-j1:j2], old[i:j1])
		i = j2
	}

	return res, new
}

func main() {

	n := NextInt()
	k := NextInt64() - 1

	xx = make([]uint64, n)

	for i := 1; i < n; i++ {
		p := NextInt()
		v := uint64(NextInt64())
		p--
		xx[i] = xx[p] ^ v
	}

	rand.Shuffle(n, func(i, j int) {
		xx[i], xx[j] = xx[j], xx[i]
	})

	sort.Slice(xx, func(i, j int) bool {
		return xx[i] < xx[j]
	})

	current := make([]uint64, n)
	copy(current, xx)

	buf := make([]uint64, n)

	sum := int64(0)
	answer := uint64(0)

	for i := 62; i >= 0; i-- {
		if res, newArr := calculateForBit(answer^(1<<uint(i)), uint(i), current, buf); sum+res <= k {
			sum += res
			current, buf = newArr, current
			answer ^= 1 << uint(i)
		}
	}

	fmt.Println(answer)
}

package main

import (
	"bufio"
	"fmt"
	"math/rand"
	"os"
	"sort"
)

var scanner *bufio.Scanner

func init() {
	scanner = bufio.NewScanner(bufio.NewReaderSize(os.Stdin, 1<<20))
	scanner.Split(bufio.ScanWords)
}

func NextInt64() int64 {
	scanner.Scan()
	var res int64
	var negative bool
	bytes := scanner.Bytes()
	if bytes[0] == '-' {
		negative = true
		bytes = bytes[1:]
	}
	for _, c := range bytes {
		res = res*10 + int64(c - '0')
	}
	if negative {
		res = -res
	}
	return res
}

func NextInt() int {
	return int(NextInt64())
}

var xx []uint64

func calculateForBit(prefix uint64, bit uint, old []uint64, new []uint64) (int64, []uint64) {
	res := int64(0)
	l, r := 0, 0

	for i := 0; i < len(old); {
		var j1, j2 int

		left := (((old[i] ^ prefix) >> bit) ^ 1) << bit
		right := left + (1 << bit)

		for ; l < len(xx) && xx[l] < left; l++ {
		}
		for ; r < len(xx) && xx[r] < right; r++ {
		}

		for j1 = i; j1 < len(old) && old[j1]>>bit == old[i]>>bit; j1++ {
			res += int64(r - l)
		}

		if j1 != len(old) {
			left = (((old[j1] ^ prefix) >> bit) ^ 1) << bit
			right = left + (1 << bit)

			for ; l < len(xx) && xx[l] < left; l++ {
			}
			for ; r < len(xx) && xx[r] < right; r++ {
			}
		}

		for j2 = j1; j2 < len(old) && old[j2]>>(bit+1) == old[i]>>(bit+1); j2++ {
			res += int64(r - l)
		}

		copy(new[i:i+j2-j1], old[j1:j2])
		copy(new[i+j2-j1:j2], old[i:j1])
		i = j2
	}

	return res, new
}

func main() {

	n := NextInt()
	k := NextInt64() - 1

	xx = make([]uint64, n)

	for i := 1; i < n; i++ {
		p := NextInt()
		v := uint64(NextInt64())
		p--
		xx[i] = xx[p] ^ v
	}

	rand.Shuffle(n, func(i, j int) {
		xx[i], xx[j] = xx[j], xx[i]
	})

	sort.Slice(xx, func(i, j int) bool {
		return xx[i] < xx[j]
	})

	current := make([]uint64, n)
	copy(current, xx)

	buf := make([]uint64, n)

	sum := int64(0)
	answer := uint64(0)

	for i := 61; i >= 0; i-- {
		if res, newArr := calculateForBit(answer^(1<<uint(i)), uint(i), current, buf); sum+res <= k {
			sum += res
			current, buf = newArr, current
			answer ^= 1 << uint(i)
		}
	}

	fmt.Println(answer)
}

package main

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

var in = bufio.NewReaderSize(os.Stdin, 2<<16)

var xx []uint64

type Node struct {
	ch [2]*Node
	sum int32
}

func getSum(node *Node) int64 {
	if node == nil {
		return 0
	}
	return int64(node.sum)
}

func findSum(root *Node, x uint64, k uint64) int64 {
	x = bits.Reverse64(x)
	k = bits.Reverse64(k)

	res := int64(0)

	for i := 0; i < 64 && getSum(root) > 0; i++ {
		if k & 1 == 1 {
			res += getSum(root.ch[x & 1])
		}
		root = root.ch[(x ^ k) & 1]
		x >>= 1
		k >>= 1
	}

	return res
}

func build(values []uint64) *Node {
	root := &Node{}
	for _, x := range values {
		x = bits.Reverse64(x)
		node := root
		for i := 0; i < 64; i++ {
			node.sum += 1
			if node.ch[x & 1] == nil {
				node.ch[x & 1] = &Node{}
			}
			node = node.ch[x & 1]
			x >>= 1
		}
		node.sum += 1
	}

	return root
}

func findLess(root *Node, values []uint64, k uint64) int64 {
	res := int64(0)
	for _, v := range values {
		res += findSum(root, v, k)
	}
	return res
}

func main() {

	var (
		n int
		k int64
	)

	fmt.Fscan(in, &n, &k)
	k--

	xx = make([]uint64, n)

	for i := 1; i < n; i++ {
		var p int
		var v uint64
		fmt.Fscan(in, &p, &v)
		p--
		xx[i] = xx[p] ^ v
	}

	root := build(xx)
	l, r := uint64(0), uint64(1 << 62)

	//for i := 0; i < 7; i++ {
	//	fmt.Println(i, findLess(root, xx, uint64(i)))
	//}

	for ; l < r; {
		m := (l + r) / 2
		if findLess(root, xx, m) >= k {
			r = m
		} else {
			l = m + 1
		}
	}
	fmt.Println(l)
}

package main

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

var in = bufio.NewReaderSize(os.Stdin, 2<<16)

var xx []uint64

type Node struct {
	ch [2]*Node
	sum int32
}

func getSum(node *Node) int64 {
	if node == nil {
		return 0
	}
	return int64(node.sum)
}

func findSum(root *Node, x uint64, k uint64) int64 {
	x = bits.Reverse64(x)
	k = bits.Reverse64(k)

	res := int64(0)

	for i := 0; i < 64 && getSum(root) > 0; i++ {
		if k & 1 == 1 {
			res += getSum(root.ch[x & 1])
		}
		root = root.ch[(x ^ k) & 1]
		x >>= 1
		k >>= 1
	}

	return res
}

func build(values []uint64) *Node {
	root := &Node{}
	for _, x := range values {
		x = bits.Reverse64(x)
		node := root
		for i := 0; i < 64; i++ {
			node.sum += 1
			if node.ch[x & 1] == nil {
				node.ch[x & 1] = &Node{}
			}
			node = node.ch[x & 1]
			x >>= 1
		}
	}

	return root
}

func findLess(root *Node, values []uint64, k uint64) int64 {
	res := int64(0)
	for _, v := range values {
		res += findSum(root, v, k)
	}
	return res
}

func main() {

	var (
		n int
		k int64
	)

	fmt.Fscan(in, &n, &k)
	k--

	xx = make([]uint64, n)

	for i := 1; i < n; i++ {
		var p int
		var v uint64
		fmt.Fscan(in, &p, &v)
		p--
		xx[i] = xx[p] ^ v
	}

	root := build(xx)
	l, r := uint64(0), uint64(1 << 62)

	//for i := 0; i < 7; i++ {
	//	fmt.Println(findLess(root, xx, uint64(i)))
	//}

	for ; l < r; {
		m := (l + r) / 2
		if findLess(root, xx, m) >= k {
			r = m
		} else {
			l = m + 1
		}
	}
	fmt.Println(l)
}

package main

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

var in = bufio.NewReaderSize(os.Stdin, 2<<16)

var xx []uint64

func calculateForBit(prefix uint64, bit uint, old []uint64, new []uint64) (int64, []uint64) {
	res := int64(0)
	l, r := 0, 0

	doUpdate := func(left, right uint64, multiplier int64) {
		//println("! ", left, " ", right, " ", multiplier)
		for ; l < len(xx) && xx[l] < left; l++ {
		}
		for ; r < len(xx) && xx[r] < right; r++ {
		}
		res += int64(r-l) * multiplier
	}

	for i := 0; i < len(old); {
		var j1, j2 int

		for j1 = i; j1 < len(old) && (old[j1]^prefix)>>bit == (old[i]^prefix)>>bit; j1++ {
		}

		left := (((old[i] ^ prefix) >> bit) ^ 1) << bit
		right := left + (1 << bit)
		doUpdate(left, right, int64(j1 - i))

		for j2 = j1; j2 < len(old) && (old[j2]^prefix)>>(bit+1) == (old[i]^prefix)>>(bit+1); j2++ {
		}

		if j2 > j1 {
			left := (((old[j1] ^ prefix) >> bit) ^ 1) << bit
			right := left + (1 << bit)
			doUpdate(left, right, int64(j2 - j1))
		}

		new = append(new, old[j1:j2]...)
		new = append(new, old[i:j1]...)
		i = j2
	}

	//println(prefix, " ", bit, " ", res)
	return res, new
}

func main() {

	var (
		n int
		k int64
	)

	fmt.Fscan(in, &n, &k)
	k--

	xx = make([]uint64, n)

	for i := 1; i < n; i++ {
		var p int
		var v uint64
		fmt.Fscan(in, &p, &v)
		p--
		xx[i] = xx[p] ^ v
	}

	sort.Slice(xx, func(i, j int) bool {
		return xx[i] < xx[j]
	})

	current := make([]uint64, n)
	copy(current, xx)

	new := make([]uint64, n)

	sum := int64(0)
	answer := uint64(0)

	for i := 62; i >= 0; i-- {
		if res, newArr := calculateForBit(answer^ (1 << uint(i)), uint(i), current, new[:0]); sum + res <= k {
			sum += res
			current, new = newArr, current
			answer ^= 1 << uint(i)
		}
	}

	println(answer)
}


You are given a n × m field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A right triangle is a triangle in which one angle is a right angle (that is, a 90 degree angle).

The first line contains two positive integer numbers n and m (1 ≤ n, m ≤ 1000). The following n lines consist of m characters each, describing the field. Only '.' and '*' are allowed.

Output a single number — total number of square triangles in the field. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).

// Codeforces 983 b XorPyramid train done
package main

import (
	"bufio"
	"fmt"
	"strings"
	"strconv"
	"os"
)
var in *bufio.Reader

func readFive() (int,int,int,int,int) {
	var a [5]int
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for i:=0; i<len(ss); i++ {
		a[i], err = strconv.Atoi(ss[i])
		if err != nil {
			fmt.Println("n atoi failure", err)
			panic(err)
		}
	}
	return a[0],a[1],a[2],a[3],a[4]
}

func readLineNumbs(n int) []int {
	a := make([]int, n)
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for j:=0; j<n; j++ {
		aa,err := strconv.Atoi(ss[j])
		if err != nil {
			fmt.Println("aa conv failed", err)
			panic(err)
		}
		a[j] = aa
	}
	return a
}

var n,m int
var rcnt,ccnt []int
var b [][] byte
var tot int64

func readData() {
	in = bufio.NewReader(os.Stdin)
	// reading n, k
	n, m, _, _, _ = readFive()
	// reading b
	rcnt = make([]int, n)
	ccnt = make([]int, m)
	b = make([][]byte, n)
	for i:=0; i<n; i++ {
		s, err := in.ReadString('\n')
		if err != nil {
			fmt.Println("read failure", err)
			panic(err)
		}
		sb := []byte(s)
		b[i] = sb
		for j:=0; j<m; j++ {
			// fmt.Println("sbi", sb[i], byte('*'))
			if sb[j] == '*' {
				rcnt[i]++
				ccnt[j]++
			}
		}
	}
}

func solve() {
	tot = 0
	for i:=0; i<n; i++ {
		for j:=0; j<m; j++ {
			if b[i][j] == byte('*') {
				tot += int64((rcnt[i] - 1) * (ccnt[j] - 1))
			}
		}
	}
}

func printRes() {
	fmt.Println(tot)
}

func main() {
	readData()
	solve()
	printRes()
}


Anna is a girl so brave that she is loved by everyone in the city and citizens love her cookies. She is planning to hold a party with cookies. Now she has $$$a$$$ vanilla cookies and $$$b$$$ chocolate cookies for the party.She invited $$$n$$$ guests of the first type and $$$m$$$ guests of the second type to the party. They will come to the party in some order. After coming to the party, each guest will choose the type of cookie (vanilla or chocolate) to eat. There is a difference in the way how they choose that type:If there are $$$v$$$ vanilla cookies and $$$c$$$ chocolate cookies at the moment, when the guest comes, then  if the guest of the first type: if $$$v>c$$$ the guest selects a vanilla cookie. Otherwise, the guest selects a chocolate cookie.  if the guest of the second type: if $$$v>c$$$ the guest selects a chocolate cookie. Otherwise, the guest selects a vanilla cookie. After that:  If there is at least one cookie of the selected type, the guest eats one.  Otherwise (there are no cookies of the selected type), the guest gets angry and returns to home. Anna wants to know if there exists some order of guests, such that no one guest gets angry. Your task is to answer her question.

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain descriptions of test cases. For each test case, the only line contains four integers $$$a$$$, $$$b$$$, $$$n$$$, $$$m$$$ ($$$0 \le a,b,n,m \le 10^{18}, n+m \neq 0$$$).

For each test case, print the answer in one line. If there exists at least one valid order, print "Yes". Otherwise, print "No". You can print each letter in any case (upper or lower).

NoteIn the first test case, let's consider the order $$$\{1, 2, 2\}$$$ of types of guests. Then:  The first guest eats a chocolate cookie. After that, there are $$$2$$$ vanilla cookies and $$$1$$$ chocolate cookie.  The second guest eats a chocolate cookie. After that, there are $$$2$$$ vanilla cookies and $$$0$$$ chocolate cookies.  The last guest selects a chocolate cookie, but there are no chocolate cookies. So, the guest gets angry. So, this order can't be chosen by Anna.Let's consider the order $$$\{2, 2, 1\}$$$ of types of guests. Then:  The first guest eats a vanilla cookie. After that, there is $$$1$$$ vanilla cookie and $$$2$$$ chocolate cookies.  The second guest eats a vanilla cookie. After that, there are $$$0$$$ vanilla cookies and $$$2$$$ chocolate cookies.  The last guest eats a chocolate cookie. After that, there are $$$0$$$ vanilla cookies and $$$1$$$ chocolate cookie. So, the answer to this test case is "Yes".In the fifth test case, it is illustrated, that the number of cookies ($$$a + b$$$) can be equal to zero, but the number of guests ($$$n + m$$$) can't be equal to zero.In the sixth test case, be careful about the overflow of $$$32$$$-bit integer type.

package main

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

var in *bufio.Reader
var out *bufio.Writer

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

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

func main() {
	out = bufio.NewWriterSize(os.Stdout, 8192)
	defer out.Flush()
	if false {
		file, err := os.Open("in.txt")
		if err != nil {
			log.Fatal(err)
		}
		in = bufio.NewReaderSize(file, 8192)
	} else {
		in = bufio.NewReaderSize(os.Stdin, 8192)
	}

	var t, a, b, n, m int64
	scanf("%d", &t)

	for ; t > 0; t-- {
		scanf("\n%d %d %d %d", &a, &b, &n, &m)
		if a+b < n+m || min(a, b) < m {
			printf("No\n")
		} else {
			printf("Yes\n")
		}
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	for tc > 0 {
		tc--
		var a, b, n, m uint64
		s, _ := reader.ReadBytes('\n')
		pos := readUint64(s, 0, &a)
		pos = readUint64(s, pos+1, &b)
		pos = readUint64(s, pos+1, &n)
		pos = readUint64(s, pos+1, &m)
		res := solve(int64(a), int64(b), int64(n), int64(m))
		if res {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

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(a, b, n, m int64) bool {
	return n+m <= a+b && m <= min(a, b)
}

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

package main

import (
	"fmt"
)

func min(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func main() {
	var tt int
	var a, b, n, m int64

	fmt.Scan(&tt)

	for tt != 0 {
		fmt.Scan(&a, &b, &n, &m)
		if a+b < n+m {
			fmt.Println("No")
		} else if m <= min(a, b) {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
		tt--
	}
}

/*
URL:
https://codeforces.com/contest/1371/problem/C
*/

package main

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

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

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

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD = 1000000000 + 7
	// MOD          = 998244353
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t int

	a, b, n, m int64
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		a, b, n, m = ReadInt64_4()

		solve()
	}
}

func solve() {
	if a+b < n+m {
		fmt.Println("No")
		return
	}

	if a < b {
		a, b = b, a
	}

	if b < m {
		fmt.Println("No")
		return
	}

	b -= m
	if a+b < n {
		fmt.Println("No")
		return
	}

	fmt.Println("Yes")
}

/*******************************************************************/

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

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

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

var DEBUG = true

func main() {
	defer Flush()

	T := readi()
	for t := 0; t < T; t++ {
		a := readll()
		b := readll()
		n := readll()
		m := readll()
		if solve(a, b, n, m) {
			println("Yes")
		} else {
			println("No")
		}
	}
}

func solve(a, b, n, m int64) bool {
	k := minll(n, m)

	a -= k
	b -= k
	if a < 0 || b < 0 {
		return false
	}

	m -= k
	n -= k
	if n == 0 && m == 0 {
		//dbg(a+k, b+k, n+k, m+k, "=>", a, b, n, m)
		return true
	}
	if 0 < n {
		//dbg(a+k, b+k, n+k, m+k, "=>", a, b, n, m)
		return n <= a+b
	}
	//dbg(a+k, b+k, n+k, m+k, "=>", a, b, n, m)
	return m <= minll(a, b)
}

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func dbgf(f string, args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintf(os.Stderr, f, args...)
}

func dbg(args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

// -----------------------------------------------------------------------------

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

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

func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minf(a, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

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

func maxll(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxf(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

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

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func absf(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

package main

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

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

	var t int
	var a, b, n, m int64

	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		fmt.Fscan(r, &a, &b, &n, &m)

		if (min(a, b) >= m) && (a+b >= m+n) {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
	}
}

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

	return b
}

package main

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

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

	var t int
	var a, b, n, m int64

	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		fmt.Fscan(r, &a, &b, &n, &m)
		if a > b {
			a, b = b, a
		}
		if a < m {
			fmt.Fprintln(w, "NO")
			continue
		}
		if a+b < m+n {
			fmt.Fprintln(w, "NO")
			continue
		}

		fmt.Fprintln(w, "YES")
	}
}

package main

import "fmt"

func main() {
	var tc int
	fmt.Scanf("%d\n", &tc)
	for ; tc > 0; tc-- {
		var a, b, n, m, tmp int64
		fmt.Scanf("%d%d%d%d\n", &a, &b, &n, &m)
		if a < b {
			tmp = a
		} else {
			tmp = b
		}
		if a+b < n+m || m-tmp > 0 {
			fmt.Println("No")
		} else {
			fmt.Println("Yes")
		}
	}
}

package main

import (
	"fmt"
)

func min(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func main() {
	var tt int
	var a, b, n, m int64

	fmt.Scan(&tt)

	for tt != 0 {
		fmt.Scan(&a, &b, &n, &m)
		if a+b < n+m {
			println("No")
		} else if m <= min(a, b) {
			println("Yes")
		} else {
			println("No")
		}
		tt--
	}
}