Several days ago you bought a new house and now you are planning to start a renovation. Since winters in your region can be very cold you need to decide how to heat rooms in your house.Your house has $$$n$$$ rooms. In the $$$i$$$-th room you can install at most $$$c_i$$$ heating radiators. Each radiator can have several sections, but the cost of the radiator with $$$k$$$ sections is equal to $$$k^2$$$ burles.Since rooms can have different sizes, you calculated that you need at least $$$sum_i$$$ sections in total in the $$$i$$$-th room. For each room calculate the minimum cost to install at most $$$c_i$$$ radiators with total number of sections not less than $$$sum_i$$$.

The first line contains single integer $$$n$$$ ($$$1 \le n \le 1000$$$) — the number of rooms. Each of the next $$$n$$$ lines contains the description of some room. The $$$i$$$-th line contains two integers $$$c_i$$$ and $$$sum_i$$$ ($$$1 \le c_i, sum_i \le 10^4$$$) — the maximum number of radiators and the minimum total number of sections in the $$$i$$$-th room, respectively.

For each room print one integer — the minimum possible cost to install at most $$$c_i$$$ radiators with total number of sections not less than $$$sum_i$$$.

NoteIn the first room, you can install only one radiator, so it's optimal to use the radiator with $$$sum_1$$$ sections. The cost of the radiator is equal to $$$(10^4)^2 = 10^8$$$.In the second room, you can install up to $$$10^4$$$ radiators, but since you need only one section in total, it's optimal to buy one radiator with one section.In the third room, there $$$7$$$ variants to install radiators: $$$[6, 0]$$$, $$$[5, 1]$$$, $$$[4, 2]$$$, $$$[3, 3]$$$, $$$[2, 4]$$$, $$$[1, 5]$$$, $$$[0, 6]$$$. The optimal variant is $$$[3, 3]$$$ and it costs $$$3^2+ 3^2 = 18$$$.

package main

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

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

	defer out.Flush()
	var n,c,summ int

	fmt.Fscanf(in,"%d\n",&n)

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

		fmt.Fscanf(in,"%d %d\n",&c,&summ)
		if c > summ {
			 c = summ
		}
		quo := summ / c

		remm := summ % c

		yy := c - remm

		output := remm*(quo + 1)*(quo + 1) + yy*quo*quo

		fmt.Fprintf(out,"%d\n",output)

	}

}

package main

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

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

var (
	// ReadString returns a WORD string.
	ReadString func() string
)

func init() {
	ReadString = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

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

func main() {
	n := ReadInt()

	for n > 0 {
		a, b := ReadFloat64(), ReadFloat64()
		fmt.Println(int64(solve(a, b)))
		n--
	}
}

func solve(a, b float64) float64 {
	if a >= b {
		return b
	}

	var ans float64

	for a > 0 && b > 0 {
		r := math.Round(b / a)
		b -= r
		a--
		ans += r * r
	}

	return ans
}

package main

import "fmt"

func main() {
	var n int
	var a, b int
	fmt.Scanln(&n)
	for i := 0; i < n; i++ {
		fmt.Scanln(&a, &b)
		if a >= b {
			fmt.Println(b)
		} else {
			perRad := b / a
			bigRad := b % a
			fmt.Println((a-bigRad)*perRad*perRad + bigRad*(perRad+1)*(perRad+1))
		}
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		if a >= b {
			fmt.Println(b)
		} else {
			perRad := b / a
			bigRad := b % a
			fmt.Println((a-bigRad)*perRad*perRad + bigRad*(perRad+1)*(perRad+1))
		}
	}
}

package main

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

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

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

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	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
}

/*********** DP sub-functions ***********/

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

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

/********** 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 MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var n int
var C, S []int64

func main() {
	n = ReadInt()
	C, S = make([]int64, n), make([]int64, n)
	for i := 0; i < n; i++ {
		c, s := ReadInt64_2()
		C[i], S[i] = c, s
	}

	for i := 0; i < n; i++ {
		c, sum := C[i], S[i]

		if c >= sum {
			fmt.Println(sum)
			continue
		}

		x := sum / c
		m := sum % c
		ans := x*x*(c-m) + (x+1)*(x+1)*m
		fmt.Println(ans)
	}
}

/*
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
*/

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

package main

import "fmt"

func main() {
	var n, c, sum int
	fmt.Scan(&n)

	for ; n > 0; n-- {
		fmt.Scan(&c, &sum)

		eachOneMin := int(sum / c)
		eachOneMax := sum - eachOneMin*c

		fmt.Println(eachOneMax*(eachOneMin+1)*(eachOneMin+1) + eachOneMin*eachOneMin*(c-eachOneMax))
	}
}

package main

import (
	"fmt"
	"os"
)

func sqr(x int) int {
	return x * x
}

func main() {
	var n int
	fmt.Fscanln(os.Stdin, &n)
	for i := 0; i < n; i++ {
		var a, b int
		fmt.Fscanln(os.Stdin, &a, &b)
		if a >= b {
			fmt.Println(b)
		} else {
			ans := 0
			for j := 0; j < a; j++ {
				if j < b%a {
					ans += sqr(b/a + 1)
				} else {
					ans += sqr(b / a)
				}
			}
			fmt.Println(ans)
		}
	}
}

package main

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

func solve(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var t int
	Fscan(in, &t)
	for case_ := 0; case_ < t; case_++ {
		solveCase(in, out)
	}
}

func solveCase(in io.Reader, out io.Writer) {
	var c,sum int64
	Fscan(in, &c,&sum)
	avg := sum/c
	if c>=sum {
		Fprintln(out, sum)
	} else {
		big := sum-c*avg
		small := c-big
		ans := big*(avg+1)*(avg+1)+small*avg*avg
		Fprintln(out, ans)
	}
}

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func ifElseI(cond bool, a, b int) int {
	if cond {
		return a
	}
	return b
}
func ifElseS(cond bool, a, b string) string {
	if cond {
		return a
	}
	return b
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(0)
	fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		x, y := int64(0), int64(0)
		fmt.Fscanf(in, "%d %d\n", &x, &y)
		a := make([]int64, x)
		sum := int64(0)
		for i := int64(0); i < x; i++ {
			a[i] = y / x
			if i < y%x {
				a[i]++
			}
			sum += a[i] * a[i]
		}
		fmt.Fprintf(out, "%d\n", sum)
	}
	return
}

package main

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

var reader *bufio.Reader=bufio.NewReader(os.Stdin)
var writer *bufio.Writer=bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}){fmt.Fprintf(writer,f,a...)}
func scanf(f string,a...interface{}){fmt.Fscanf(reader,f,a...)}

func main(){
	defer writer.Flush()
	var n int
	scanf("%d\n",&n)
	for i:=0;i<n;i++{
		var c,sum int
		scanf("%d %d\n",&c,&sum)
		k:=sum/c
		e:=sum%c
		printf("%d\n",k*k*(c-e)+(k+1)*(k+1)*e)
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var c, sum int
		fmt.Scan(&c, &sum)

		if c >= sum {
			fmt.Println(sum)
		} else {
			ans := 0
			sections := sum / c
			extra := sum - sections*c
			for j := 0; j < c; j++ {
				if extra > 0 {
					ans += (sections + 1) * (sections + 1)
					extra--
				} else {
					ans += (sections) * (sections)
				}
			}

			fmt.Println(ans)
		}
	}
}

package main

import "fmt"

func main() {
	var T int
	fmt.Scan(&T)
	for T != 0 {
		T--
		var c, sum int
		fmt.Scan(&c, &sum)
		d, r := sum/c, sum%c
		fmt.Println(r*(d+1)*(d+1) + (c-r)*d*d)
	}
}

package main

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

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

var (
	// ReadString returns a WORD string.
	ReadString func() string
)

