You have array of $$$n$$$ numbers $$$a_{1}, a_{2}, \ldots, a_{n}$$$. Rearrange these numbers to satisfy $$$|a_{1} - a_{2}| \le |a_{2} - a_{3}| \le \ldots \le |a_{n-1} - a_{n}|$$$, where $$$|x|$$$ denotes absolute value of $$$x$$$. It's always possible to find such rearrangement.Note that all numbers in $$$a$$$ are not necessarily different. In other words, some numbers of $$$a$$$ may be same.You have to answer independent $$$t$$$ test cases.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^{4}$$$) — the number of test cases. The first line of each test case contains single integer $$$n$$$ ($$$3 \le n \le 10^{5}$$$) — the length of array $$$a$$$. It is guaranteed that the sum of values of $$$n$$$ over all test cases in the input does not exceed $$$10^{5}$$$. The second line of each test case contains $$$n$$$ integers $$$a_{1}, a_{2}, \ldots, a_{n}$$$ ($$$-10^{9} \le a_{i} \le 10^{9}$$$).

For each test case, print the rearranged version of array $$$a$$$ which satisfies given condition. If there are multiple valid rearrangements, print any of them.

NoteIn the first test case, after given rearrangement, $$$|a_{1} - a_{2}| = 0 \le |a_{2} - a_{3}| = 1 \le |a_{3} - a_{4}| = 2 \le |a_{4} - a_{5}| = 2 \le |a_{5} - a_{6}| = 10$$$. There are other possible answers like "5 4 5 6 -2 8".In the second test case, after given rearrangement, $$$|a_{1} - a_{2}| = 1 \le |a_{2} - a_{3}| = 2 \le |a_{3} - a_{4}| = 4$$$. There are other possible answers like "2 4 8 1".

package main

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

var reader = bufio.NewReader(os.Stdin)
var 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 scanIntArr() ([]int, error) {
	str, err := reader.ReadString('\n')
	if err != nil {
		return nil, err
	}
	str = strings.TrimRight(str, "\n\r")
	strArr := strings.Split(str, " ")

	arr := make([]int, len(strArr))
	for i, strA := range strArr {
		arr[i], err = strconv.Atoi(strA)
		if err != nil {
			return nil, err
		}
	}

	return arr, nil
}

func main() {
	defer writer.Flush()

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

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

func exec() {
	var n uint64
	scanf("%d %d\n", &n)

	arrA, err := scanIntArr()
	if err != nil {
		fmt.Println(err.Error())
		panic(err)
	}

	sort.Ints(arrA)
	if n%2 != 0 {
		printf("%d ", arrA[n/2])
	}
	for i := n / 2; i > 0; i-- {
		printf("%d ", arrA[i-1])
		printf("%d ", arrA[n-i])
	}
	printf("\n")
}

package main

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

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 int
        fmt.Fscan(in, &n)
        a := make([]int, n)
        for i := range a {
            fmt.Fscan(in, &a[i])
        }
        sort.Ints(a)
        // m +1 -2 +3 -4 +5 -6 ...
        m, sgn := (n - 1) / 2, -1
        for i := 0; i < n; i++ {
            m += sgn*i
            fmt.Fprint(out, a[m], " ")
            sgn = -sgn
        }
        fmt.Fprintln(out)
    }
    out.Flush()
}

package main

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

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < cases; i++ {
		line := readLine(reader)
		n, _ := strconv.ParseInt(string(line), 10, 64)
		line = readLine(reader)
		arrs := strings.Split(string(line), " ")
		arr := make([]int64, n)
		for i := int64(0); i < n; i++ {
			arr[i], _ = strconv.ParseInt(arrs[i], 10, 64)
		}
		sort.Slice(arr, func(i, j int) bool {
			return arr[i] < arr[j]
		})
		i := int64(0)
		if n%2 == 0 {
			i = n/2 - 1
		} else {
			i = n / 2
		}
		dap := int64(1)
		flag := false
		result := make([]int64, 0)
		// fmt.Println(arr)
		for i >= 0 && i < n {
			// fmt.Println(i)
			result = append(result, arr[i])
			if !flag {
				i = i + dap
				flag = true
			} else {
				i = i- dap
				flag = false
			}
			dap++
		}
		// result = append(result, arr[0])
		printArr(result)
		fmt.Println()
	}
}

func printArr(arr []int64) {
	for _, v := range arr {
		fmt.Printf("%d ", v)
	}
}

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
}

/*
URL:
https://codeforces.com/problemset/problem/1339/B
*/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"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
	A []int
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		n = ReadInt()
		A = ReadIntSlice(n)

		solve()
	}
}