func init() {
	ReadString = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

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

func main() {
	n := ReadInt()

	for n > 0 {
		a, b := ReadFloat64(), ReadFloat64()
		fmt.Println(solve(a, b))
		n--
	}
}

func solve(a, b float64) float64 {
	if a >= b {
		return b
	}

	var ans float64

	for a > 0 && b > 0 {
		r := math.Round(b / a)
		b -= r
		a--
		ans += r * r
	}

	return ans
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanln(&n)
	for i := 0; i < n; i++ {
		var a, b int
		fmt.Scanf("%d %d", &a, &b)
		if a >= b {
			fmt.Println(b)
		} else {
			perRad := b / a
			bigRad := b % a
			fmt.Println((a-bigRad)*perRad*perRad + bigRad*(perRad+1)*(perRad+1))
		}
	}
}

package main

import "fmt"

func main() {
	var n, c, sum, ans int64
	fmt.Scan(&n)

	for ; n > 0; n-- {
		fmt.Scan(&c, &sum)

		aux := int64(sum / c)

		aux2 := sum - (aux * c)

		ans = (aux+1)*aux2*aux2 + (c-aux2)*aux*aux

		fmt.Println(ans)
	}
}

package main

import "fmt"

func main() {
	var n, c, sum, ans int
	fmt.Scan(&n)

	for ; n > 0; n-- {
		fmt.Scan(&c, &sum)

		aux := int(sum / c)

		aux2 := sum - (aux * c)

		ans = (aux+1)*aux2*aux2 + (c-aux2)*aux*aux

		fmt.Println(ans)
	}
}

package main

import "fmt"

func main() {
	var T int
	fmt.Scan(&T)
	for T != 0 {
		T--
		var c, sum int
		fmt.Scan(&c, &sum)
		d, r := sum/c, sum%c
		println(r*(d+1)*(d+1) + (c-r)*d*d)
	}
}


The only difference between the two versions is that this version asks the minimal possible answer.Homer likes arrays a lot. Today he is painting an array $$$a_1, a_2, \dots, a_n$$$ with two kinds of colors, white and black. A painting assignment for $$$a_1, a_2, \dots, a_n$$$ is described by an array $$$b_1, b_2, \dots, b_n$$$ that $$$b_i$$$ indicates the color of $$$a_i$$$ ($$$0$$$ for white and $$$1$$$ for black).According to a painting assignment $$$b_1, b_2, \dots, b_n$$$, the array $$$a$$$ is split into two new arrays $$$a^{(0)}$$$ and $$$a^{(1)}$$$, where $$$a^{(0)}$$$ is the sub-sequence of all white elements in $$$a$$$ and $$$a^{(1)}$$$ is the sub-sequence of all black elements in $$$a$$$. For example, if $$$a = [1,2,3,4,5,6]$$$ and $$$b = [0,1,0,1,0,0]$$$, then $$$a^{(0)} = [1,3,5,6]$$$ and $$$a^{(1)} = [2,4]$$$.The number of segments in an array $$$c_1, c_2, \dots, c_k$$$, denoted $$$\mathit{seg}(c)$$$, is the number of elements if we merge all adjacent elements with the same value in $$$c$$$. For example, the number of segments in $$$[1,1,2,2,3,3,3,2]$$$ is $$$4$$$, because the array will become $$$[1,2,3,2]$$$ after merging adjacent elements with the same value. Especially, the number of segments in an empty array is $$$0$$$.Homer wants to find a painting assignment $$$b$$$, according to which the number of segments in both $$$a^{(0)}$$$ and $$$a^{(1)}$$$, i.e. $$$\mathit{seg}(a^{(0)})+\mathit{seg}(a^{(1)})$$$, is as small as possible. Find this number.

The first line contains an integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq n$$$).

Output a single integer, indicating the minimal possible total number of segments.

package main

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

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

	n := readNum(reader)

	A := readNNums(reader, n)

	res := solve(n, A)

	fmt.Printf("%d\n", res)
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, a []int) int {
	A := make([]int, n+1)
	copy(A[1:], a)
	var m int

	for i := 1; i <= n; i++ {
		if i == 1 || A[i] != A[i-1] {
			m++
			A[m] = A[i]
		}
	}
	res := m
	last := make([]int, n+1)

	for i := 1; i <= n; i++ {
		last[i] = -1
	}
	f := make([]int, m+1)
	f[1] = 1
	last[A[1]] = 1
	g := func(j, i int) int {
		if j == 0 {
			return 1 << 30
		}
		ret := f[j] + i - j - 1
		if A[j-1] != A[i] {
			ret++
		}
		return ret
	}

	for i := 2; i <= m; i++ {
		cand := last[A[i]] + 1
		f[i] = min(g(i-1, i), g(cand, i))

		res = min(res, f[i]+m-i)

		last[A[i]] = i
	}
	return res
}

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

func solve1(n int, a []int) int {
	A := make([]int, n+1)
	copy(A[1:], a)
	pos := make([]int, n+1)
	for i := 0; i <= n; i++ {
		pos[i] = n + 1
	}

	next := make([]int, n+1)

	for i := n; i >= 0; i-- {
		next[i] = pos[A[i]]
		pos[A[i]] = i
	}

	var x, y int
	var res int
	for i := 1; i <= n; i++ {
		if A[x] == A[i] {
			x = i
		} else if A[y] == A[i] {
			y = i
		} else if next[x] > next[y] {
			res++
			x = i
		} else {
			res++
			y = i
		}
	}
	return res
}

package main

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

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

	n := readNum(reader)

	A := readNNums(reader, n)

	res := solve(n, A)

	fmt.Printf("%d\n", res)
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, a []int) int {
	A := make([]int, n+1)
	copy(A[1:], a)
	pos := make([]int, n+1)
	for i := 0; i <= n; i++ {
		pos[i] = n + 1
	}

	next := make([]int, n+1)

	for i := n; i >= 0; i-- {
		next[i] = pos[A[i]]
		pos[A[i]] = i
	}

	var x, y int
	var res int
	for i := 1; i <= n; i++ {
		if A[x] == A[i] {
			x = i
		} else if A[y] == A[i] {
			y = i
		} else if next[x] > next[y] {
			res++
			x = i
		} else {
			res++
			y = i
		}
	}
	return res
}

package main

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

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

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

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

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

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

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

	var a = make([]int, n)
	for i := range a {
		scan(&a[i])
	}

	var posof = make(map[int][]int, n)
	for i := len(a) - 1; i >= 0; i-- {
		posof[a[i]] = append(posof[a[i]], i)
	}

	var (
		ans  int
		x, y = -1, -1
	)
	for _, e := range a {
		posof[e] = posof[e][:len(posof[e])-1]
		if e == x || e == y {
			continue
		}
		ans++

		px, py := n, n+1
		if x != -1 && len(posof[x]) > 0 {
			px = posof[x][len(posof[x])-1]
		}
		if y != -1 && len(posof[y]) > 0 {
			py = posof[y][len(posof[y])-1]
		}
		if x == -1 || px > py {
			x = e
		} else if y == -1 || py > px {
			y = e
		} else {
			panic("")
		}
	}
	printf("%v\n", ans)
}


Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Similarly, by swiping right from the last photo you reach photo 1. It takes a seconds to swipe from photo to adjacent.For each photo it is known which orientation is intended for it — horizontal or vertical. Phone is in the vertical orientation and can't be rotated. It takes b second to change orientation of the photo.Vasya has T seconds to watch photos. He want to watch as many photos as possible. If Vasya opens the photo for the first time, he spends 1 second to notice all details in it. If photo is in the wrong orientation, he spends b seconds on rotating it before watching it. If Vasya has already opened the photo, he just skips it (so he doesn't spend any time for watching it or for changing its orientation). It is not allowed to skip unseen photos.Help Vasya find the maximum number of photos he is able to watch during T seconds.

The first line of the input contains 4 integers n, a, b, T (1 ≤ n ≤ 5·105, 1 ≤ a, b ≤ 1000, 1 ≤ T ≤ 109) — the number of photos, time to move from a photo to adjacent, time to change orientation of a photo and time Vasya can spend for watching photo. Second line of the input contains a string of length n containing symbols 'w' and 'h'.  If the i-th position of a string contains 'w', then the photo i should be seen in the horizontal orientation. If the i-th position of a string contains 'h', then the photo i should be seen in vertical orientation.