func solve() {
	sort.Sort(sort.IntSlice(A))

	mid := n / 2
	answers := []int{A[mid]}
	for l, r := mid-1, mid+1; l >= 0 && r < n; l, r = l-1, r+1 {
		answers = append(answers, A[l], A[r])
	}
	if len(answers) < n {
		answers = append(answers, A[0])
	}

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

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

/*********** 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"
	"os"
	"sort"
)

func main() {
	Solve()
}

func Solve() {
	inBuf := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscanf(inBuf,"%d\n", &t)

	for i := 0; i < t; i++ {
		var n int
		fmt.Fscanf(inBuf, "%d\n", &n)

		format := "%d"
		var valuesInCase []int
		for j := 0; j < n; j++ {
			var num int
			fmt.Fscanf(inBuf, format, &num)
			valuesInCase = append(valuesInCase, num)
			format = " %d"
		}
		fmt.Fscanf(inBuf, "\n", nil)

		arr := FindAscendingDifferencesArray(valuesInCase)
		format1 := "%v"
		for _, v := range arr {
			fmt.Printf(format1, v)
			format1 = " %v"
		}
		fmt.Println()
	}
}

func FindAscendingDifferencesArray(input []int) []int {
	sort.Ints(input)
	index := len(input)/2
	if len(input) % 2 == 0 {
		index -= 1
	}

	res := make([]int, len(input))

	for i := 0; i < len(input); i++ {
		res[i] = input[index]
		shift := i+1
		if i % 2 != 0 {
			shift *= -1
		}
		index += shift
	}

	return res
}

package main

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

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

	var T int
	fmt.Fscanf(reader, "%d\n", &T)
	for T > 0 {
		T -= 1
		var n int
		fmt.Fscanf(reader, "%d\n", &n)
		a := make([]int, n, n)
		for i := 0; i < n; i++ {
			fmt.Fscanf(reader, "%d", &a[i])
		}
		fmt.Fscanf(reader, "\n")
		sort.Ints(a)
		k := n >> 1
		fmt.Fprintf(writer, "%d", a[k])
		for i := k - 1; i >= 0; i-- {
			fmt.Fprintf(writer, " %d", a[i])
			if 2*k-i < n {
				fmt.Fprintf(writer, " %d", a[2*k-i])
			}
		}
		fmt.Fprintf(writer, "\n")
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		n := 0
		fmt.Fscan(in, &n)
		as := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &as[i])
		}
		sort.Ints(as)
		i := (n - 1) / 2
		next := 0
		// to swap next direction ( + = goto right, - = goto left ) at each inc step
		sign := -1
		for next < n-1 {
			i = i + (sign * next)
			fmt.Fprintf(out, "%d ", as[i])
			next++
			sign *= -1
		}
		i = i + (sign * next)
		fmt.Fprintln(out, as[i])
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		n := 0
		fmt.Fscan(in, &n)
		as := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &as[i])
		}
		sort.Ints(as)
		i := (n - 1) / 2
		next := 0
		// to swap next direction ( + = goto right, - = goto left ) at each inc step
		sign := -1
		for next < n-1 {
			i = i + (sign * next)
			fmt.Fprintf(out, "%d ", as[i])
			next++
			sign *= -1
		}
		i = i + (sign * next)
		fmt.Fprintln(out, as[i])
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		n := 0
		fmt.Fscan(in, &n)
		as := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &as[i])
		}
		sort.Ints(as)
		i := (n - 1) / 2
		next := 0
		// to swap next direction ( + = goto right, - = goto left ) at each inc step
		sign := -1
		//fmt.Fprintln(out, t, n, as, next, sign)
		for next < n-1 {
			i = i + (sign * next)
			fmt.Fprintf(out, "%d ", as[i])
			next++
			sign *= -1
		}
		i = i + (sign * next)
		fmt.Fprintln(out, as[i])
	}
}

package main

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

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 {
	NextInt() int
	NextInt64() int64
	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) NextInt() int {
	impl.Scan()
	bb := impl.Bytes()
	i := 0
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int(b - '0')
	}
	return i
}

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) NextString() string {
	impl.Scan()
	return impl.Text()
}

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()
		aa := []int64{}
		for ; n > 0; n-- {
			aa = append(aa, reader.NextInt64())
		}
        res := sol(aa)
        for i := len(res)-1; i > -1; i-- {
            writer.Printf("%d ", res[i])
        }
		writer.Printf("\n")
	}
}

func sol(aa []int64) []int64 {
	sort.Slice(aa, func(i, j int) bool {
        return aa[i] < aa[j]
    })
    l := 0
    r := len(aa) - 1
    left := true
    res := []int64{}
    for l <= r {
        if left {
            res = append(res, aa[l])
            l++
        } else {
            res = append(res, aa[r])
            r--
        }
        left = !left
    }
	return res
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var 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 scanIntArr() ([]int, error) {
	str, err := reader.ReadString('\n')
	if err != nil {
		return nil, err
	}
	str = strings.TrimRight(str, "\n\r")
	strArr := strings.Split(str, " ")

	arr := make([]int, len(strArr))
	for i, strA := range strArr {
		arr[i], err = strconv.Atoi(strA)
		if err != nil {
			return nil, err
		}
	}

	return arr, nil
}

func main() {
	defer writer.Flush()

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

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

func exec() {
	var n uint64
	scanf("%d %d\n", &n)

	arrA, err := scanIntArr()
	if err != nil {
		fmt.Println(err.Error())
		panic(err)
	}

	quicksort(arrA)
	if n%2 != 0 {
		printf("%d ", arrA[n/2+1])
	}
	for i := n / 2; i > 0; i-- {
		printf("%d ", arrA[i-1])
		if i != 0 {
			printf("%d ", arrA[n-i])
			continue
		}
		printf("%d", arrA[n-i])
	}
	printf("\n")
}

func quicksort(a []int) []int {
	if len(a) < 2 {
		return a
	}

	left, right := 0, len(a)-1

	pivot := rand.Int() % len(a)

	a[pivot], a[right] = a[right], a[pivot]

	for i, _ := range a {
		if a[i] < a[right] {
			a[left], a[i] = a[i], a[left]
			left++
		}
	}

	a[left], a[right] = a[right], a[left]

	quicksort(a[:left])
	quicksort(a[left+1:])

	return a
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var 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 scanIntArr() ([]int, error) {
	str, err := reader.ReadString('\n')
	if err != nil {
		return nil, err
	}
	str = strings.TrimRight(str, "\n\r")
	strArr := strings.Split(str, " ")

	arr := make([]int, len(strArr))
	for i, strA := range strArr {
		arr[i], err = strconv.Atoi(strA)
		if err != nil {
			return nil, err
		}
	}

	return arr, nil
}

func main() {
	defer writer.Flush()

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

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

func exec() {
	var n uint64
	scanf("%d %d\n", &n)

	arrA, err := scanIntArr()
	if err != nil {
		fmt.Println(err.Error())
		panic(err)
	}

	quicksort(arrA)
	if n%2 != 0 {
		printf("%d ", arrA[n%2+1])
	}
	for i := n / 2; i > 0; i-- {
		printf("%d ", arrA[i-1])
		if i != 0 {
			printf("%d ", arrA[n-i])
			continue
		}
		printf("%d", arrA[n-i])
	}
	printf("\n")
}

func quicksort(a []int) []int {
	if len(a) < 2 {
		return a
	}

	left, right := 0, len(a)-1

	pivot := rand.Int() % len(a)

	a[pivot], a[right] = a[right], a[pivot]

	for i, _ := range a {
		if math.Abs(float64(a[i])) < math.Abs(float64(a[right])) {
			a[left], a[i] = a[i], a[left]
			left++
		}
	}

	a[left], a[right] = a[right], a[left]

	quicksort(a[:left])
	quicksort(a[left+1:])

	return a
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var 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 scanIntArr() ([]int, error) {
	str, err := reader.ReadString('\n')
	if err != nil {
		return nil, err
	}
	str = strings.TrimRight(str, "\n\r")
	strArr := strings.Split(str, " ")

	arr := make([]int, len(strArr))
	for i, strA := range strArr {
		arr[i], err = strconv.Atoi(strA)
		if err != nil {
			return nil, err
		}
	}

	return arr, nil
}

func main() {
	defer writer.Flush()

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

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

func exec() {
	var n uint64
	scanf("%d %d\n", &n)

	arrA, err := scanIntArr()
	if err != nil {
		fmt.Println(err.Error())
		panic(err)
	}

	quicksort(arrA)
	if n%2 != 0 {
		printf("%d ", arrA[n%2+1])
	}
	for i := n / 2; i > 0; i-- {
		printf("%d ", arrA[i-1])
		if i != 0 {
			printf("%d ", arrA[n-i])
			continue
		}
		printf("%d", arrA[n-i])
	}
	printf("\n")
}

func quicksort(a []int) []int {
	if len(a) < 2 {
		return a
	}

	left, right := 0, len(a)-1

	pivot := rand.Int() % len(a)

	a[pivot], a[right] = a[right], a[pivot]

	for i, _ := range a {
		if a[i] < a[right] {
			a[left], a[i] = a[i], a[left]
			left++
		}
	}

	a[left], a[right] = a[right], a[left]

	quicksort(a[:left])
	quicksort(a[left+1:])

	return a
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var 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 scanIntArr() ([]int, error) {
	str, err := reader.ReadString('\n')
	if err != nil {
		return nil, err
	}
	str = strings.TrimRight(str, "\n\r")
	strArr := strings.Split(str, " ")

	arr := make([]int, len(strArr))
	for i, strA := range strArr {
		arr[i], err = strconv.Atoi(strA)
		if err != nil {
			return nil, err
		}
	}

	return arr, nil
}

func main() {
	defer writer.Flush()

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

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

func exec() {
	var n uint64
	scanf("%d %d\n", &n)

	arrA, err := scanIntArr()
	if err != nil {
		fmt.Println(err.Error())
		panic(err)
	}

	quicksort(arrA)
	if n%2 != 0 {
		printf("%d ", arrA[n/2])
	}
	for i := n / 2; i > 0; i-- {
		printf("%d ", arrA[i-1])
		printf("%d", arrA[n-i])
	}
	printf("\n")
}

func quicksort(a []int) []int {
	if len(a) < 2 {
		return a
	}

	left, right := 0, len(a)-1

	pivot := rand.Int() % len(a)

	a[pivot], a[right] = a[right], a[pivot]

	for i, _ := range a {
		if a[i] < a[right] {
			a[left], a[i] = a[i], a[left]
			left++
		}
	}

	a[left], a[right] = a[right], a[left]

	quicksort(a[:left])
	quicksort(a[left+1:])

	return a
}

package main

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

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < cases; i++ {
		line := readLine(reader)
		n, _ := strconv.ParseInt(string(line), 10, 64)
		line = readLine(reader)
		arrs := strings.Split(string(line), " ")
		arr := make([]int64, n)
		for i := int64(0); i < n; i++ {
			arr[i], _ = strconv.ParseInt(arrs[i], 10, 64)
		}
		sort.Slice(arr, func(i, j int) bool {
			return arr[i] < arr[j]
		})
		i := int64(0)
		if n%2 == 0 {
			i = n/2 - 1
		} else {
			i = n / 2
		}
		dap := int64(1)
		flag := false
		result := make([]int64, 0)
		fmt.Println(arr)
		for i >= 0 {
			fmt.Println(i)
			result = append(result, arr[i])
			if !flag {
				i = i + dap
				flag = true
			} else {
				i = i- dap
				flag = false
			}
			dap++
		}
		// result = append(result, arr[0])
		printArr(result)
		fmt.Println()
	}
}

func printArr(arr []int64) {
	for _, v := range arr {
		fmt.Printf("%d ", v)
	}
}

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
}


There are $$$n$$$ people participating in some contest, they start participating in $$$x$$$ minutes intervals. That means the first participant starts at time $$$0$$$, the second participant starts at time $$$x$$$, the third — at time $$$2 \cdot x$$$, and so on.Duration of contest is $$$t$$$ minutes for each participant, so the first participant finishes the contest at time $$$t$$$, the second — at time $$$t + x$$$, and so on. When a participant finishes the contest, their dissatisfaction equals to the number of participants that started the contest (or starting it now), but haven't yet finished it.Determine the sum of dissatisfaction of all participants.

The first line contains a single integer $$$k$$$ ($$$1 \le k \le 1000$$$) — the number of test cases. Each of the next $$$k$$$ lines contains three integers $$$n$$$, $$$x$$$, $$$t$$$ ($$$1 \le n, x, t \le 2 \cdot 10^9$$$) — the number of participants, the start interval and the contest duration.

Print $$$k$$$ lines, in the $$$i$$$-th line print the total dissatisfaction of participants in the $$$i$$$-th test case.

NoteIn the first example the first participant starts at $$$0$$$ and finishes at time $$$5$$$. By that time the second and the third participants start, so the dissatisfaction of the first participant is $$$2$$$. The second participant starts at time $$$2$$$ and finishes at time $$$7$$$. By that time the third the fourth participants start, so the dissatisfaction of the second participant is $$$2$$$. The third participant starts at $$$4$$$ and finishes at $$$9$$$. By that time the fourth participant starts, so the dissatisfaction of the third participant is $$$1$$$.The fourth participant starts at $$$6$$$ and finishes at $$$11$$$. By time $$$11$$$ everyone finishes the contest, so the dissatisfaction of the fourth participant is $$$0$$$.In the second example the first participant starts at $$$0$$$ and finishes at time $$$2$$$. By that time the second participants starts, and the third starts at exactly time $$$2$$$. So the dissatisfaction of the first participant is $$$2$$$. The second participant starts at time $$$1$$$ and finishes at time $$$3$$$. At that time the third participant is solving the contest.

package main

import (
	"fmt"
)
func max(a,b uint64) uint64{
	if a > b {
		return a
	}
	return b;
}
func min(a,b uint64) uint64{
	if a < b {
		return a
	}
	return b
}
func main() {
	var k int
//	fmt.Println("hello")
	fmt.Scanf("%d\n",&k)
	for ;k>=1;k--{
		var n,x,t uint64
		fmt.Scanf("%d%d%d\n",&n,&x,&t)
		//fmt.Printf("%d %d %d\n",n,x,t)
		mx := min(n,t/x)
		stduent_on_max := n-mx
		temp := (mx-1)*mx/2+mx*stduent_on_max
		fmt.Printf("%d\n",temp)
	}
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n, x, t, ans uint64
		_, _ = fmt.Fscan(in, &n, &x, &t)

		m := t / x

		if m > n {
			m = n
		}

		ans += (m * (m - 1)) / 2

		if n > m {
			ans += (n - m) * m
		}

		fmt.Println(ans)
	}
}

package main

import (
	"fmt"
)

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

func f(n, x, t int64, c chan int64) {
	cnt := Min(n, t/x)
	c <- n*cnt - cnt*(cnt+1)/2
	close(c)
}

func main() {
	var k int32
	fmt.Scanf("%d\n", &k)
	chans := make([]chan int64, k)
	for i := int32(0); i < k; i++ {
		var n, x, t int64
		fmt.Scanf("%d %d %d\n", &n, &x, &t)
		chans[i] = make(chan int64, 1)
		go f(n, x, t, chans[i])
	}
	for i := int32(0); i < k; i++ {
		fmt.Printf("%d\n", <-chans[i])
	}
}

package main

import (
	"fmt"
)

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

func f(n, x, t int64, c chan int64) {
	cnt := Min(n, t/x)
	c <- n*cnt - cnt*(cnt+1)/2
	close(c)
}

func main() {
	var k int32
	fmt.Scanf("%d\n", &k)
	chans := make([]chan int64, k)
	for i := int32(0); i < k; i++ {
		var n, x, t int64
		fmt.Scanf("%d %d %d\n", &n, &x, &t)
		chans[i] = make(chan int64)
		go f(n, x, t, chans[i])
	}
	for i := int32(0); i < k; i++ {
		fmt.Printf("%d\n", <-chans[i])
	}
}

package main

import (
	"fmt"
)

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

func f(n, x, t int64) int64 {
	cnt := Min(n, t/x)
	return n*cnt - cnt*(cnt+1)/2
}

func main() {
	var k int32
	fmt.Scanf("%d\n", &k)
	for ; k > 0; k-- {
		var n, x, t int64
		fmt.Scanf("%d %d %d\n", &n, &x, &t)
		ans := f(n, x, t)
		fmt.Printf("%d\n", ans)
	}
}

/*input

*/
package main

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

var str string
var tc,n,x,t,d int64

func main(){
	var cin io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(cin,&tc)
	for tc>0{
		tc--
		fmt.Fscan(cin,&n,&x,&t)
		d=t/x
		if n>d+1{
			fmt.Println(d*(d-1)/2+(n-d)*d)
		}else{
			fmt.Println(n*(n-1)/2)
		}
	}
}

package main

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

var tc,n,x,t,d int64

func main() {
  var cin io.Reader = bufio.NewReader(os.Stdin)
  fmt.Fscan(cin, &tc)
  for tc>0{
    tc--
    fmt.Fscan(cin, &n,&x,&t)
    d=t/x
    if n>d+1{
      fmt.Println(d*(d-1)/2+(n-d)*d)
    } else {
      fmt.Println(n*(n-1)/2)
    }
  }
}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

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

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

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

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	var l, q int64
	l = MAX(x, y)
	q = MIN(x, y)
	var m int64
	for l*q > 0 {
		a := l % q
		b := l - a
		cc := int64(b / q)
		remain := l - cc*q
		l = MAX(remain, q)
		q = MIN(remain, q)
		if l*q == 0 {
			m = l + q
			break
		}

	}
	return m
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

var k int

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

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

		var m int64

		m = int64(t / x)
		var sum int64
		if n < m+1 {
			sum = n * (n - 1) / 2
		} else {
			sum = (m * (m - 1) / 2) + (n-m)*m
		}

		fmt.Println(sum)

	}
}

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, x, d int
		fmt.Fscan(in, &n, &x, &d)

		var total int64
		z := int64(d / x)
		if int(z) <= n-1 {
			total = (int64(n) - z) * z
		}

		if z > int64(n) {
			z = int64(n)
		}

		z--
		total += z * (z + 1) / 2
		fmt.Fprintln(out, total)
	}
}

package main

import (
	"fmt"
)

func Max(a, b uint64) uint64 {
	if a > b {
		return a
	}
	return b
}

func Min(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func process() {
	var n, x, t uint64
	fmt.Scanf("%d %d %d\n", &n, &x, &t)
	mx := Min(n, t/x)
	// mx := t / x
	students_on_max := n - mx
	tot := (mx*(mx-1))/2 + mx*students_on_max
	fmt.Printf("%d\n", tot)
}

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

package main

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

type Scanner struct {
    scanner *bufio.Scanner
}

func StdinScanner() *Scanner {
    scanner := new(Scanner)
    scanner.scanner = bufio.NewScanner(os.Stdin)
    scanner.scanner.Split(bufio.ScanWords)

    return scanner
}

func (s Scanner) Int() int {
    s.scanner.Scan()
    n, _ := strconv.Atoi(s.scanner.Text())

    return n
}

func (s Scanner) Int64() int64 {
    s.scanner.Scan()
    n, _ := strconv.ParseInt(s.scanner.Text(), 10, 64)

    return n
}

func (s Scanner) Token() string {
    s.scanner.Scan()

    return s.scanner.Text()
}

func main() {
    scanner := StdinScanner()
    tests := scanner.Int()

    for i := 0; i < tests; i += 1 {
        n, x, t := scanner.Int64(), scanner.Int64(), scanner.Int64()
        kk := int64(math.Min(float64(t / x), float64(n - 1)))

        res := kk * (n - kk) + (kk - 1) * kk / 2
        fmt.Println(res)
    }
}

// 00
package main

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

type Anything interface {
	int64 | float64 | int | string | float32
}

func write[K Anything](f *bufio.Writer, a K) {
	f.Write([]byte(fmt.Sprint(a)))
}

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for k := 1; k <= T; k++ {
		var n, x, t, ans int64
		fmt.Fscan(reader, &n, &x, &t)
		d := t / x
		if n > d {
			ans = (d*(d+1))/2 + (n-d-1)*d
		} else {
			ans = ((n - 1) * n) / 2
		}
		write(f, ans)
		write(f, "\n")
	}
}