Output the only integer, the maximum number of photos Vasya is able to watch during those T seconds.

NoteIn the first sample test you can rotate the first photo (3 seconds), watch the first photo (1 seconds), move left (2 second), rotate fourth photo (3 seconds), watch fourth photo (1 second). The whole process takes exactly 10 seconds.Note that in the last sample test the time is not enough even to watch the first photo, also you can't skip it.

package main

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

func dist(i, j int) int {
	kd := j
	if i > 1 {
		kd += j + i - 1
	}

	dk := i - 1
	if j > 0 {
		dk += j + i - 1
	}

	if kd < dk {
		return kd
	}
	return dk
}

func main() {
	var n, a, b, t int
	var s string
	fmt.Scan(&n, &a, &b, &t)
	reader := bufio.NewReader(os.Stdin)
comefrom:
	s, err := reader.ReadString('\n')
	if err != nil && err != io.EOF {
		panic(err)
	}
	s = strings.TrimSpace(s)
	if len(s) == 0 {
		goto comefrom
	}
	pre := make([]int, n+1)
	suf := make([]int, n+1)
	mp := 0
	for i := 0; i < n; i++ {
		pre[i+1] = pre[i] + 1
		if s[i] == 'w' {
			pre[i+1] += b
		}
		if pre[i+1]+a*i <= t {
			mp = i + 1
		}

		suf[i+1] = suf[i] + 1
		if s[n-1-i] == 'w' {
			suf[i+1] += b
		}
	}

	res := 0
	j := 0
	for i := mp; i > 0; i-- {
		for pre[i]+suf[j]+a*dist(i, j) <= t && j <= n-i {
			j++
		}
		j--
		if j+i > res {
			res = j + i
		}
	}
	fmt.Println(res)
}


This is an interactive problem. In the output section below you will see the information about flushing the output.On Sunday Leha the hacker took Nura from the house where she lives and went with her to one of the most luxurious restaurants in Vičkopolis. Upon arrival, they left the car in a huge parking lot near the restaurant and hurried inside the building.In the restaurant a polite waiter immediately brought the menu to Leha and Noora, consisting of n dishes. It is interesting that all dishes in the menu are numbered with integers from 1 to n. After a little thought, the girl ordered exactly k different dishes from available in the menu. To pass the waiting time while the chefs prepare ordered dishes, the girl invited the hacker to play a game that will help them get to know each other better.The game itself is very simple: Noora wants Leha to guess any two dishes among all ordered. At the same time, she is ready to answer only one type of questions. Leha can say two numbers x and y (1 ≤ x, y ≤ n). After that Noora chooses some dish a for the number x such that, at first, a is among the dishes Noora ordered (x can be equal to a), and, secondly, the value  is the minimum possible. By the same rules the girl chooses dish b for y. After that Noora says «TAK» to Leha, if , and «NIE» otherwise. However, the restaurant is preparing quickly, so Leha has enough time to ask no more than 60 questions. After that he should name numbers of any two dishes Noora ordered.Help Leha to solve this problem!

There are two numbers n and k (2 ≤ k ≤ n ≤ 105) in the single line of input denoting the number of dishes in the menu and the number of dishes Noora ordered.

If you want to provide an answer, output a string of the form 2 x y (1 ≤ x, y ≤ n, x ≠ y), if you think the dishes x and y was among dishes ordered by Noora. After that, flush the output and terminate your program.

NoteThere are three dishes in sample. Noora ordered dished numberes 2 and 3, which Leha should guess. If Noora receive requests for the first dish (x = 1), then she'll choose the second dish (a = 2) as the dish with the minimum value . For the second (x = 2) and the third (x = 3) dishes themselves will be optimal, because in that case . Let Leha asks Noora about the next couple of dishes:  x = 1, y = 2, then he'll recieve «NIE» answer, because |1 - 2| > |2 - 2|  x = 2, y = 1, then he'll recieve «TAK» answer, because |2 - 2| ≤ |1 - 2|  x = 1, y = 3, then he'll recieve «NIE» answer, because |1 - 2| > |3 - 3|  x = 3, y = 1, then he'll recieve «TAK» answer, because |3 - 3| ≤ |1 - 2|  x = 2, y = 3, then he'll recieve «TAK» answer, because |2 - 2| ≤ |3 - 3|  x = 3, y = 2, then he'll recieve «TAK» answer, because |3 - 3| ≤ |2 - 2| According to the available information, it is possible to say that Nura ordered dishes with numbers 2 and 3.

package main

import "fmt"

func tak(x, y int) bool {
	fmt.Println(1, x, y)
	var ans string
	fmt.Scan(&ans)
	return ans == "TAK"
}

func search(lo, hi int) int {
	for hi-lo >= 3 {
		x := lo + (hi-lo)/3
		y := hi - (hi-lo)/3
		if tak(x, y) {
			hi = y - 1
		} else {
			lo = x + 1
		}
	}
	switch hi - lo {
	case 2:
		a := tak(lo, lo+1)
		b := tak(lo, lo+2)
		switch {
		case a && b:
			return lo
		case a && !b:
			return lo + 2
		case !a && b:
			return lo + 1
		default:
			return lo + 2
		}
	case 1:
		if tak(lo, lo+1) {
			return lo
		}
		return lo + 1
	}
	return lo
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := search(1, n)
	if a-1 < n-a {
		mi := a - 1
		if tak(a+mi, a-mi) {
			fmt.Println(2, a, search(a+1, n))
		} else {
			fmt.Println(2, a, search(1, a-1))
		}
	} else {
		mi := n - a
		if tak(a-mi, a+mi) {
			fmt.Println(2, a, search(1, a-1))
		} else {
			fmt.Println(2, a, search(a+1, n))
		}
	}

}

package main

import "fmt"

func tak(x, y int) bool {
	fmt.Println(1, x, y)
	var ans string
	fmt.Scan(&ans)
	return ans == "TAK"
}

func search(lo, hi int) int {
	for hi-lo >= 3 {
		x := lo + (hi-lo)/3
		y := x + (hi-lo)/3
		if tak(x, y) {
			hi = y - 1
		} else {
			lo = x + 1
		}
	}
	switch hi - lo {
	case 2:
		a := tak(lo, lo+1)
		b := tak(lo, lo+2)
		switch {
		case a && b:
			return lo
		case a && !b:
			return lo + 2
		case !a && b:
			return lo + 1
		default:
			return lo + 2
		}
	case 1:
		if tak(lo, lo+1) {
			return lo
		}
		return lo + 1
	}
	return lo
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := search(1, n)
	if a-1 < n-a {
		mi := a - 1
		if tak(a+mi, a-mi) {
			fmt.Println(2, a, search(a+1, n))
		} else {
			fmt.Println(2, a, search(1, a-1))
		}
	} else {
		mi := n - a
		if tak(a-mi, a+mi) {
			fmt.Println(2, a, search(1, a-1))
		} else {
			fmt.Println(2, a, search(a+1, n))
		}
	}

}


Bearland has n cities, numbered 1 through n. Cities are connected via bidirectional roads. Each road connects two distinct cities. No two roads connect the same pair of cities.Bear Limak was once in a city a and he wanted to go to a city b. There was no direct connection so he decided to take a long walk, visiting each city exactly once. Formally:   There is no road between a and b.  There exists a sequence (path) of n distinct cities v1, v2, ..., vn that v1 = a, vn = b and there is a road between vi and vi + 1 for . On the other day, the similar thing happened. Limak wanted to travel between a city c and a city d. There is no road between them but there exists a sequence of n distinct cities u1, u2, ..., un that u1 = c, un = d and there is a road between ui and ui + 1 for .Also, Limak thinks that there are at most k roads in Bearland. He wonders whether he remembers everything correctly.Given n, k and four distinct cities a, b, c, d, can you find possible paths (v1, ..., vn) and (u1, ..., un) to satisfy all the given conditions? Find any solution or print -1 if it's impossible.

The first line of the input contains two integers n and k (4 ≤ n ≤ 1000, n - 1 ≤ k ≤ 2n - 2) — the number of cities and the maximum allowed number of roads, respectively. The second line contains four distinct integers a, b, c and d (1 ≤ a, b, c, d ≤ n).

Print -1 if it's impossible to satisfy all the given conditions. Otherwise, print two lines with paths descriptions. The first of these two lines should contain n distinct integers v1, v2, ..., vn where v1 = a and vn = b. The second line should contain n distinct integers u1, u2, ..., un where u1 = c and un = d. Two paths generate at most 2n - 2 roads: (v1, v2), (v2, v3), ..., (vn - 1, vn), (u1, u2), (u2, u3), ..., (un - 1, un). Your answer will be considered wrong if contains more than k distinct roads or any other condition breaks. Note that (x, y) and (y, x) are the same road.

NoteIn the first sample test, there should be 7 cities and at most 11 roads. The provided sample solution generates 10 roads, as in the drawing. You can also see a simple path of length n between 2 and 4, and a path between 7 and 3.

package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextLong() int64 {
	i, err := strconv.ParseInt(io.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextDouble() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

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

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	io := NewIo()
	defer io.Flush()
	N := io.NextInt()
	K := io.NextInt()
	A := make([]int, 4)
	for i := 0; i < 4; i++ {
		A[i] = io.NextInt()
	}
	if N == 4 || K < N - 1 + 2 {
		io.PrintLn(-1)
	} else {
		used := make([]bool, N + 1)
		for i := 0; i < 4; i++ {
			used[A[i]] = true
		}
		B := []int{}
		for i := 1; i <= N; i++ {
			if !used[i] {
				B = append(B, i)
			}
		}
		X := []int{}
		X = append(X, A[0])
		X = append(X, A[2])
		for i := 0; i < len(B); i++ {
			X = append(X, B[i])
		}
		X = append(X, A[3])
		X = append(X, A[1])

		Y := []int{}
		Y = append(Y, A[2])
		Y = append(Y, A[0])
		for i := 0; i < len(B); i++ {
			Y = append(Y, B[i])
		}
		Y = append(Y, A[1])
		Y = append(Y, A[3])
		io.PrintIntLn(X)
		io.PrintIntLn(Y)
	}
}

package main

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

func main() {
	defer out.Flush()
	n := in.NextInt()
	k := in.NextInt()
	a := in.NextInt()
	b := in.NextInt()
	c := in.NextInt()
	d := in.NextInt()
	if n == 4 {
		fmt.Fprintln(out, -1)
		return
	}
	if k < n+1 {
		fmt.Fprintln(out, -1)
		return
	}
	x := make([]int, n)
	x[0] = a
	x[1] = c
	x[n-2] = d
	x[n-1] = b
	for i, j := 2, 0; i < n-2; i++ {
		for {
			j++
			if j != a && j != b && j != c && j != d {
				break
			}
		}
		x[i] = j
	}
	for i := 0; i < n; i++ {
		if i != 0 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, x[i])
	}
	fmt.Fprintln(out)
	x[0], x[1] = x[1], x[0]
	x[n-1], x[n-2] = x[n-2], x[n-1]
	for i := 0; i < n; i++ {
		if i != 0 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, x[i])
	}
	fmt.Fprintln(out)
}

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

type FastReader struct {
	r   *bufio.Reader
	buf string
}

func NewFastReader(r io.Reader) *FastReader {
	return &FastReader{
		r: bufio.NewReader(r),
	}
}

func (r *FastReader) advance() {
	for len(r.buf) != 0 && r.buf[0] == ' ' {
		r.buf = r.buf[1:]
	}
	var err error
	for len(r.buf) == 0 && err != io.EOF {
		buf := new(bytes.Buffer)
		for {
			var chunk []byte
			var more bool
			chunk, more, err = r.r.ReadLine()
			buf.Write(chunk)
			if !more {
				break
			}
		}
		r.buf = buf.String()
	}
}

func (r *FastReader) NextLine() string {
	r.advance()
	line := r.buf
	r.buf = ""
	return line
}

func (r *FastReader) NextWord() string {
	r.advance()
	var word string
	wordStart := 0
	for i := 0; i < len(r.buf); i++ {
		b := r.buf[i]
		if b == ' ' {
			if i != wordStart {
				word = r.buf[wordStart:i]
				r.buf = r.buf[i:]
				break
			}
			wordStart = i + 1
		}
	}
	if len(word) == 0 {
		word = r.buf
		r.buf = ""
	}
	return word
}

func (r *FastReader) NextInt() int {
	return parseInt(r.NextWord())
}

func parseInt(word string) int {
	sign := 1
	if word[0] == '-' {
		sign = -1
		word = word[1:]
	}
	result := 0
	for i := 0; i < len(word); i++ {
		result = result*10 + int(word[i]) - '0'
	}
	result *= sign
	return result
}

package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextLong() int64 {
	i, err := strconv.ParseInt(io.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextDouble() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

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

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	io := NewIo()
	defer io.Flush()
	N := io.NextInt()
	K := io.NextInt()
	A := make([]int, 4)
	for i := 0; i < 4; i++ {
		A[i] = io.NextInt()
	}
	if (N == 4 && K == 4) || K < N - 4 - 1 + 6 {
		io.PrintLn(-1)
	} else {
		used := make([]bool, N + 1)
		for i := 0; i < 4; i++ {
			used[A[i]] = true
		}
		B := []int{}
		for i := 1; i <= N; i++ {
			if !used[i] {
				B = append(B, i)
			}
		}
		X := []int{}
		X = append(X, A[0])
		X = append(X, A[2])
		for i := 0; i < len(B); i++ {
			X = append(X, B[i])
		}
		X = append(X, A[3])
		X = append(X, A[1])

		Y := []int{}
		Y = append(Y, A[2])
		Y = append(Y, A[0])
		for i := 0; i < len(B); i++ {
			Y = append(Y, B[i])
		}
		Y = append(Y, A[1])
		Y = append(Y, A[3])
		io.PrintIntLn(X)
		io.PrintIntLn(Y)
	}
}

package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextLong() int64 {
	i, err := strconv.ParseInt(io.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextDouble() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

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

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	io := NewIo()
	defer io.Flush()
	N := io.NextInt()
	K := io.NextInt()
	A := make([]int, 4)
	for i := 0; i < 4; i++ {
		A[i] = io.NextInt()
	}
	if K < N - 4 - 1 + 6 {
		io.PrintLn(-1)
	} else {
		used := make([]bool, N + 1)
		for i := 0; i < 4; i++ {
			used[A[i]] = true
		}
		B := []int{}
		for i := 1; i <= N; i++ {
			if !used[i] {
				B = append(B, i)
			}
		}
		X := []int{}
		X = append(X, A[0])
		X = append(X, A[2])
		for i := 0; i < len(B); i++ {
			X = append(X, B[i])
		}
		X = append(X, A[3])
		X = append(X, A[1])

		Y := []int{}
		Y = append(Y, A[2])
		Y = append(Y, A[0])
		for i := 0; i < len(B); i++ {
			Y = append(Y, B[i])
		}
		Y = append(Y, A[1])
		Y = append(Y, A[3])
		io.PrintIntLn(X)
		io.PrintIntLn(Y)
	}
}

package main

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

func main() {
	defer out.Flush()
	n := in.NextInt()
	k := in.NextInt()
	a := in.NextInt()
	b := in.NextInt()
	c := in.NextInt()
	d := in.NextInt()
	if n == 4 {
		if k < 4 {
			fmt.Fprintln(out, -1)
			return
		}
		fmt.Fprintln(out, a, c, d, b)
		fmt.Fprintln(out, c, a, b, d)
		return
	}
	if k < n+1 {
		fmt.Fprintln(out, -1)
		return
	}
	x := make([]int, n)
	x[0] = a
	x[1] = c
	x[n-2] = d
	x[n-1] = b
	for i, j := 2, 0; i < n-2; i++ {
		for {
			j++
			if j != a && j != b && j != c && j != d {
				break
			}
		}
		x[i] = j
	}
	for i := 0; i < n; i++ {
		if i != 0 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, x[i])
	}
	fmt.Fprintln(out)
	x[0], x[1] = x[1], x[0]
	x[n-1], x[n-2] = x[n-2], x[n-1]
	for i := 0; i < n; i++ {
		if i != 0 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, x[i])
	}
	fmt.Fprintln(out)
}

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