// 00
package main

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

func write_int(f *bufio.Writer, a int64) {
	f.Write([]byte(fmt.Sprint(a)))
}
func write_string(f *bufio.Writer, a string) {
	f.Write([]byte(a))
}

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for k := 1; k <= T; k++ {
		var n, x, t, ans int64
		fmt.Fscan(reader, &n, &x, &t)
		d := t / x
		if n > d {
			ans = (d*(d+1))/2 + (n-d-1)*d
		} else {
			ans = ((n - 1) * n) / 2
		}
		write_int(f, ans)
		write_string(f, "\n")
	}
}

package main

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

var p int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &p)
	for o := 0; o < p; o++ {
		var n, x, t int64
		fmt.Fscan(input, &n)
		fmt.Fscan(input, &x)
		fmt.Fscan(input, &t)
		if t >= (n - 1) * x {
			fmt.Println(((n-1)*n)/2)
		}else{
			var k int64 = t / x
			fmt.Println(((n-k)*k + ((k-1)*k)/2))
		}
	}
}

package main

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

const (
// mx = 2e5 + 10
)

var n, x, t, k int64

func main() {

	var cin io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(cin, &k)

	for k > 0 {
		k--

		fmt.Fscan(cin, &n, &x, &t)
		berapa := t / x
		if berapa > n {
			ans := n * (n - 1) / 2
			fmt.Println(ans)
			continue
		}
		ans := berapa*n - berapa*(berapa+1)/2
		fmt.Println(ans)
	}

}