type FastReader struct {
	r   *bufio.Reader
	buf string
}

func NewFastReader(r io.Reader) *FastReader {
	return &FastReader{
		r: bufio.NewReader(r),
	}
}

func (r *FastReader) advance() {
	for len(r.buf) != 0 && r.buf[0] == ' ' {
		r.buf = r.buf[1:]
	}
	var err error
	for len(r.buf) == 0 && err != io.EOF {
		buf := new(bytes.Buffer)
		for {
			var chunk []byte
			var more bool
			chunk, more, err = r.r.ReadLine()
			buf.Write(chunk)
			if !more {
				break
			}
		}
		r.buf = buf.String()
	}
}

func (r *FastReader) NextLine() string {
	r.advance()
	line := r.buf
	r.buf = ""
	return line
}

func (r *FastReader) NextWord() string {
	r.advance()
	var word string
	wordStart := 0
	for i := 0; i < len(r.buf); i++ {
		b := r.buf[i]
		if b == ' ' {
			if i != wordStart {
				word = r.buf[wordStart:i]
				r.buf = r.buf[i:]
				break
			}
			wordStart = i + 1
		}
	}
	if len(word) == 0 {
		word = r.buf
		r.buf = ""
	}
	return word
}

func (r *FastReader) NextInt() int {
	return parseInt(r.NextWord())
}

func parseInt(word string) int {
	sign := 1
	if word[0] == '-' {
		sign = -1
		word = word[1:]
	}
	result := 0
	for i := 0; i < len(word); i++ {
		result = result*10 + int(word[i]) - '0'
	}
	result *= sign
	return result
}

package main

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

func main() {
	defer out.Flush()
	n := in.NextInt()
	k := in.NextInt()
	a := in.NextInt()
	b := in.NextInt()
	c := in.NextInt()
	d := in.NextInt()
	if k < n {
		fmt.Fprintln(out, -1)
		return
	}
	x := make([]int, n)
	x[0] = a
	x[1] = c
	x[2] = d
	x[n-1] = b
	for i, j := 3, 0; i < n-1; i++ {
		for {
			j++
			if j != a && j != b && j != c && j != d {
				break
			}
		}
		x[i] = j
	}
	for i := 0; i < n; i++ {
		if i != 0 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, x[i])
	}
	fmt.Fprintln(out)
	fmt.Fprint(out, c, " ", a, " ", b)
	for i := n - 2; i >= 3; i-- {
		fmt.Fprint(out, " ", x[i])
	}
	fmt.Fprint(out, " ", d)
	fmt.Fprintln(out)
}

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

type FastReader struct {
	r   *bufio.Reader
	buf string
}

func NewFastReader(r io.Reader) *FastReader {
	return &FastReader{
		r: bufio.NewReader(r),
	}
}

func (r *FastReader) advance() {
	for len(r.buf) != 0 && r.buf[0] == ' ' {
		r.buf = r.buf[1:]
	}
	var err error
	for len(r.buf) == 0 && err != io.EOF {
		buf := new(bytes.Buffer)
		for {
			var chunk []byte
			var more bool
			chunk, more, err = r.r.ReadLine()
			buf.Write(chunk)
			if !more {
				break
			}
		}
		r.buf = buf.String()
	}
}

func (r *FastReader) NextLine() string {
	r.advance()
	line := r.buf
	r.buf = ""
	return line
}

func (r *FastReader) NextWord() string {
	r.advance()
	var word string
	wordStart := 0
	for i := 0; i < len(r.buf); i++ {
		b := r.buf[i]
		if b == ' ' {
			if i != wordStart {
				word = r.buf[wordStart:i]
				r.buf = r.buf[i:]
				break
			}
			wordStart = i + 1
		}
	}
	if len(word) == 0 {
		word = r.buf
		r.buf = ""
	}
	return word
}

func (r *FastReader) NextInt() int {
	return parseInt(r.NextWord())
}

func parseInt(word string) int {
	sign := 1
	if word[0] == '-' {
		sign = -1
		word = word[1:]
	}
	result := 0
	for i := 0; i < len(word); i++ {
		result = result*10 + int(word[i]) - '0'
	}
	result *= sign
	return result
}


There are $$$n$$$ points on an infinite plane. The $$$i$$$-th point has coordinates $$$(x_i, y_i)$$$ such that $$$x_i > 0$$$ and $$$y_i > 0$$$. The coordinates are not necessarily integer.In one move you perform the following operations:   choose two points $$$a$$$ and $$$b$$$ ($$$a \neq b$$$);  move point $$$a$$$ from $$$(x_a, y_a)$$$ to either $$$(x_a + 1, y_a)$$$ or $$$(x_a, y_a + 1)$$$;  move point $$$b$$$ from $$$(x_b, y_b)$$$ to either $$$(x_b + 1, y_b)$$$ or $$$(x_b, y_b + 1)$$$;  remove points $$$a$$$ and $$$b$$$. However, the move can only be performed if there exists a line that passes through the new coordinates of $$$a$$$, new coordinates of $$$b$$$ and $$$(0, 0)$$$. Otherwise, the move can't be performed and the points stay at their original coordinates $$$(x_a, y_a)$$$ and $$$(x_b, y_b)$$$, respectively.The numeration of points does not change after some points are removed. Once the points are removed, they can't be chosen in any later moves. Note that you have to move both points during the move, you can't leave them at their original coordinates.What is the maximum number of moves you can perform? What are these moves?If there are multiple answers, you can print any of them.

The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of points. The $$$i$$$-th of the next $$$n$$$ lines contains four integers $$$a_i, b_i, c_i, d_i$$$ ($$$1 \le a_i, b_i, c_i, d_i \le 10^9$$$). The coordinates of the $$$i$$$-th point are $$$x_i = \frac{a_i}{b_i}$$$ and $$$y_i = \frac{c_i}{d_i}$$$.

In the first line print a single integer $$$c$$$ — the maximum number of moves you can perform. Each of the next $$$c$$$ lines should contain a description of a move: two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le n$$$, $$$a \neq b$$$) — the points that are removed during the current move. There should be a way to move points $$$a$$$ and $$$b$$$ according to the statement so that there's a line that passes through the new coordinates of $$$a$$$, the new coordinates of $$$b$$$ and $$$(0, 0)$$$. No removed point can be chosen in a later move. If there are multiple answers, you can print any of them. You can print the moves and the points in the move in the arbitrary order.

NoteHere are the points and the moves for the ones that get chosen for the moves from the first example:

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	_i, buf := 1<<12, make([]byte, 1<<12)
	rc := func() byte {
		if _i == 1<<12 {
			os.Stdin.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}

	id := map[[2]int64]int{}
	genID := func(x, y int64) int {
		a, b := x, y
		for a > 0 {
			a, b = b%a, a
		}
		p := [2]int64{x / b, y / b}
		if _, ok := id[p]; !ok {
			id[p] = len(id)
		}
		return id[p]
	}
	n := r()
	type nb struct{ w, i int }
	g := make([][]nb, 2*n)
	for i := 1; i <= n; i++ {
		a,b,c,d := int64(r()), int64(r()), int64(r()), int64(r())
		v, w := genID(b*c, (a+b)*d), genID(b*(c+d), a*d)
		g[v] = append(g[v], nb{w, i})
		g[w] = append(g[w], nb{v, i})
	}

	ans := make([][]int, len(id))
	vis := make([]int8, len(id))
	var f func(int, int)
	f = func(v, p int) {
		vis[v] = 1
		for _, e := range g[v] {
			w, i := e.w, e.i
			if i == p || vis[w] == 2 {
				continue
			}
			if vis[w] == 1 {
				ans[v] = append(ans[v], i)
			} else {
				f(w, i)
				if len(ans[w])&1 > 0 {
					ans[w] = append(ans[w], i)
				} else {
					ans[v] = append(ans[v], i)
				}
			}
		}
		vis[v] = 2
	}
	for i, b := range vis {
		if b == 0 {
			f(i, 0)
		}
	}

	s:=0
	for _, ids := range ans {
		s += len(ids) / 2
	}
	Fprintln(out, s)
	for _, ids := range ans {
		for i := 1; i < len(ids); i += 2 {
			Fprintln(out, ids[i-1], ids[i])
		}
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	_i, buf := 1<<12, make([]byte, 1<<12)
	rc := func() byte {
		if _i == 1<<12 {
			os.Stdin.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}

	id := map[[2]int64]int{}
	e := func(x, y int64) int {
		a, b := x, y
		for a > 0 {
			a, b = b%a, a
		}
		p := [2]int64{x / b, y / b}
		if _, ok := id[p]; !ok {
			id[p] = len(id)
		}
		return id[p]
	}
	n := r()
	type nb struct{ w, i int }
	g := make([][]nb, 2*n)
	for i := 1; i <= n; i++ {
		a,b,c,d := int64(r()), int64(r()), int64(r()), int64(r())
		v, w := e(b*c, (a+b)*d), e(b*(c+d), a*d)
		g[v] = append(g[v], nb{w, i})
		g[w] = append(g[w], nb{v, i})
	}

	ds := make([][]int, len(id))
	vis := make([]int, len(id))
	var f func(int, int)
	f = func(v, p int) {
		vis[v] = 1
		for _, e := range g[v] {
			w, i := e.w, e.i
			if i == p || vis[w] == 2 {
				continue
			}
			if vis[w] > 0 {
				ds[v] = append(ds[v], i)
			} else {
				f(w, i)
				if len(ds[w])&1 > 0 {
					ds[w] = append(ds[w], i)
				} else {
					ds[v] = append(ds[v], i)
				}
			}
		}
		vis[v] = 2
	}
	for i, b := range vis {
		if b == 0 {
			f(i, 0)
		}
	}

	s:=0
	for _, d := range ds {
		s += len(d) / 2
	}
	Fprintln(out, s)
	for _, d := range ds {
		for i := 0; i+1 < len(d); i += 2 {
			Fprintln(out, d[i], d[i+1])
		}
	}
}

package main
import("bufio";."fmt";"os")

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	id := map[[2]int64]int{}
	e := func(x, y int64) int {
		a, b := x, y
		for a > 0 {
			a, b = b%a, a
		}
		p := [2]int64{x/b, y/b}
		if _, ok := id[p]; !ok {
			id[p] = len(id)
		}
		return id[p]
	}
	var n, s int
	var a, b, c, d int64
	Fscan(in, &n)
	type nb struct{ w, i int }
	g := make([][]nb, 2*n)
	for i := 1; i <= n; i++ {
		Fscan(in, &a, &b, &c, &d)
		v, w := e(b*c, (a+b)*d), e(b*(c+d), a*d)
		g[v] = append(g[v], nb{w, i})
		g[w] = append(g[w], nb{v, i})
	}

	ds := make([][]int, len(id))
	vis := make([]int, len(id))
	var f func(int, int)
	f = func(v, p int) {
		vis[v] = 1
		for _, e := range g[v] {
			w,i:= e.w,e.i
			if i == p || vis[w] == 2 {
				continue
			}
			if vis[w] > 0 {
				ds[v] = append(ds[v], i)
			} else {
				f(w, i)
				if len(ds[w])&1 > 0 {
					ds[w] = append(ds[w], i)
				} else {
					ds[v] = append(ds[v], i)
				}
			}
		}
		vis[v] = 2
	}
	for i, b := range vis {
		if b == 0 {
			f(i, 0)
		}
	}

	for _, d := range ds {
		s += len(d) / 2
	}
	Fprintln(out, s)
	for _, d := range ds {
		for i := 0; i+1 < len(d); i += 2 {
			Fprintln(out, d[i], d[i+1])
		}
	}
}

package main

import (
	"bufio"
	"container/heap"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
type pvi struct {
	d, v int
	i    int
}
type hpi []*pvi

func (h hpi) Len() int             { return len(h) }
func (h hpi) Less(i, j int) bool   { return h[i].d < h[j].d }
func (h hpi) Swap(i, j int)        { h[i], h[j] = h[j], h[i]; h[i].i = i; h[j].i = j }
func (h *hpi) Push(v interface{})  { *h = append(*h, v.(*pvi)) }
func (h *hpi) Pop() interface{}    { a := *h; v := a[len(a)-1]; *h = a[:len(a)-1]; return v }
func (h *hpi) push(d, id int) *pvi { p := &pvi{d, id, len(*h)}; heap.Push(h, p); return p }
func (h *hpi) pop() *pvi           { return heap.Pop(h).(*pvi) }
func (h *hpi) fix(i int)           { heap.Fix(h, i) }
func (h *hpi) remove(i int) *pvi   { return heap.Remove(h, i).(*pvi) }

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type edge struct{ v, w int }

	f := func(x, y int64) [2]int64 {
		g := gcd(x, y)
		return [2]int64{x / g, y / g}
	}
	var n int
	var a, b, c, d int64
	Fscan(in, &n)
	if n == 1 {
		Fprintln(out, 0)
		return
	}

	id := map[[2]int64]int{}
	es := make([]edge, 0, n)
	for i := 1; i <= n; i++ {
		Fscan(in, &a, &b, &c, &d)
		p := f(b*c, (a+b)*d)
		if _, ok := id[p]; !ok {
			id[p] = len(id)
		}
		q := f(b*(c+d), a*d)
		if _, ok := id[q]; !ok {
			id[q] = len(id)
		}
		es = append(es, edge{id[p], id[q]})
	}

	n = len(id)
	g := make([]map[int]int, n)
	for i := range g {
		g[i] = map[int]int{}
	}
	for i, e := range es {
		v, w := e.v, e.w
		g[v][i] = w
		g[w][i] = v
	}
	h := hpi{}
	pts := make([]*pvi, len(g))
	for i, vs := range g {
		if len(vs) > 1 {
			pts[i] = h.push(len(vs),i)
		}
	}

	ans := [][2]int{}

	for len(h) > 0  {
		if h[0].d < 2 {
			h.pop()
			continue
		}
		p := h[0]
		ids := [2]int{}
		c:=0
		for id, w := range g[p.v] {
			ids[c] = id
			delete(g[w], id)
			delete(g[p.v], id)
			if pts[w] != nil {
				pts[w].d--
				h.fix(pts[w].i)
			}

			c++
			if c == 2 {
				break
			}
		}
		if ids != [2]int{1,1} {
			ans = append(ans, ids)
		}
		h[0].d -= 2
		h.fix(pts[p.v].i)
	}

	Fprintln(out, len(ans))
	for _, p := range ans {
		Fprintln(out, p[0]+1, p[1]+1)
	}
}

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

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


Vlad likes to eat in cafes very much. During his life, he has visited cafes n times. Unfortunately, Vlad started to feel that his last visits are not any different from each other. To fix that Vlad had a small research.First of all, Vlad assigned individual indices to all cafes. Then, he wrote down indices of cafes he visited in a row, in order of visiting them. Now, Vlad wants to find such a cafe that his last visit to that cafe was before his last visits to every other cafe. In other words, he wants to find such a cafe that he hasn't been there for as long as possible. Help Vlad to find that cafe.

In first line there is one integer n (1 ≤ n ≤ 2·105) — number of cafes indices written by Vlad. In second line, n numbers a1, a2, ..., an (0 ≤ ai ≤ 2·105) are written — indices of cafes in order of being visited by Vlad. Vlad could visit some cafes more than once. Note that in numeration, some indices could be omitted.

Print one integer — index of the cafe that Vlad hasn't visited for as long as possible.

NoteIn first test, there are three cafes, and the last visits to cafes with indices 1 and 2 were after the last visit to cafe with index 3; so this cafe is the answer. In second test case, there are also three cafes, but with indices 1, 2 and 4. Cafes with indices 1 and 4 were visited after the last visit of cafe with index 2, so the answer is 2. Note that Vlad could omit some numbers while numerating the cafes.

package main;
import (
    "fmt"
    "os"
    "bufio"
)
var (
    n int
    a [222222]int
    m map[int]int
    res int
)

func main() {
	in := bufio.NewReader(os.Stdin)
	m = make(map[int]int)
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a[i])
	}

	for i := n-1; i >= 0; i-- {
		if m[a[i]] == 0 {
			m[a[i]] = 1
			res = a[i]
		}
	}

	fmt.Printf("%d", res)
}