package main

import "fmt"

func main() {
	var k int
	fmt.Scanln(&k)
	var tc int
	tc = 0
	for tc < k {
		var n,x,t uint64
		fmt.Scan(&n)
		fmt.Scan(&x)
		fmt.Scan(&t)
		var soln uint64
		if n > (t/x) {
			soln = (n - (t/x))*(t/x)
			l := (t/x) - 1
			soln = soln + (l*(l+1)/2)
		} else {
			l := n - 1
			soln = soln + (l*(l+1)/2)
		}
		fmt.Println(soln)
		tc++
	}
}

package main

import (
	"bufio"
	"os"
	"fmt"

)

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

	var t int
	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {

		var n, x, t int
		fmt.Fscan(r, &n, &x, &t)

		ans := solve(n, x, t)
		fmt.Println(ans)
	}

}

func solve(n, x , t int) int64 {

	if x > t {
		return 0
	}

	if x == t {
		return int64(n) - 1
	}

	d := t/x

	if n < d {
		return (int64(n - 1) * int64(n))/2

	} else {

		k := n - d

		s1 := int64(k) * int64(d)
		s2 := (int64(d - 1) * int64(d))/2

		return  s1 + s2
	}

	return int64(d) * int64(n)

}

package main

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

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var k int
	Fscan(in, &k)
	for i := 0; i < k; i++ {
		var n, t, x int
		Fscan(in, &n, &x, &t)
		cnt := int64(min(n-1, int(t/x)))
		var ans int64
		ans += cnt * (int64(n-1) - cnt)
		ans += (cnt + 1) * cnt / 2
		Fprintln(out, ans)
	}
}

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

package main

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

type Scanner struct {
	bScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bScanner := bufio.NewScanner(os.Stdin)
	bScanner.Split(bufio.ScanWords)
	bScanner.Buffer([]byte{}, math.MaxInt32)
	return &Scanner{
		bScanner,
	}
}
func (s *Scanner) Next() string {
	s.bScanner.Scan()
	return s.bScanner.Text()
}
func (s *Scanner) NextInt() int {
	s.bScanner.Scan()
	res, err := strconv.Atoi(s.bScanner.Text())
	if err != nil {
		panic(err)
	}
	return res
}
func (s *Scanner) NextInt64() int64 {
	s.bScanner.Scan()
	res, err := strconv.ParseInt(s.bScanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}
func (s *Scanner) NextFloat() float64 {
	s.bScanner.Scan()
	res, err := strconv.ParseFloat(s.bScanner.Text(), 64)
	if err != nil {
		panic(err)
	}
	return res
}
func (s *Scanner) NextInts(N int) []int {
	res := make([]int, N)
	for i := 0; i < N; i++ {
		res[i] = s.NextInt()
	}
	return res
}
func (s *Scanner) NextInt64s(N int) []int64 {
	res := make([]int64, N)
	for i := 0; i < N; i++ {
		res[i] = s.NextInt64()
	}
	return res
}
func Min(nums ...int) int {
	ans := math.MaxInt32
	for _, num := range nums {
		if num < ans {
			ans = num
		}
	}
	return ans
}
func Max(nums ...int) int {
	ans := math.MinInt32
	for _, num := range nums {
		if num > ans {
			ans = num
		}
	}
	return ans
}

func InitInts1D(n int, val int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = val
	}
	return res
}
func InitInts2D(n, m int, val int) [][]int {
	res := make([][]int, n)
	for i := 0; i < n; i++ {
		res[i] = InitInts1D(m, val)
	}
	return res
}
func InitInts3D(n, m, k int, val int) [][][]int {
	res := make([][][]int, n)
	for i := 0; i < n; i++ {
		res[i] = InitInts2D(m, k, val)
	}
	return res
}

type StepState struct {
	step, dist int
}
type PriorityQueue []*StepState

func (pq PriorityQueue) Len() int { return len(pq) }
func (pq PriorityQueue) Less(i, j int) bool {
	if pq[i].step != pq[j].step {
		return pq[i].step < pq[j].step
	}
	return pq[i].dist < pq[j].dist
}
func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}
func (pq *PriorityQueue) Push(x interface{}) {
	item := x.(*StepState)
	*pq = append(*pq, item)
}
func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

func main() {
	sc := NewScanner()
	wr := bufio.NewWriter(os.Stdout)
	defer wr.Flush()

	TC := sc.NextInt()
	for tc := 0; tc < TC; tc++ {
		n := sc.NextInt()
		x := sc.NextInt()
		t := sc.NextInt()

		ans := int64(0)
		if x <= t {
			upperBound := t / x
			incSeqLen := Min(n, t/x+1)
			flatSeqLen := n - incSeqLen
			ans = int64(incSeqLen)*int64(incSeqLen-1)/2 + int64(flatSeqLen)*int64(upperBound)
		}
		fmt.Fprintln(wr, ans)
	}

}

package main

import (
	"fmt"
)
func max(a,b uint64) uint64{
	if a > b {
		return a
	}
	return b;
}
func min(a,b uint64) uint64{
	if a < b {
		return a
	}
	return b
}
func main() {
	var k int
//	fmt.Println("hello")
	fmt.Scanf("%d\n",&k)
	for ;k>=1;k--{
		var n,x,t uint64
		fmt.Scanf("%d%d%d\n",&n,&x,&t)
		//fmt.Printf("%d %d %d\n",n,x,t)
		temp :=(0+min(n-1,t/x-1))*(t/x)/2
		temp +=max(0, n-t/x)*(t/x)
		fmt.Printf("%d\n",temp)
	}
}