package main

import "fmt"
import "os"
import "bufio"

var n int
var a [222222]int
var m map[int]bool
var res int

func main() {
	in := bufio.NewReader(os.Stdin)
	m = make(map[int]bool)

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

	for i := n-1; i >= 0; i-- {
		if m[a[i]] == false {
			m[a[i]] = true
			res = a[i]
		}
	}

	fmt.Printf("%d", res)
}

package main

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

func solve() {
	n := readInt()
	a := make([]int, n)
	keys := make(map[int]bool)
	for i := 0; i < n; i++ {
		a[i] = readInt()
	}
	ans := 0
	for i := n - 1; i >= 0; i-- {
		if _, ok := keys[a[i]]; !ok {
			ans = a[i]
			keys[ans] = true
		}
	}
	fmt.Println(ans)
}

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

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

var scanner *bufio.Scanner

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

// 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 readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

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

var n, ans int
var a [200005]int
var met [200005]bool

func main() {
	fmt.Scanf("%d", &n)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; scanner.Scan(); i++{
		a[i], _ = strconv.Atoi(scanner.Text())
		//fmt.Println(a[i])
	}
	for i := n-1; i >= 0; i--{
		if !met[a[i]]{
			ans = a[i]
		}
		met[a[i]] = true
	}
	fmt.Println(ans)
}

package main

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

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	pauses := map[int]int{}
	firstCantina := 0
	for i := 0; scanner.Scan(); i++ {
		cantina, _ := strconv.Atoi(scanner.Text())
		pauses[cantina] = n - i

		if i == 0 {
			firstCantina = cantina
		}
	}

	maxCantina := firstCantina
	maxPause := pauses[maxCantina]
	for c, p := range pauses {
		if p > maxPause {
			maxPause = p
			maxCantina = c
		}
	}

	fmt.Println(maxCantina)
}

package main;
import (
    "fmt"
)
var (
    n int
    a [222222]int
    m map[int]int
    res int
)

func main() {
	m = make(map[int]int)
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}

	for i := n-1; i >= 0; i-- {
		if m[a[i]] == 0 {
			m[a[i]] = 1
			res = a[i]
		}
	}

	fmt.Printf("%d", res)
}

package main

import(
	"fmt"
	//"os"
	//"strings"
)

var n, ans int
var a [200005]int
var met [200005]bool

func main() {
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++{
		fmt.Scanf("%d", &a[i])
	}
	for i := n-1; i >= 0; i--{
		if !met[a[i]]{
			ans = a[i]
		}
		met[a[i]] = true
	}
	fmt.Println(ans)
}

package main

import(
	"fmt"
	//"os"
	//"strings"
)

func main() {
	var n, ans int
	var a [200005]int
	var met [200005]bool
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++{
		fmt.Scanf("%d", &a[i])
	}
	for i := n-1; i >= 0; i--{
		if !met[a[i]]{
			ans = a[i]
		}
		met[a[i]] = true
	}
	fmt.Println(ans)
}


Bessie has way too many friends because she is everyone's favorite cow! Her new friend Rabbit is trying to hop over so they can play! More specifically, he wants to get from $$$(0,0)$$$ to $$$(x,0)$$$ by making multiple hops. He is only willing to hop from one point to another point on the 2D plane if the Euclidean distance between the endpoints of a hop is one of its $$$n$$$ favorite numbers: $$$a_1, a_2, \ldots, a_n$$$. What is the minimum number of hops Rabbit needs to get from $$$(0,0)$$$ to $$$(x,0)$$$? Rabbit may land on points with non-integer coordinates. It can be proved that Rabbit can always reach his destination.Recall that the Euclidean distance between points $$$(x_i, y_i)$$$ and $$$(x_j, y_j)$$$ is $$$\sqrt{(x_i-x_j)^2+(y_i-y_j)^2}$$$.For example, if Rabbit has favorite numbers $$$1$$$ and $$$3$$$ he could hop from $$$(0,0)$$$ to $$$(4,0)$$$ in two hops as shown below. Note that there also exists other valid ways to hop to $$$(4,0)$$$ in $$$2$$$ hops (e.g. $$$(0,0)$$$ $$$\rightarrow$$$ $$$(2,-\sqrt{5})$$$ $$$\rightarrow$$$ $$$(4,0)$$$).    Here is a graphic for the first example. Both hops have distance $$$3$$$, one of Rabbit's favorite numbers. In other words, each time Rabbit chooses some number $$$a_i$$$ and hops with distance equal to $$$a_i$$$ in any direction he wants. The same number can be used multiple times.

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$)  — the number of test cases. Next $$$2t$$$ lines contain test cases — two lines per test case. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \le n \le 10^5$$$, $$$1 \le x \le 10^9$$$)  — the number of favorite numbers and the distance Rabbit wants to travel, respectively. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^9$$$)  — Rabbit's favorite numbers. It is guaranteed that the favorite numbers are distinct. It is guaranteed that the sum of $$$n$$$ over all the test cases will not exceed $$$10^5$$$.

For each test case, print a single integer — the minimum number of hops needed.

NoteThe first test case of the sample is shown in the picture above. Rabbit can hop to $$$(2,\sqrt{5})$$$, then to $$$(4,0)$$$ for a total of two hops. Each hop has a distance of $$$3$$$, which is one of his favorite numbers.In the second test case of the sample, one way for Rabbit to hop $$$3$$$ times is: $$$(0,0)$$$ $$$\rightarrow$$$ $$$(4,0)$$$ $$$\rightarrow$$$ $$$(8,0)$$$ $$$\rightarrow$$$ $$$(12,0)$$$.In the third test case of the sample, Rabbit can hop from $$$(0,0)$$$ to $$$(5,0)$$$.In the fourth test case of the sample, Rabbit can hop: $$$(0,0)$$$ $$$\rightarrow$$$ $$$(5,10\sqrt{2})$$$ $$$\rightarrow$$$ $$$(10,0)$$$.

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	// inf, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(inf, 1000010)
	T := NextInt()
	// a := make([]int, 100010)
	for t := 0; t < T; t++ {
		n := NextInt()
		x := NextInt()
		var res, cur int
		for i := 0; i < n; i++ {
			r := NextInt()
			if r <= x {
				cur = (x - r) / r
				if (x-r)%r != 0 {
					cur++
				}
			} else {
				cur = (r - x) / r
				if (r-x)%r != 0 {
					cur++
				}
			}

			if i == 0 || cur+1 < res {
				res = cur + 1
			}
		}
		fmt.Fprintln(out, res)
	}
}

package main

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

func main() {
	scanner := bufio.NewReader(os.Stdin)
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		arrs := readLine(scanner)
		arr := strings.Split(string(arrs), " ")
		distance, _ := strconv.ParseUint(arr[1], 10, 64)
		arrs = readLine(scanner)
		arr = strings.Split(string(arrs), " ")
		bigest := uint64(0)
		flag := false
		for _, c := range arr {
			ai, _ := strconv.ParseUint(c, 10, 64)
			if ai > bigest {
				bigest = ai
			}
			if distance == ai {
				fmt.Println(1)
				flag = true
				break
			}
		}
		if flag {
			continue
		}
		result := uint64(0)
		if distance < bigest {
			result = 2
		} else if distance%bigest == 0 {
			result = distance / bigest
		} else {
			result = distance/bigest + 1
		}
		fmt.Println(result)
	}
}

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 {
			// fmt.Println(string(result))
			break
		}
	}
	return result
}

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

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
	n, x int
	A    []int
)

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

		solve()
	}
}

func solve() {
	ans := INF_BIT30
	for _, a := range A {
		if x%a == 0 {
			ChMin(&ans, x/a)
		} else {
			q := x / a
			if q > 0 {
				ChMin(&ans, q+1)
			} else {
				ChMin(&ans, 2)
			}
			// ChMin(&ans, x/a)
		}
	}
	fmt.Println(ans)
}

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

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

/*********** 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 "fmt"
import "os"
import "bufio"
import "strings"
import "strconv"
//~ import "sort"

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    capacity := 5000 * 1024
    scanner.Buffer(make([]byte, capacity), capacity)
    scanner.Scan()
    line := scanner.Text()
    t, _ := strconv.Atoi(line)
    for i := 0; i < t; i++ {
        scanner.Scan()
        line = scanner.Text()
        parts := strings.Split(line, " ")
        n, _ := strconv.Atoi(parts[0])
        x, _ := strconv.Atoi(parts[1])

        a := make([]int, n)
        scanner.Scan()
        line = scanner.Text()
        parts = strings.Split(line, " ")
        for j := 0; j < n; j++ {
            a[j], _ = strconv.Atoi(parts[j]);
        }
        fmt.Println(solve(a, x))
    }
}

func solve(a []int, x int) int {
    //~ fmt.Println(a, x)

    var max int
    for j := 0; j < len(a); j++ {
        if a[j] > max {
            max = a[j];
        }
    }

    if x < max {
        for _, v := range a {
            if v == x {
                return 1
            }
        }
        return 2
    } else {
        if x % max == 0 {
            return x / max
        } else {
            return (x / max) + 1
        }
    }
}

package main

import "bufio"
import "fmt"
import "os"

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 < T; t++ {
		var n, x int
		fmt.Fscanf(reader, "%d %d\n", &n, &x)

		ans := (1 << 30)
		for i := 0; i < n; i++ {
			var e int
			fmt.Fscanf(reader, "%d", &e)

			l := max(0, x-2*e)
			y := (l + e - 1) / e
			w := x - e*y

			req := y
			if w == e {
				req++
			} else {
				req += 2
			}

			ans = min(ans, req)
		}
		fmt.Fscanf(reader, "\n")

		fmt.Fprintf(writer, "%d\n", ans)
	}
}

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

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

package main

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

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

	var t, n, x, v int
	for Fscan(in, &t); t > 0; t-- {
		mx := 0
		found := false
		for Fscan(in, &n, &x); n > 0; n-- {
			if Fscan(in, &v); v > mx {
				mx = v
			}
			if v == x {
				found = true
			}
		}
		if found {
			Fprintln(out, 1)
		} else if mx > x {
			Fprintln(out, 2)
		} else {
			Fprintln(out, (x-1)/mx+1)
		}
	}
}

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

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"sync"
)
var a [100005]int
func main() {
	//var n, d, t, i, cas int
	for cas := ReadInt(); cas >0; cas-- {
		var maxx, ans int
		n:=ReadInt()
		d:=ReadInt()
		for i := 1; i <= n; i++ {
			a[i]=ReadInt()
			maxx = max(a[i], maxx)
			if a[i] == d {
				ans = 1
			}
		}
		if ans == 0 {
			tmp  := (d + maxx - 1) / maxx
			ans = max(tmp, 2)
		}
		fmt.Println(ans)
	}
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup
func ReadString() string {
	in.Scan()
	return in.Text()
}
func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}
func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.ParseInt(intStr, 10, 32)
	return int(i)
}
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	//set output
	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(write *bufio.Writer) {
		defer outWg.Done()
		defer write.Flush()

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

package main

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

func main() {
	scanner := bufio.NewReader(os.Stdin)
	var cases int
	fmt.Scanf("%d\n", cases)
	for i := 0; i < cases; i++ {
		arrs := readLine(scanner)
		arr := strings.Split(string(arrs), " ")
		distance, _ := strconv.ParseUint(arr[1], 10, 64)
		arrs = readLine(scanner)
		arr = strings.Split(string(arrs), " ")
		bigest := uint64(0)
		flag := false
		for _, c := range arr {
			ai, _ := strconv.ParseUint(c, 10, 64)
			if ai > bigest {
				bigest = ai
			}
			if distance == ai {
				fmt.Println(1)
				flag = true
				break
			}
		}
		if flag {
			continue
		}
		result := uint64(0)
		if distance < bigest {
			result = 2
		} else if distance%bigest == 0 {
			result = distance / bigest
		} else {
			result = distance/bigest + 1
		}
		fmt.Println(result)
	}
}

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 {
			// fmt.Println(string(result))
			break
		}
	}
	return result
}

package main

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

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

	var t, n, x, v int
	for Fscan(in, &t); t > 0; t-- {
		mx := 0
		for Fscan(in, &n, &x); n > 0; n-- {
			if Fscan(in, &v); v > mx {
				mx = v
			}
		}
		if mx > x {
			Fprintln(out, 2)
		} else {
			Fprintln(out, (x-1)/mx+1)
		}
	}
}

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


Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The n destinations are described by a non-negative integers sequence a1, a2, ..., an. The number ak represents that the kth destination is at distance ak kilometers from the starting point. No two destinations are located in the same place. Iahub wants to visit each destination only once. Note that, crossing through a destination is not considered visiting, unless Iahub explicitly wants to visit it at that point. Also, after Iahub visits his last destination, he doesn't come back to kilometer 0, as he stops his trip at the last destination. The distance between destination located at kilometer x and next destination, located at kilometer y, is |x - y| kilometers. We call a "route" an order of visiting the destinations. Iahub can visit destinations in any order he wants, as long as he visits all n destinations and he doesn't visit a destination more than once. Iahub starts writing out on a paper all possible routes and for each of them, he notes the total distance he would walk. He's interested in the average number of kilometers he would walk by choosing a route. As he got bored of writing out all the routes, he asks you to help him.

The first line contains integer n (2 ≤ n ≤ 105). Next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 107).

Output two integers — the numerator and denominator of a fraction which is equal to the wanted average number. The fraction must be irreducible.

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
	scanner.Scan()
	x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return x
}
func getI() int {
	return int(getI64())
}
func getF() float64 {
	scanner.Scan()
	x, _ := strconv.ParseFloat(scanner.Text(), 64)
	return x
}
func getS() string {
	scanner.Scan()
	return scanner.Text()
}

func gcd( _x,_y int64) int64{
	if _y == 0 {
		return _x
	}
	return gcd(_y , _x%_y)
}

func main(){

	scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	const MAXN = 100000 + 10
	var a []int
	n := getI()
	sum := int64(0)
	for i:=0 ; i < n ; i ++ {
		tmp := getI()
		a = append(a,tmp)
		sum += int64(a[i])
	}

	sort.Ints(a)
	sol := sum
	for i := 0 ; i < n ; i ++ {
		sum -= int64(a[i])
		sol += int64(2*(sum - int64(n-i-1)*int64(a[i])))
	}
	k := gcd(sol , int64(n))
	x1 := int64(sol/k)
	x2 := int64(int64(n)/k)
	writer.WriteString(fmt.Sprintf("%v %v\n",x1 ,x2))
}