package main

import "fmt"

func main() {
	var k int
//	fmt.Println("hello")
	fmt.Scanf("%d\n",&k)
	for ;k>=1;k--{
		var n,x,t uint64
		fmt.Scanf("%d%d%d\n",&n,&x,&t)
		//fmt.Printf("%d %d %d\n",n,x,t)
		temp :=(0+t/x-1)*(t/x)/2
		temp +=(n-t/x)*(t/x)
		fmt.Printf("%d\n",temp)
	}
}

package main

import "fmt"

func main() {
	var k int
//	fmt.Println("hello")
	fmt.Scanf("%d\n",&k)
	for ;k>=1;k--{
		var n,x,t int64
		fmt.Scanf("%d%d%d\n",&n,&x,&t)
		//fmt.Printf("%d %d %d\n",n,x,t)
		temp :=(0+t/x-1)*(t/x)/2
		temp +=(n-t/x)*(t/x)
		fmt.Printf("%d\n",temp)
	}
}

package main

import "fmt"

func main() {
	var k int
//	fmt.Println("hello")
	fmt.Scanf("%d\n",&k)
	for ;k>=1;k--{
		var n,x,t int
		fmt.Scanf("%d%d%d\n",&n,&x,&t)
		//fmt.Printf("%d %d %d\n",n,x,t)
		temp :=(0+t/x-1)*(t/x)/2
		temp +=(n-t/x)*(t/x)
		fmt.Printf("%d\n",temp)
	}
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n, x, t, ans uint64
		_, _ = fmt.Fscan(in, &n, &x, &t)

		m := t / x

		ans += (m * (m - 1)) / 2

		if n > m {
			ans += (n - m) * m
		}

		fmt.Println(ans)
	}
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n, x, t, ans int64
		_, _ = fmt.Fscan(in, &n, &x, &t)

		m := t / x

		if m > 0 {
			ans += (m * (m - 1)) / 2
		}

		if n > m {
			ans += (n - m) * m
		}

		fmt.Println(ans)
	}
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n, x, t, ans int64
		_, _ = fmt.Fscan(in, &n, &x, &t)

		m := t / x

		if m > 0 {
			ans += m * (m - 1) / 2
		}

		if n > m {
			ans += (n - m) * m
		}

		fmt.Println(ans)
	}
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n, x, t int64
		_, _ = fmt.Fscan(in, &n, &x, &t)

		m := t / x

		ans := m * (m - 1) / 2

		if n > m {
			ans += (n - m) * m
		}

		fmt.Println(ans)
	}
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n, x, t int64
		_, _ = fmt.Fscan(in, &n, &x, &t)

		m := t / x

		ans := (n-m)*m + (m * (m - 1) / 2)

		fmt.Println(ans)
	}
}

package main

import "fmt"

func f(n, x, t int64) int64 {
	cnt := t / x
	return n*cnt - cnt*(cnt+1)/2
}

func main() {
	var k int32
	fmt.Scanf("%d\n", &k)
	for ; k > 0; k-- {
		var n, x, t int64
		fmt.Scanf("%d %d %d\n", &n, &x, &t)
		ans := f(n, x, t)
		fmt.Printf("%d\n", ans)
	}
}

/*input

*/
package main

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

var str string
var tc,n,x,t,d int

func main(){
	var cin io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(cin,&tc)
	for tc>0{
		tc--
		fmt.Fscan(cin,&n,&x,&t)
		d=t/x
		if n>d+1{
			fmt.Println(d*(d-1)/2+(n-d)*d)
		}else{
			fmt.Println(n*(n-1)/2)
		}
	}
}

package main

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

var tc,n,x,t,d int

func main() {
  var cin io.Reader = bufio.NewReader(os.Stdin)
  fmt.Fscan(cin, &tc)
  for tc>0{
    tc--
    fmt.Fscan(cin, &n,&x,&t)
    d=t/x
    if n>d+1{
      fmt.Println(d*(d-1)/2+(n-d)*d)
    } else {
      fmt.Println(n*(n-1)/2)
    }
  }
}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

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

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

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

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	var l, q int64
	l = MAX(x, y)
	q = MIN(x, y)
	var m int64
	for l*q > 0 {
		a := l % q
		b := l - a
		cc := int64(b / q)
		remain := l - cc*q
		l = MAX(remain, q)
		q = MIN(remain, q)
		if l*q == 0 {
			m = l + q
			break
		}

	}
	return m
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

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

		fmt.Fscan(input, &t)

		m := int64(t / x)
		if n >= m-1 {
			var qq int64
			qq = m * (2*n - m - 1) / 2
			fmt.Println(qq)
		} else {
			var qq int64
			qq = n * (n - 1) / 2
			fmt.Println(qq)
		}
	}

}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

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

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

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

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	var l, q int64
	l = MAX(x, y)
	q = MIN(x, y)
	var m int64
	for l*q > 0 {
		a := l % q
		b := l - a
		cc := int64(b / q)
		remain := l - cc*q
		l = MAX(remain, q)
		q = MIN(remain, q)
		if l*q == 0 {
			m = l + q
			break
		}

	}
	return m
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

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

		fmt.Fscan(input, &t)
		m := int64(t / x)
		var qq int64
		qq = m * (2*n - m - 1) / 2
		fmt.Println(qq)

	}

}

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, x, d int
		fmt.Fscan(in, &n, &x, &d)

		var total int64
		z := int64(d / x)
		if int(z) <= n-1 {
			total = (int64(n) - z) * z
		}

		z--
		total += z * (z + 1) / 2
		fmt.Fprintln(out, total)
	}
}

package main

import (
	"fmt"
)

func process() {
	var n, x, t uint64
	fmt.Scanf("%d %d %d\n", &n, &x, &t)
	max := t / x
	students_on_max := n - max
	tot := (max*(max-1))/2 + max*students_on_max
	fmt.Printf("%d\n", tot)
}

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

package main

import (
	"fmt"
)

func process() {
	var n, x, t int
	fmt.Scanf("%d %d %d\n", &n, &x, &t)
	max := t / x
	students_on_max := n - max
	tot := (max*(max-1))/2 + max*students_on_max
	fmt.Printf("%d\n", tot)
}

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

package main

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

type Scanner struct {
    scanner *bufio.Scanner
}

func StdinScanner() *Scanner {
    scanner := new(Scanner)
    scanner.scanner = bufio.NewScanner(os.Stdin)
    scanner.scanner.Split(bufio.ScanWords)

    return scanner
}

func (s Scanner) Int() int {
    s.scanner.Scan()
    n, _ := strconv.Atoi(s.scanner.Text())

    return n
}

func (s Scanner) Int64() int64 {
    s.scanner.Scan()
    n, _ := strconv.ParseInt(s.scanner.Text(), 10, 64)

    return n
}

func (s Scanner) Token() string {
    s.scanner.Scan()

    return s.scanner.Text()
}

func main() {
    scanner := StdinScanner()
    tests := scanner.Int()

    for i := 0; i < tests; i += 1 {
        n, x, t := scanner.Int64(), scanner.Int64(), scanner.Int64()
        kk := t / x

        res := kk * (n - kk) + (kk - 1) * kk / 2
        fmt.Println(res)
    }
}

package main

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

type Scanner struct {
    scanner *bufio.Scanner
}

func StdinScanner() *Scanner {
    scanner := new(Scanner)
    scanner.scanner = bufio.NewScanner(os.Stdin)
    scanner.scanner.Split(bufio.ScanWords)

    return scanner
}

func (s Scanner) Int() int {
    s.scanner.Scan()
    n, _ := strconv.Atoi(s.scanner.Text())

    return n
}

func (s Scanner) Token() string {
    s.scanner.Scan()

    return s.scanner.Text()
}

func main() {
    scanner := StdinScanner()
    tests := scanner.Int()

    for i := 0; i < tests; i += 1 {
        n, x, t := scanner.Int(), scanner.Int(), scanner.Int()
        kk := t / x

        res := kk * (n - kk) + (kk - 1) * kk / 2
        fmt.Println(res)
    }
}

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, x, t int
		fmt.Fscan(input, &n)
		fmt.Fscan(input, &x)
		fmt.Fscan(input, &t)
		if t >= (n - 1) * x {
			fmt.Println(((n-1)*n)/2)
		}else{
			var k int = t / x
			fmt.Println(((n-k)*k + ((k-1)*k)/2))
		}
	}
}

package main

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

const (
// mx = 2e5 + 10
)

var n, x, t, k int64

func main() {

	var cin io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(cin, &k)

	for k > 0 {
		k--

		fmt.Fscan(cin, &n, &x, &t)
		berapa := t / x
		ans := berapa*n - berapa*(berapa+1)/2
		fmt.Println(ans)
	}

}

package main

import "fmt"

func main() {
	var k int
	fmt.Scanln(&k)
	var tc int
	tc = 0
	for tc < k {
		var n,x,t uint64
		fmt.Scan(&n)
		fmt.Scan(&x)
		fmt.Scan(&t)
		var soln uint64
		soln = (n - (t/x))*(t/x)
		l := (t/x) - 1
		soln = soln + (l*(l+1)/2)
		fmt.Println(soln)
		tc++
	}
}

package main

import (
	"bufio"
	"os"
	"fmt"

)

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

	var t int
	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {

		var n, x, t int
		fmt.Fscan(r, &n, &x, &t)

		ans := solve(n, x, t)
		fmt.Println(ans)
	}

}

func solve(n, x , t int) int64 {

	if x > t {
		return 0
	}

	if x == t {
		return int64(n)
	}

	d := t/x

	if n < d {
		return (int64(n - 1) * int64(n))/2

	} else {

		k := n - d

		s1 := int64(k) * int64(d)
		s2 := (int64(d - 1) * int64(d))/2

		return  s1 + s2
	}

	return int64(d) * int64(n)

}


During the research on properties of the greatest common divisor (GCD) of a set of numbers, Ildar, a famous mathematician, introduced a brand new concept of the weakened common divisor (WCD) of a list of pairs of integers.For a given list of pairs of integers $$$(a_1, b_1)$$$, $$$(a_2, b_2)$$$, ..., $$$(a_n, b_n)$$$ their WCD is arbitrary integer greater than $$$1$$$, such that it divides at least one element in each pair. WCD may not exist for some lists.For example, if the list looks like $$$[(12, 15), (25, 18), (10, 24)]$$$, then their WCD can be equal to $$$2$$$, $$$3$$$, $$$5$$$ or $$$6$$$ (each of these numbers is strictly greater than $$$1$$$ and divides at least one number in each pair).You're currently pursuing your PhD degree under Ildar's mentorship, and that's why this problem was delegated to you. Your task is to calculate WCD efficiently.

The first line contains a single integer $$$n$$$ ($$$1 \le n \le 150\,000$$$) — the number of pairs. Each of the next $$$n$$$ lines contains two integer values $$$a_i$$$, $$$b_i$$$ ($$$2 \le a_i, b_i \le 2 \cdot 10^9$$$).

Print a single integer — the WCD of the set of pairs.  If there are multiple possible answers, output any; if there is no answer, print $$$-1$$$.

NoteIn the first example the answer is $$$6$$$ since it divides $$$18$$$ from the first pair, $$$24$$$ from the second and $$$12$$$ from the third ones. Note that other valid answers will also be accepted.In the second example there are no integers greater than $$$1$$$ satisfying the conditions.In the third example one of the possible answers is $$$5$$$. Note that, for example, $$$15$$$ is also allowed, but it's not necessary to maximize the output.

package main

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

func main()  {

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

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

	var x, y int
	fmt.Fscan(in, &x, &y)

	d := dividers(x)
	for _, yV := range dividers(y) {
		b := true
		for _, xV := range d {
			if xV == yV {
				b = false
				break
			}
		}
		if b {
			d = append(
				d,
				yV,
			)
		}
	}

	cnt := make([]int, len(d))
	for i := 0; i < len(cnt); i++ {
		cnt[i] = 1
	}

	for i := 1; i < n; i++ {
		fmt.Fscan(in, &x, &y)
		for j := 0; j < len(d); j++ {
			if x % d[j] == 0 || y % d[j] == 0 {
				cnt[j]++
			}
		}
	}

	for i := 0; i < len(d); i++ {
		if cnt[i] == n {
			fmt.Fprintln(out, d[i])
			return
		}
	}

	fmt.Fprintln(out, "-1")

}

func dividers(a int) []int {

	list := make([]int, 0)

	i, max := 2, int(math.Floor(math.Sqrt(float64(a))))
	for i <= max {
		if a%i == 0 {
			if len(list) == 0 || list[len(list) - 1] != i {
				list = append(
					list,
					i,
				)
			}
			a /= i
		} else {
			i++
		}
	}

	if a > 1 {
		list = append(
			list,
			a,
		)
	}

	return list

}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1025B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	gcd := func(a, b int64) int64 {
		for a != 0 {
			a, b = b%a, a
		}
		return b
	}
	lcm := func(a, b int64) int64 { return a / gcd(a, b) * b }

	var n int
	var x, y, a, b int64
	Fscan(in, &n, &x, &y)
	g := lcm(x, y)
	for n--; n > 0; n-- {
		Fscan(in, &a, &b)
		g = gcd(g, lcm(a, b))
	}
	f := func(n int64) int64 {
		for i := int64(2); i*i <= n; i++ {
			if n%i == 0 && g%i == 0 {
				return i
			}
			for ; n%i == 0; n /= i {
			}
		}
		if n > 1 && g%n == 0 {
			return n
		}
		return -1
	}
	ans := f(x)
	if ans == -1 {
		ans = f(y)
	}
	Fprint(out, ans)
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1025B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	gcd := func(a, b int64) int64 {
		for a != 0 {
			a, b = b%a, a
		}
		return b
	}
	lcm := func(a, b int64) int64 { return a / gcd(a, b) * b }

	var n int
	var x, y, a, b int64
	Fscan(in, &n, &x, &y)
	g := lcm(x, y)
	for n--; n > 0; n-- {
		Fscan(in, &a, &b)
		g = gcd(g, lcm(a, b))
	}
	f := func(n int64) int64 {
		for d := int64(1); d*d <= n; d++ {
			if n%d == 0 {
				if d > 1 && g%d == 0 {
					return d
				}
				if g%(n/d) == 0 {
					return n / d
				}
			}
		}
		return -1
	}
	ans := f(x)
	if ans == -1 {
		ans = f(y)
	}
	Fprint(out, ans)
}

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


Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if it starts with a bad day, ends with a bad day, and good and bad days are alternating in it. Let us denote bad days as 0 and good days as 1. Then, for example, sequences of days 0, 010, 01010 are zebras, while sequences 1, 0110, 0101 are not.Oleg tells you the story of days he lived in chronological order in form of string consisting of 0 and 1. Now you are interested if it is possible to divide Oleg's life history into several subsequences, each of which is a zebra, and the way it can be done. Each day must belong to exactly one of the subsequences. For each of the subsequences, days forming it must be ordered chronologically. Note that subsequence does not have to be a group of consecutive days.

In the only line of input data there is a non-empty string s consisting of characters 0 and 1, which describes the history of Oleg's life. Its length (denoted as |s|) does not exceed 200 000 characters.

If there is a way to divide history into zebra subsequences, in the first line of output you should print an integer k (1 ≤ k ≤ |s|), the resulting number of subsequences. In the i-th of following k lines first print the integer li (1 ≤ li ≤ |s|), which is the length of the i-th subsequence, and then li indices of days forming the subsequence. Indices must follow in ascending order. Days are numbered starting from 1. Each index from 1 to n must belong to exactly one subsequence. If there is no way to divide day history into zebra subsequences, print -1. Subsequences may be printed in any order. If there are several solutions, you may print any of them. You do not have to minimize nor maximize the value of k.

package main
import (
	"fmt"
	"bufio"
	"os"
	)
func main() {
    in := bufio.NewReader(os.Stdin)
    out := bufio.NewWriter(os.Stdout)
    defer out.Flush()
    days := ""
    fmt.Fscanf(in, "%s\n", &days)
    n := len(days)
    seq := make([][]int, 0, 100000)
    zs := make([]int, 0, 100000)
    os := make([]int, 0, 100000)
    for i := 0; i < n; i++ {
        if days[i] == '0' {
            if len(os) == 0 {
                newseq := []int{i}
                seq = append(seq, newseq)
                zs = append(zs, len(seq) - 1)
            }else {
                seq[os[0]] = append(seq[os[0]], i)
                zs = append(zs, os[0])
                os[0] = os[len(os)-1]
                os = os[:len(os)-1]
            }
        }else {
            if len(zs) == 0 {
                fmt.Fprintf(out, "-1\n")
                return
            }else {
                seq[zs[0]] = append(seq[zs[0]], i)
                os = append(os, zs[0])
                zs[0] = zs[len(zs) -1]
                zs = zs[:len(zs)-1]
            }
        }
    }
    if len(os) != 0 {
        fmt.Fprintf(out, "-1\n")
        return
    }
    fmt.Fprintf(out, "%d\n", len(seq))
    for i := 0; i < len(seq); i++ {
        fmt.Fprintf(out, "%d", len(seq[i]))
        for j := 0; j < len(seq[i]); j++ {
            fmt.Fprintf(out, " %d" , seq[i][j]+1)
        }
        fmt.Fprintf(out, "\n")
    }
    return
}

package main
import (
	"fmt"
	"bufio"
	"os"
	)
func main() {
    in := bufio.NewReader(os.Stdin)
    out := bufio.NewWriter(os.Stdout)

    days := ""
    fmt.Fscanf(in, "%s\n", &days)
    n := len(days)
    seq := make([][]int, 0, 100000)
    zs := make([]int, 0, 100000)
    os := make([]int, 0, 100000)
    for i := 0; i < n; i++ {
        if days[i] == '0' {
            if len(os) == 0 {
                newseq := []int{i}
                seq = append(seq, newseq)
                zs = append(zs, len(seq) - 1)
            }else {
                seq[os[0]] = append(seq[os[0]], i)
                zs = append(zs, os[0])
                os[0] = os[len(os)-1]
                os = os[:len(os)-1]
            }
        }else {
            if len(zs) == 0 {
                fmt.Fprintf(out, "-1\n")
                return
            }else {
                seq[zs[0]] = append(seq[zs[0]], i)
                os = append(os, zs[0])
                zs[0] = zs[len(zs) -1]
                zs = zs[:len(zs)-1]
            }
        }
    }
    if len(os) != 0 {
        fmt.Fprintf(out, "-1\n")
        return
    }
    fmt.Fprintf(out, "%d\n", len(seq))
    for i := 0; i < len(seq); i++ {
        fmt.Fprintf(out, "%d", len(seq[i]))
        for j := 0; j < len(seq[i]); j++ {
            fmt.Fprintf(out, " %d" , seq[i][j]+1)
        }
        fmt.Fprintf(out, "\n")
    }
    return
}