Alice gave Bob two integers $$$a$$$ and $$$b$$$ ($$$a > 0$$$ and $$$b \ge 0$$$). Being a curious boy, Bob wrote down an array of non-negative integers with $$$\operatorname{MEX}$$$ value of all elements equal to $$$a$$$ and $$$\operatorname{XOR}$$$ value of all elements equal to $$$b$$$.What is the shortest possible length of the array Bob wrote?Recall that the $$$\operatorname{MEX}$$$ (Minimum EXcluded) of an array is the minimum non-negative integer that does not belong to the array and the $$$\operatorname{XOR}$$$ of an array is the bitwise XOR of all the elements of the array.

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The only line of each test case contains two integers $$$a$$$ and $$$b$$$ ($$$1 \leq a \leq 3 \cdot 10^5$$$; $$$0 \leq b \leq 3 \cdot 10^5$$$) — the $$$\operatorname{MEX}$$$ and $$$\operatorname{XOR}$$$ of the array, respectively.

For each test case, output one (positive) integer — the length of the shortest array with $$$\operatorname{MEX}$$$ $$$a$$$ and $$$\operatorname{XOR}$$$ $$$b$$$. We can show that such an array always exists.

NoteIn the first test case, one of the shortest arrays with $$$\operatorname{MEX}$$$ $$$1$$$ and $$$\operatorname{XOR}$$$ $$$1$$$ is $$$[0, 2020, 2021]$$$.In the second test case, one of the shortest arrays with $$$\operatorname{MEX}$$$ $$$2$$$ and $$$\operatorname{XOR}$$$ $$$1$$$ is $$$[0, 1]$$$.It can be shown that these arrays are the shortest arrays possible.

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 t,a,b int
	scanf("%d\n", &t)
	xsors := make([]int, 10_0000 * 3 + 1)
	for i := 1; i < len(xsors);i++ {
		xsors[i] = xsors[i-1] ^ i
	}
	for l := 0; l < t; l++ {
		scanf("%d %d\n", &a, &b)
		tmp := xsors[a - 1]
		if tmp != b {
			if b ^ tmp != a {
				printf("%d\n", a + 1)
			} else {
				printf("%d\n", a + 2)
			}
		} else {
			printf("%d\n", a)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
//wtf

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 t,a,b int
	scanf("%d\n", &t)
	xsors := make([]int, 10_0000 * 3 + 1)
	for i := 1; i < len(xsors);i++ {
		xsors[i] = xsors[i-1] ^ i
	}
	for l := 0; l < t; l++ {
		scanf("%d %d\n", &a, &b)
		tmp := xsors[a - 1]
		if tmp != b {
			if b ^ tmp != a {
				printf("%d\n", a + 1)
			} else {
				printf("%d\n", a + 2)
			}
		} else {
			printf("%d\n", a)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
//wtf

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 t,a,b int
	scanf("%d\n", &t)
	xsors := make([]int, 10_0000 * 3 + 1)
	for i := 1; i < len(xsors);i++ {
		xsors[i] = xsors[i-1] ^ i
	}
	for l := 0; l < t; l++ {
		scanf("%d %d\n", &a, &b)
		tmp := xsors[a - 1]
		if tmp != b {
			if b ^ tmp != a {
				fmt.Println(a + 1)
			} else {
				fmt.Println(a + 2)
			}
		} else {
			fmt.Println(a)
		}
	}
}

package main

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

func main() {
	var t int64
	r := bufio.NewReader(os.Stdin)
	fmt.Fscan(r, &t)

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

		var xor int64

		switch a % 4 {
		case 0:
			xor = 0
		case 1:
			xor = a - 1
		case 2:
			xor = (a - 1) ^ (a - 2)
		case 3:
			xor = (a - 1) ^ (a - 2) ^ (a - 3)
		}

		if xor == b {
			fmt.Printf("%d\n", a)
			continue
		}
		if b^xor == a {
			fmt.Printf("%d\n", a+2)
			continue
		}
		fmt.Printf("%d\n", a+1)
	}
}

package main

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

var (
	in = bufio.NewReader(os.Stdin)
)

func main() {
	var test int
	fmt.Fscan(in, &test)
	for i := 0; i < test; i++ {
		solve()
	}

}

func calcXor(a int) int {
	if a%4 == 0 {
		return a
	}
	if a%4 == 1 {
		return 1
	}
	if a%4 == 2 {
		return a + 1
	}
	return 0
}
func solve() {
	var a, b int
	fmt.Fscan(in, &a)
	fmt.Fscan(in, &b)
	var ans = a
	var currenXor = calcXor(a - 1)
	if currenXor == b {
		fmt.Println(ans)
		return
	}
	//now find out the digit whose xor is equal to the given b
	needed := 0
	for i := 32; i >= 0; i-- {
		if (1<<i)&currenXor != (1<<i)&b {
			needed |= 1 << i
		}
	}
	if needed == a {
		fmt.Println(a + 2)
	} else {
		fmt.Println(a + 1)
	}

}

//x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-TEMPLATE_STARTING-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-

type pair struct {
	a int64
	b int64
}

func sortPair(pairs []pair) {
	sort.Slice(pairs, func(i, j int) bool {
		return pairs[i].a < pairs[j].a
	})
}
func min(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max(a int64, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func printArray(arr []int) {
	for i := 1; i < len(arr); i++ {
		fmt.Print(arr[i], " ")
	}
	fmt.Println()
}

type runeSort []rune

func (r runeSort) Len() int           { return len(r) }
func (r runeSort) Swap(i, j int)      { r[i], r[j] = r[j], r[i] }
func (r runeSort) Less(i, j int) bool { return r[i] < r[j] }

// 00
package main

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

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

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	m := make(map[int]int)
	curr := 1
	xor := 0
	for curr <= 300000 {
		m[curr] = xor
		xor = xor ^ curr
		curr++
	}
	for t := 1; t <= T; t++ {
		var a, b int
		fmt.Fscan(reader, &a, &b)
		if m[a] != b {
			if m[a]^b == a {
				fmt.Println(a + 2)
			} else {
				fmt.Println(a + 1)
			}
		} else {
			fmt.Println(a)
		}
	}
}

package main

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

func main() {
	r := bufio.NewReaderSize(os.Stdin, 1024*1024)

	var T int
	fmt.Fscanf(r, "%d\n", &T)

	x := make([]int, 3*100000+2)
	for i := 1; i < len(x); i++ {
		x[i] = x[i-1] ^ i
	}

	for t := 0; t < T; t++ {
		var a, b int

		fmt.Fscanf(r, "%d %d\n", &a, &b)

		v := x[a-1] ^ b
		res := a

		// 0 1
		// 1

		if v == 0 {

		} else if v > a || v < a {
			res++
		} else {
			res += 2
		}

		fmt.Println(res)
	}
}

package main

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

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

	var T, a, b int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &a, &b)
		xor := 0
		switch a % 4 {
		case 1:
			xor = a - 1
		case 2:
			xor = 1
		case 3:
			xor = a
		}
		if xor == b {
			Fprintln(out, a)
		} else if xor^b != a {
			Fprintln(out, a+1)
		} else {
			Fprintln(out, a+2)
		}
	}
}

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

package main

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

func xorUpto(u int) (int) {
	u--
	switch u % 4 {
		case 0: return u
		case 1: return 1
		case 2: return u+1
		case 3: return 0
	}
	return -1
}

func solve(a, b int) int {
	xa := xorUpto(a)
	r := xa ^ b
	if (r == 0) {
		return a
	} else if (r == a) {
		return a+2
	} else {
		return a+1
	}
}

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

	s.Scan() // skip number of inputs
	for s.Scan() {
		l := strings.Split(s.Text(), " ")
		if len(l) < 2 {
			break
		}
		a, err := strconv.Atoi(l[0])
		if err != nil {
			break
		}
		if a < 1 {
			panic("a < 1")
		}
		b, err := strconv.Atoi(l[1])
		if err != nil {
			break
		}
		fmt.Println(solve(a, b))
	}
}

package main

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

type Scanner struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) *Scanner {
	scanner := bufio.NewScanner(reader)
	scanner.Split(bufio.ScanWords)
	return &Scanner{scanner}
}

func (s *Scanner) Word() string {
	s.Scan()
	return s.Text()
}

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

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

func (s *Scanner) Words(count int) []string {
	words := make([]string, count)
	for i := range words {
		words[i] = s.Word()
	}
	return words
}

func (s *Scanner) Ints(count int) []int {
	ints := make([]int, count)
	for i := range ints {
		ints[i] = s.Int()
	}
	return ints
}

func (s *Scanner) Int64s(count int) []int64 {
	int64s := make([]int64, count)
	for i := range int64s {
		int64s[i] = s.Int64()
	}
	return int64s
}

func compXors(n int) []int {
	xors := make([]int, n+1)
	for i := 1; i <= n; i++ {
		xors[i] = xors[i-1] ^ i
	}
	return xors
}

func solve(a, b int, xors []int) int {
	x := xors[a-1]
	if x == b {
		return a
	}
	if x^b != a {
		return a + 1
	}
	return a + 2
}

func main() {
	stdin := NewWordScanner(os.Stdin)
	tests := stdin.Int()

	xors := compXors(300010)

	for i := 0; i < tests; i++ {
		a, b := stdin.Int(), stdin.Int()
		fmt.Println(solve(a, b, xors))
	}
}

package main

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

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

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}
func computeXor(n int) int {
	switch n % 4 {
	case 0:
		return n
	case 1:
		return 1
	case 2:
		return n + 1
	case 3:
		return 0
	}
	return 0
}
func solve() {
	var a, b int
	scan(&a, &b)
	n := a - 1
	xor := computeXor(n)
	result := a
	neededXor := (b ^ xor)
	if neededXor > 0 {
		if neededXor == a {
			result += 2
		} else {
			result += 1
		}
	}
	printf("%d\n", result)
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

func xorTo(n int) int {
	switch {
	case n%4 == 0:
		return n
	case n%4 == 1:
		return 1
	case n%4 == 2:
		return n + 1
	default:
		return 0
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	var t int
	_, _ = fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		var a, b int
		_, _ = fmt.Fscan(reader, &a, &b)
		if xorTo(a-1) == b {
			fmt.Println(a)
		} else {
			need := b ^ xorTo(a-1)
			if need != a {
				fmt.Println(a + 1)
			} else {
				fmt.Println(a + 2)
			}
		}
	}
}

package main

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

func xorUpto(n int) int {
	return []int{n, 1, n + 1, 0}[n%4]
}

func solve(a, b int) int {
	x := xorUpto(a - 1)
	if x == b {
		return a
	}
	if x^b == mex {
		return a + 2
	}
	return a + 1
}

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

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

package main

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

func main() {
	stdin := bufio.NewReader(os.Stdin)
	stdout := bufio.NewWriter(os.Stdout)
	defer stdout.Flush()
	xorsum := make([]int, 310000)
	for i := 1; i < 310000; i++ {
		xorsum[i] = i ^ xorsum[i-1]
	}

	var tc int
	fmt.Fscanf(stdin, "%d\n", &tc)
	for ; tc > 0; tc-- {
		var mex, xor int
		fmt.Fscanf(stdin, "%d %d\n", &mex, &xor)
		ln := mex
		xor ^= xorsum[mex-1]
		if xor == 0 {
		} else if xor == mex {
			ln += 2
		} else {
			ln++
		}
		fmt.Fprintf(stdout, "%d\n", ln)
	}
}

package main
import (
	"fmt"
	"bufio"
	"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...) }
var XOR [1000000]int
func init(){
	for i:=1;i<1000000;i++{
		XOR[i]=XOR[i-1]^i
	}
}

func main(){
	defer writer.Flush()

	var t int
	scanf("%d\n",&t)
	for t>0{
		var mex,xor,ans int
		scanf("%d %d\n",&mex,&xor)
		currXor:=XOR[mex-1]
		needed:=currXor^xor
		if currXor==xor{
			ans=mex
		}else if needed==mex{
			ans=mex+2
		}else{
			ans=mex+1
		}
		printf("%d\n",ans)
		t--
	}

}

package main

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

func main() {
	var t,a,b int
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	fmt.Scanf("%d", &t)
	xsors := make([]int, 10_0000 * 3 + 1)
	for i := 1; i < len(xsors);i++ {
		xsors[i] = xsors[i-1] ^ i
	}
	for l := 0; l < t; l++ {
		fmt.Scanf("%d %d", &a, &b)
		tmp := xsors[a - 1]
		if tmp != b {
			if b ^ tmp != a {
				fmt.Println(a + 1)
			} else {
				fmt.Println(a + 2)
			}
		} else {
			fmt.Println(a)
		}
	}
}

package main

import "fmt"

func main() {
	var t,a,b int
	fmt.Scanln(&t)
	xsors := make([]int, 10_0000 * 3 + 1)
	for i := 1; i < len(xsors);i++ {
		xsors[i] = xsors[i-1] ^ i
	}
	for l := 0; l < t; l++ {
		fmt.Scan(&a, &b)
		tmp := xsors[a - 1]
		if tmp != b {
			if b <= a {
				fmt.Println(a + 2)
			} else {
				fmt.Println(a + 1)
			}
		} else {
			fmt.Println(a)
		}
 	}
}

package main

import "fmt"

func main() {
	var t,a,b int
	fmt.Scanln(&t)
	xsors := make([]int, 10_0000 * 3 + 1)
	for i := 1; i < len(xsors);i++ {
		xsors[i] = xsors[i-1] ^ i
	}
	for l := 0; l < t; l++ {
		fmt.Scan(&a, &b)
		tmp := xsors[a - 1]
		if tmp != b {
			if b == a {
				fmt.Println(a + 2)
			} else {
				fmt.Println(a + 1)
			}
		} else {
			fmt.Println(a)
		}
 	}
}

package main

import (
	"fmt"
)

func main() {
	var t int64
	_, err := fmt.Scan(&t)
	if err != nil {
		return
	}
	for i := int64(0); i < t; i++ {
		var a int64
		var b int64
		_, err := fmt.Scan(&a)
		if err != nil {
			return
		}
		fmt.Scan(&b)
		if err != nil {
			return
		}

		var xor int64

		switch a % 4 {
		case 0:
			xor = 0
		case 1:
			xor = a - 1
		case 2:
			xor = (a - 1) ^ (a - 2)
		case 3:
			xor = (a - 1) ^ (a - 2) ^ (a - 3)
		}

		if xor == b {
			fmt.Println(a)
			continue
		}
		if b^xor == a {
			fmt.Println(a + 2)
			continue
		}
		fmt.Println(a)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int64
	_, err := fmt.Scan(&t)
	if err != nil {
		return
	}
	for i := int64(0); i < t; i++ {
		var a int64
		var b int64
		_, err := fmt.Scan(&a)
		if err != nil {
			return
		}
		fmt.Scan(&b)
		if err != nil {
			return
		}

		var xor int64

		switch (a - 1) % 4 {
		case 0:
			xor = 0
		case 1:
			xor = a - 1
		case 2:
			xor = (a - 1) ^ (a - 2)
		case 3:
			xor = (a - 1) ^ (a - 2) ^ (a - 3)
		}

		if xor == b {
			fmt.Println(a)
			continue
		}
		if b^xor == a {
			fmt.Println(a + 2)
			continue
		}
		fmt.Println(a+1)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int64
	_, err := fmt.Scan(&t)
	if err != nil {
		return
	}
	for i := int64(0); i < t; i++ {
		var a int64
		var b int64
		_, err := fmt.Scan(&a)
		if err != nil {
			return
		}
		fmt.Scan(&b)
		if err != nil {
			return
		}

		var xor int64

		switch (a - 1) % 4 {
		case 0:
			xor = 0
		case 1:
			xor = a - 1
		case 2:
			xor = (a - 1) ^ (a - 2)
		case 3:
			xor = (a - 1) ^ (a - 2) ^ (a - 3)
		}

		if xor == b {
			fmt.Println(a-1)
			continue
		}
		if b^xor == a {
			fmt.Println(a + 1)
			continue
		}
		fmt.Println(a)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int64
	_, err := fmt.Scan(&t)
	if err != nil {
		return
	}
	for i := int64(0); i < t; i++ {
		var a int64
		var b int64
		_, err := fmt.Scan(&a)
		if err != nil {
			return
		}
		fmt.Scan(&b)
		if err != nil {
			return
		}
		var array []int64
		var xor int64

		switch (a - 1) % 4 {
		case 0:
			xor = 0
		case 1:
			xor = a - 1
		case 2:
			xor = (a - 1) ^ (a - 2)
		case 3:
			xor = (a - 1) ^ (a - 2) ^ (a - 3)
		}

		if xor == b {
			fmt.Println(len(array))
			continue
		}
		if b^xor == a {
			fmt.Println(len(array) + 2)
			continue
		}
		fmt.Println(len(array) + 1)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int64
	_, err := fmt.Scan(&t)
	if err != nil {
		return
	}
	for i := int64(0); i < t; i++ {
		var a int64
		var b int64
		_, err := fmt.Scan(&a)
		if err != nil {
			return
		}
		fmt.Scan(&b)
		if err != nil {
			return
		}
		var array []int64
		var xor int64

			for j := int64(0); j < a; j++ {
				array = append(array, j)
				xor =xor ^ j
			}
			if xor==b{
				fmt.Println(len(array))
				continue
			}
			if b^xor==b{
				fmt.Println(len(array)+2)
				continue
			}
			fmt.Println(len(array)+1)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int64
	_, err := fmt.Scan(&t)
	if err != nil {
		return
	}
	for i := int64(0); i < t; i++ {
		var a int64
		var b int64
		_, err = fmt.Scanf("%d %d\n", &a, &b)
		if err != nil {
			return
		}
		var array []int64
		var xor int64

			for j := int64(0); j < a; j++ {
				array = append(array, j)
				xor =xor ^ j
			}
			if xor==b{
				fmt.Println(len(array))
				continue
			}
			if b^xor==b{
				fmt.Println(len(array)+2)
				continue
			}
			fmt.Println(len(array)+1)
	}
}

package main

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

var (
	in = bufio.NewReader(os.Stdin)
)

func main() {
	var test int
	fmt.Fscan(in, &test)
	for i := 0; i < test; i++ {
		solve()
	}

}

func calcXor(a int) int {
	if a%4 == 0 {
		return a
	}
	if a%4 == 1 {
		return 1
	}
	if a%4 == 2 {
		return a + 1
	}
	return 0
}
func solve() {
	var a, b int
	fmt.Fscan(in, &a)
	fmt.Fscan(in, &b)
	var ans = a
	var currenXor = calcXor(a - 1)
	if currenXor == b {
		fmt.Println(ans)
		return
	}
	//now find out the digit whose xor is equal to the given b
	needed := 0
	for i := 0; i < 32; i++ {
		if currenXor&(1<<i) == 0 && b&(1<<i) == 1 {
			needed |= 1 << i
		} else if currenXor&(1<<i) == 1 && b&(1<<i) == 0 {
			needed |= 1 << i
		}
	}
	if needed == a {
		fmt.Println(a + 2)
	} else {
		fmt.Println(a + 1)
	}

}

//x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-TEMPLATE_STARTING-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-

type pair struct {
	a int64
	b int64
}

func sortPair(pairs []pair) {
	sort.Slice(pairs, func(i, j int) bool {
		return pairs[i].a < pairs[j].a
	})
}
func min(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max(a int64, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func printArray(arr []int) {
	for i := 1; i < len(arr); i++ {
		fmt.Print(arr[i], " ")
	}
	fmt.Println()
}

type runeSort []rune

func (r runeSort) Len() int           { return len(r) }
func (r runeSort) Swap(i, j int)      { r[i], r[j] = r[j], r[i] }
func (r runeSort) Less(i, j int) bool { return r[i] < r[j] }

package main

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

var (
	in = bufio.NewReader(os.Stdin)
)

func main() {
	var test int
	fmt.Fscan(in, &test)
	for i := 0; i < test; i++ {
		solve()
	}

}

func calcXor(a int) int {
	if a%4 == 0 {
		return a
	}
	if a%4 == 1 {
		return 1
	}
	if a%4 == 2 {
		return a + 2
	}
	return 0
}
func solve() {
	var a, b int
	fmt.Fscan(in, &a)
	fmt.Fscan(in, &b)
	var ans = a
	var currenXor = calcXor(a - 1)
	if currenXor == b {
		fmt.Println(ans)
		return
	}
	//now find out the digit whose xor is equal to the given b
	needed := 0
	for i := 0; i < 32; i++ {
		if currenXor&(1<<i) == 0 && b&(1<<i) == 1 {
			needed |= 1 << i
		} else if currenXor&(1<<i) == 1 && b&(1<<i) == 0 {
			needed |= 1 << i
		}
	}
	if needed == a {
		fmt.Println(a + 2)
	} else {
		fmt.Println(a + 1)
	}

}

//x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-TEMPLATE_STARTING-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-

type pair struct {
	a int64
	b int64
}

func sortPair(pairs []pair) {
	sort.Slice(pairs, func(i, j int) bool {
		return pairs[i].a < pairs[j].a
	})
}
func min(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max(a int64, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func printArray(arr []int) {
	for i := 1; i < len(arr); i++ {
		fmt.Print(arr[i], " ")
	}
	fmt.Println()
}

type runeSort []rune

func (r runeSort) Len() int           { return len(r) }
func (r runeSort) Swap(i, j int)      { r[i], r[j] = r[j], r[i] }
func (r runeSort) Less(i, j int) bool { return r[i] < r[j] }

package main

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

var (
	in = bufio.NewReader(os.Stdin)
)

func main() {
	var test int
	fmt.Fscan(in, &test)
	for i := 0; i < test; i++ {
		solve()
	}

}

func calcXor(a int) int {
	if a%4 == 0 {
		return a
	}
	if a%4 == 1 {
		return 1
	}
	if a%4 == 2 {
		return a + 2
	}
	return 0
}
func solve() {
	var a, b int
	fmt.Fscan(in, &a)
	fmt.Fscan(in, &b)
	var ans = a
	var currenXor = calcXor(a - 1)
	if currenXor == b {
		fmt.Println(ans)
		return
	}
	//now find out the digit whose xor is equal to the given b
	needed := 0
	for i := 0; i < 32; i++ {
		if currenXor&1<<i == 0 && b&1<<i == 1 {
			needed |= 1 << i
		} else if currenXor&1<<i == 1 && b&1<<i == 0 {
			needed |= 1 << i
		}
	}
	if needed == a {
		fmt.Println(a + 2)
	} else {
		fmt.Println(a + 1)
	}

}

//x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-TEMPLATE_STARTING-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-

type pair struct {
	a int64
	b int64
}

func sortPair(pairs []pair) {
	sort.Slice(pairs, func(i, j int) bool {
		return pairs[i].a < pairs[j].a
	})
}
func min(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max(a int64, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func printArray(arr []int) {
	for i := 1; i < len(arr); i++ {
		fmt.Print(arr[i], " ")
	}
	fmt.Println()
}

type runeSort []rune

func (r runeSort) Len() int           { return len(r) }
func (r runeSort) Swap(i, j int)      { r[i], r[j] = r[j], r[i] }
func (r runeSort) Less(i, j int) bool { return r[i] < r[j] }

// 00
package main

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

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

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	m := make(map[int]int)
	curr := 1
	xor := 0
	for curr <= 300000 {
		m[curr] = xor
		xor = xor ^ curr
		curr++
	}
	for t := 1; t <= T; t++ {
		var a, b int
		fmt.Fscan(reader, &a, &b)
		if m[a] != b {
			if a == b {
				fmt.Println(a + 2)
			} else {
				fmt.Println(a + 1)
			}
		} else {
			fmt.Println(a)
		}
	}
}

// 00
package main

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

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

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	m := make(map[int]int)
	curr := 1
	xor := 0
	for curr <= 300000 {
		m[curr] = xor
		xor = xor ^ curr
		curr++
	}
	for t := 1; t <= T; t++ {
		var a, b int
		fmt.Fscan(reader, &a, &b)
		if a == 1 && b == 1 {
			fmt.Println(3)
		} else if m[a] != b {
			fmt.Println(a + 1)
		} else {
			fmt.Println(a)
		}
	}
}

package main

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

func main() {
	r := bufio.NewReaderSize(os.Stdin, 1024*1024)

	var T int
	fmt.Fscanf(r, "%d\n", &T)

	for t := 0; t < T; t++ {
		var a, b int

		fmt.Fscanf(r, "%d %d\n", &a, &b)

		x := 0

		for i := 0; i < a; i++ {
			x ^= i
		}

		v := x ^ b
		res := a

		// 0 1
		// 1

		if v == 0 {

		} else if v > a {
			res++
		} else {
			res += 2
		}

		fmt.Println(res)
	}
}

package main

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

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

	var T, a, b int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &a, &b)
		xor := 0
		if a > 1 {
			switch a % 4 {
			case 1:
				xor = a*4 + 3
			case 2:
				xor = 1
			case 3:
				xor = a*4 + 2
			}
		}
		if xor == b {
			Fprintln(out, a)
		} else if xor^b != a {
			Fprintln(out, a+1)
		} else {
			Fprintln(out, a+2)
		}
	}
}

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


You are given an array of $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$, and a set $$$b$$$ of $$$k$$$ distinct integers from $$$1$$$ to $$$n$$$.In one operation, you may choose two integers $$$i$$$ and $$$x$$$ ($$$1 \le i \le n$$$, $$$x$$$ can be any integer) and assign $$$a_i := x$$$. This operation can be done only if $$$i$$$ does not belong to the set $$$b$$$.Calculate the minimum number of operations you should perform so the array $$$a$$$ is increasing (that is, $$$a_1 < a_2 < a_3 < \dots < a_n$$$), or report that it is impossible.

The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 5 \cdot 10^5$$$, $$$0 \le k \le n$$$) — the size of the array $$$a$$$ and the set $$$b$$$, respectively. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \le a_i \le 10^9$$$). Then, if $$$k \ne 0$$$, the third line follows, containing $$$k$$$ integers $$$b_1$$$, $$$b_2$$$, ..., $$$b_k$$$ ($$$1 \le b_1 < b_2 < \dots < b_k \le n$$$). If $$$k = 0$$$, this line is skipped.

If it is impossible to make the array $$$a$$$ increasing using the given operations, print $$$-1$$$. Otherwise, print one integer — the minimum number of operations you have to perform.

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1437E(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	lis := func(a []int) int {
		dp := []int{}
		for _, v := range a {
			if p := sort.SearchInts(dp, v+1); p < len(dp) {
				dp[p] = v
			} else {
				dp = append(dp, v)
			}
		}
		return len(dp)
	}

	var n, k, ans int
	Fscan(in, &n, &k)
	a := make([]int, n+2)
	a[0] = -1e8
	for i := 1; i <= n; i++ {
		Fscan(in, &a[i])
	}
	a[n+1] = 2e9
	b := make([]int, k+2)
	for i := 1; i <= k; i++ {
		Fscan(in, &b[i])
	}
	b[k+1] = n + 1

	for i := 0; i <= k; i++ {
		l, r := b[i], b[i+1]
		if a[r]-a[l] < r-l {
			Fprint(out, -1)
			return
		}
		c := []int{}
		for j := l + 1; j < r; j++ {
			v := a[j]
			if v-a[l] >= j-l && a[r]-v >= r-j {
				c = append(c, v-j)
			}
		}
		ans += lis(c)
	}
	Fprint(out, n-k-ans)
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1437E(_r io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	_i, buf := 1<<12, make([]byte, 1<<12)
	rc := func() byte {
		if _i == 1<<12 {
			_r.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
	}
	n, k := r(), r()
	a := make([]int, n+2)
	a[0] = -1e8
	for i := 1; i <= n; i++ {
		a[i] = r()
	}
	a[n+1] = 2e9
	b := make([]int, k+2)
	for i := 1; i <= k; i++ {
		b[i] = r()
	}
	b[k+1] = n + 1

	ans := 0
	for i := 0; i <= k; i++ {
		l, r := b[i], b[i+1]
		if a[r]-a[l] < r-l {
			Fprint(out, -1)
			return
		}
		dp := []int{}
		for j := l + 1; j < r; j++ {
			if v := a[j] - j; a[l]-l <= v && v <= a[r]-r {
				if p := sort.SearchInts(dp, v+1); p < len(dp) {
					dp[p] = v
				} else {
					dp = append(dp, v)
				}
			}
		}
		ans += len(dp)
	}
	Fprint(out, n-k-ans)
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	var n, k, s int
	Fscan(in, &n, &k)
	a := make([]int, n+2)
	a[0],a[n+1] = -1e8,2e9
	for i := 1; i <= n; i++ { Fscan(in, &a[i]) }
	b := make([]int, k+2)
	for i := 1; i <= k; i++ { Fscan(in, &b[i]) }
	b[k+1] = n+1

	for i, l := range b[:k+1] {
		r := b[i+1]
		if a[r]-a[l] < r-l {
			Print(-1)
			return
		}
		dp := []int{}
		for j := l + 1; j < r; j++ {
			if v := a[j] - j; a[l]-l <= v && v <= a[r]-r {
				if p := sort.SearchInts(dp, v+1); p < len(dp) {
					dp[p] = v
				} else {
					dp = append(dp, v)
				}
			}
		}
		s += len(dp)
	}
	Print(n-k-s)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1437E(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, k, ans int
	Fscan(in, &n, &k)
	a := make([]int, n+2)
	a[0] = -1e8
	for i := 1; i <= n; i++ {
		Fscan(in, &a[i])
	}
	a[n+1] = 2e9
	b := make([]int, k+2)
	for i := 1; i <= k; i++ {
		Fscan(in, &b[i])
	}
	b[k+1] = n + 1

	for i := 0; i <= k; i++ {
		l, r := b[i], b[i+1]
		if a[r]-a[l] < r-l {
			Fprint(out, -1)
			return
		}
		dp := []int{}
		for j := l + 1; j < r; j++ {
			if v := a[j] - j; a[l]-l <= v && v <= a[r]-r {
				if p := sort.SearchInts(dp, v+1); p < len(dp) {
					dp[p] = v
				} else {
					dp = append(dp, v)
				}
			}
		}
		ans += len(dp)
	}
	Fprint(out, n-k-ans)
}

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


There are $$$n$$$ cats in a line, labeled from $$$1$$$ to $$$n$$$, with the $$$i$$$-th cat at position $$$i$$$. They are bored of gyrating in the same spot all day, so they want to reorder themselves such that no cat is in the same place as before. They are also lazy, so they want to minimize the total distance they move. Help them decide what cat should be at each location after the reordering.For example, if there are $$$3$$$ cats, this is a valid reordering: $$$[3, 1, 2]$$$. No cat is in its original position. The total distance the cats move is $$$1 + 1 + 2 = 4$$$ as cat $$$1$$$ moves one place to the right, cat $$$2$$$ moves one place to the right, and cat $$$3$$$ moves two places to the left.

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first and only line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 100$$$) — the number of cats. It can be proven that under the constraints of the problem, an answer always exist.

Output $$$t$$$ answers, one for each test case. Each answer consists of $$$n$$$ integers — a permutation with the minimum total distance. If there are multiple answers, print any.

NoteFor the first test case, there is only one possible permutation that satisfies the conditions: $$$[2, 1]$$$.The second test case was described in the statement. Another possible answer is $$$[2, 3, 1]$$$.

package main

import (
    "fmt"
    "strings"
)

func main() {
    var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var k, rn int
		fmt.Scan(&k)
		rn = (k % 2)
		fmt.Print("2 ", strings.Repeat("3 ", rn), "1 ")
		for flag, j := 1, 3+rn; j <= k; j, flag = j+1, flag*-1 {
			fmt.Print(j+flag, " ")
		}
		fmt.Println()
	}
}

package main

import (
    "fmt"
    "strings"
)

func main() {
    var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var k int
		fmt.Scan(&k)
		rn := (k % 2)
		fmt.Print("2 ", strings.Repeat("3 ", rn), "1 ")
		flag := 1
		for j := 3 + rn; j <= k; j++ {
			fmt.Print(j+flag, " ")
			flag *= -1
		}
		fmt.Println()
	}
}

package main

import (
    "fmt"
)

func main() {
    var n int
    fmt.Scan(&n)
    for i:=0; i<n; i++ {
        var k int
        fmt.Scan(&k)
        flag:=1
        for j:=1; j<=k-2; j++ {
            fmt.Print(j + flag," ")
            flag*=-1
        }
        if k%2 == 0 {
            fmt.Print(k,k-1)
        } else {
            fmt.Print(k,k-2)
        }
        fmt.Println()
    }

}

package main

import (
    "fmt"
)

func main() {
    var n int
    fmt.Scan(&n)
    for i:=0; i<n; i++ {
        var k int
        fmt.Scan(&k)
        flag:=1
        if k%2 == 0 {
            for j:=1; j<=k; j++ {
                fmt.Print(j + flag," ")
                flag*=-1
            }
        } else {
            for j:=1; j<=k-2; j++ {
                fmt.Print(j + flag," ")
                flag*=-1
            }
            fmt.Print(k,k-2)
        }
        fmt.Println()
    }

}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Scan(&n)
		if n%2 == 0 {
			for j:=0;j<n;j+=2{
				fmt.Printf("%d %d ",j+2,j+1)
			}
		} else {
			fmt.Printf("3 1 2 ")
			for j:=3;j<n;j+=2{
				fmt.Printf("%d %d ",j+2,j+1)
			}
		}
		fmt.Println()
	}
}

package main

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

func main() {
    reader := bufio.NewReader(os.Stdin)
    input, _ := reader.ReadString('\n')

	// Get t
	t, _ := GetInt(input)

	for i:=0; i<t; i++ {
		// Get n
		input, _ = reader.ReadString('\n')
		var n int
		n, _ = GetInt(input)

		m := n>>1 - 1
		for i:=1; i<=m; i++ {
			fmt.Printf("%d %d ", 2*i, 2*i-1)
		}
		if n & 0x1 == 1 {
			fmt.Printf("%d %d %d\n", n, n-2, n-1)

		} else {
			fmt.Printf("%d %d\n", n, n-1)
		}
	}
}

// func abs(val float64) float64 {
//     if val >= 0.0 {
//         return val
//     }
//     return -val
// }

func GetInt(s string) (result int, output string) {
	iter, n := 0, len(s)
	for iter < n && s[iter] >= '0' && s[iter] <= '9' {
		iter++
	}
	result, _ = strconv.Atoi(s[:iter])
	// Skip the redundant characters
	for iter < n && (s[iter] < '0' || s[iter] > '9') {
		iter++
	}
	if iter == n {
		output = ""

	} else {
		output = s[iter:]
	}
	return
}

func GetInt64(s string) (result int64, output string) {
	iter, n := 0, len(s)
	for iter < n && s[iter] >= '0' && s[iter] <= '9' {
		iter++
	}
	result, _ = strconv.ParseInt(s[:iter], 10, 64)
	// Skip the redundant characters
	for iter < n && (s[iter] < '0' || s[iter] > '9') {
		iter++
	}
	if iter == n {
		output = ""

	} else {
		output = s[iter:]
	}
	return
}

package main

import ."fmt"
//import "sort"
import "bufio"
import "os"
//import "string"
//import "time"
//import ."math"

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

func main() {
    defer writer.Flush()

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

}
func solve() {
    n := sint64()
	arr := make([]int64, n)
	for i := int64(0); i < n; i++ {
		arr[i] = i + 1
	}

	for i := int64(1); i < n; i += 2 {
		arr[i], arr[i - 1] = arr[i - 1], arr[i]
	}

	if n % 2 == 1 {
		arr[n - 1], arr[n - 2] = arr[n - 2], arr[n - 1]
	}

	for i := int64(0); i < n; i++ {
		printf("%d ", arr[i])
	}
	printf("\n")

}
func printf(f string, a ...interface{}) {
	Fprintf(writer, f, a...)
}
func sstring() string {
	scanner.Scan()
	return scanner.Text()
}
func sint64() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sum(a []int64) int64{
    ans := int64(0)
    for _, i := range a {
        ans += i
    }
    return ans
}
func abs(x int64) int64 {
    if x < 0 {
        return 0 - x
    }
    return x
}
func min(x, y int64) int64 {
    if x < y {
        return x
    }
    return y
}

package main

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

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

	for test := parseInt(getString(reader)); test > 0; test-- {
		n := parseInt(getString(reader))
		A := make([]int, n)
		for i := 0; i < (n / 2); i++ {
			A[2*i] = 2 * (i + 1)
			A[2*i+1] = 2*i + 1
		}
		if n%2 == 1 {
			A[n-2] = n
			A[n-1] = n - 2
		}
		writer.WriteString(fmt.Sprint(A)[1:len(fmt.Sprint(A))-1] + "\n")
	}
	writer.Flush()
}

func parseInt(str string) int {
	var res int
	size := len(str)
	for i := 0; i < size; i++ {
		digit := int(str[i] - '0')
		for j := (i + 1); j < size; j++ {
			digit = digit<<3 + digit<<1
		}
		res += digit
	}
	return res
}

func getString(in *bufio.Reader) string {
	res, _ := in.ReadString('\n')
	res = strings.ReplaceAll(res, "\n", "")
	res = strings.ReplaceAll(res, "\r", "")
	res = strings.TrimSpace(res)
	return res
}

package main

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

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

func solve(n int) string {
	var x string
	if n%2 == 0 {
		for i := 1; i <= n; i += 2 {
			x += fmt.Sprintf("%d %d ", i+1, i)
		}
	} else {
		x = "2 3 1 "
		for i := 4; i <= n; i += 2 {
			x += fmt.Sprintf("%d %d ", i+1, i)
		}
	}
	return x
}

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

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 n int
		fmt.Fscan(input, &n)
		if n%2 == 0 {
			k := int(n / 2)
			for i := 1; i < k+1; i++ {
				fmt.Println(2 * i)
				fmt.Println(2*i - 1)
			}
		} else {
			fmt.Println(3)
			fmt.Println(1)
			fmt.Println(2)
			k := int(n / 2)
			for i := 2; i < k+1; i++ {
				fmt.Println(2*i + 1)
				fmt.Println(2 * i)
			}

		}
	}

}

package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"log"
	"os"
)

func init() {
	log.SetFlags(0)
	log.SetOutput(ioutil.Discard)
}

func solve(num int) []int {
	a := make([]int, num)
	for i := 1; i < num+1; i++ {
		a[i-1] = i
	}

	for i := 0; i < num-1; i += 2 {
		a[i], a[i+1] = a[i+1], a[i]
	}
	if num%2 != 0 {
		a[num-3] = num
		a[num-1] = num - 1
		a[num-2] = num - 2
	}
	return a
}

func main() {
	log.Println("start")

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

	// num := 0
	// fmt.Fscan(in, &num)
	// for i := 0; i < num; i++ {
	var size int
	fmt.Fscan(in, &size)
	// a := make([]int, size)
	for i := 0; i < size; i++ {
		var num int
		fmt.Fscan(in, &num)
		a := solve(num)
		log.Printf("a = %#v\n", a)

		for _, v := range a {
			fmt.Fprintf(out, "%d ", v)
		}
		fmt.Fprintf(out, "\n")
	}
	log.Println("__end__")
}

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

		solve(n)
		fmt.Println()
	}
}

func solve(n int) {

	if n == 3 {
		fmt.Print(2)
		fmt.Print(" ")
		fmt.Print(3)
		fmt.Print(" ")
		fmt.Print(1)
		fmt.Print(" ")
		return
	}

	if n % 2 == 0 {

		for i := 1; i <= n; i += 2 {
			fmt.Print(i + 1)
			fmt.Print(" ")
			fmt.Print(i)
			fmt.Print(" ")
		}

	} else {
		fmt.Print(2)
		fmt.Print(" ")
		fmt.Print(3)
		fmt.Print(" ")
		fmt.Print(1)
		fmt.Print(" ")

		for i := 4; i <= n; i +=2 {
			fmt.Print(i + 1)
			fmt.Print(" ")
			fmt.Print(i)
			fmt.Print(" ")
		}
	}
}

//1 2 3 4 5 6 7
//2 3 1 5 4 7 6

package main

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

func CF1541A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, N int
	for fmt.Fscan(in, &T); T > 0; T-- {
		fmt.Fscan(in, &N)
		vec := make([]int, N)
		for i := 1; i <= N; i++ {
			vec[i-1] = i
		}
		for i := 0; i < N-1; i += 2 {
			vec[i], vec[i+1] = vec[i+1], vec[i]
		}
		if N&1 != 0 {
			vec[N-3], vec[N-1] = vec[N-1], vec[N-3]
		}
		for i := 0; i < N; i++ {
			fmt.Fprint(out, vec[i], " ")
		}
		fmt.Fprintln(out)
	}
}

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

package main

import (
	"fmt"
)

func solve() {
	n := readInt()

	if n%2 == 0 {
		for i := 0; i < n/2; i++ {
			fmt.Printf("%d %d ", 2*i+2, 2*i+1)
		}
	} else {
		for i := 0; i < (n-3)/2; i++ {
			fmt.Printf("%d %d ", 2*i+2, 2*i+1)
		}
		fmt.Printf("%d %d %d", n, n-2, n-1)
	}
	fmt.Print("\n")
}

func main() {
	n := readInt()
	for i := 0; i < n; i++ {
		solve()
	}
}

func readInt() int {
	var n int
	fmt.Scan(&n)
	return n
}
func readIntN(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	return arr
}

func readIntNN(n, m int) [][]int {
	arr := make([][]int, n)
	for i := 0; i < n; i++ {
		arr[i] = readIntN(m)
	}
	return arr
}

func min(a ...int) int {
	min := a[0]
	for _, v := range a {
		if v < min {
			min = v
		}
	}
	return min
}
func max(a ...int) int {
	max := a[0]
	for _, v := range a {
		if v > max {
			max = v
		}
	}
	return max
}

func minMax(a ...int) (min int, max int) {
	min, max = a[0], a[0]
	for _, v := range a {
		if v < min {
			min = v
		}
		if v > max {
			max = v
		}
	}
	return
}

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

package main

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

type CF1541A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1541A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1541A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1541A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1541A) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1541A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1541A
Date: 11/10/21
User: epradere
URL: https://codeforces.com/problemset/problem/1541/A
Problem: CF1541A
**/
func (in *CF1541A) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		n := in.NextInt()
		sol := make([]int, n)

		for i := 1; i < n; i += 2 {
			sol[i] = i
			sol[i-1] = i + 1
		}

		if n % 2 != 0 {
			sol[n-2], sol[n-1] = n, sol[n-2]
		}

		for i := 0; i < n; i++ {
			fmt.Print(sol[i], " ")
		}
		fmt.Println()
	}
}

func NewCF1541A(r *bufio.Reader) *CF1541A {
	return &CF1541A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1541A(bufio.NewReader(os.Stdin)).Run()
}

package main

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

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 solve(n int) []int {
	if n == 2 {
		return []int{2, 1}
	}

	res := make([]int, n)

	if n%2 == 0 {
		for i := 0; i < n; i += 2 {
			res[i] = i + 2
			res[i+1] = i + 1
		}
	} else {
		for i := 0; i+3 < n; i += 2 {
			res[i] = i + 2
			res[i+1] = i + 1
		}
		res[n-3] = n
		res[n-2] = n - 2
		res[n-1] = n - 1
	}

	return res
}

func main() {
	scanner := StdinScanner()

	tests := scanner.Int()
	for i := 0; i < tests; i += 1 {
		x := scanner.Int()
		res := solve(x)
		for _, num := range res {
			fmt.Printf("%d ", num)
		}
		fmt.Println()
	}
}

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

		arr := make([]int, n)
		for i := 0; i < n; i++ {
			arr[i] = i + 1
		}

		for i := 1; i < n; i += 2 {
			arr[i], arr[i-1] = arr[i-1], arr[i]
		}

		if n%2 == 1 {
			arr[n-1], arr[n-2] = arr[n-2], arr[n-1]
		}

		for i := 0; i < n; i++ {
			fmt.Printf("%d ", arr[i])
		}
		fmt.Println()
	}
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Scan(&n)
		fmt.Printf("%d ",n)
		for j:=1;j<=n-1;j++{
			fmt.Printf("%d ",j)
		}
		fmt.Println()
	}
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Scan(&n)
		fmt.Printf("%d ",n)
		for j:=1;j<=n-1;j++{
			fmt.Printf("%d ",j)
		}
	}
}

package main

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

func main() {
    reader := bufio.NewReader(os.Stdin)
    input, _ := reader.ReadString('\n')

	// Get t
	t, _ := GetInt(input)

	for i:=0; i<t; i++ {
		// Get n
		input, _ = reader.ReadString('\n')
		var n int
		n, _ = GetInt(input)

		m := n>>1 - 1
		for i:=0; i<m; i++ {
			fmt.Printf("%d %d ", 1<<i+1, 1<<i)
		}
		if n & 0x1 == 1 {
			fmt.Printf("%d %d %d\n", n, n-2, n-1)

		} else {
			fmt.Printf("%d %d\n", n, n-1)
		}
	}
}

// func abs(val float64) float64 {
//     if val >= 0.0 {
//         return val
//     }
//     return -val
// }

func GetInt(s string) (result int, output string) {
	iter, n := 0, len(s)
	for iter < n && s[iter] >= '0' && s[iter] <= '9' {
		iter++
	}
	result, _ = strconv.Atoi(s[:iter])
	// Skip the redundant characters
	for iter < n && (s[iter] < '0' || s[iter] > '9') {
		iter++
	}
	if iter == n {
		output = ""

	} else {
		output = s[iter:]
	}
	return
}

func GetInt64(s string) (result int64, output string) {
	iter, n := 0, len(s)
	for iter < n && s[iter] >= '0' && s[iter] <= '9' {
		iter++
	}
	result, _ = strconv.ParseInt(s[:iter], 10, 64)
	// Skip the redundant characters
	for iter < n && (s[iter] < '0' || s[iter] > '9') {
		iter++
	}
	if iter == n {
		output = ""

	} else {
		output = s[iter:]
	}
	return
}

package main

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

func main() {
    reader := bufio.NewReader(os.Stdin)
    input, _ := reader.ReadString('\n')

	// Get t
	t, _ := GetInt(input)

	for i:=0; i<t; i++ {
		// Get n
		input, _ = reader.ReadString('\n')
		var n int
		n, _ = GetInt(input)

		fmt.Printf("%d ", n)
		for i:=1; i<n; i++ {
			fmt.Printf("%d ", i)
		}
		fmt.Println()
	}
}

// func abs(val float64) float64 {
//     if val >= 0.0 {
//         return val
//     }
//     return -val
// }

func GetInt(s string) (result int, output string) {
	iter, n := 0, len(s)
	for iter < n && s[iter] >= '0' && s[iter] <= '9' {
		iter++
	}
	result, _ = strconv.Atoi(s[:iter])
	// Skip the redundant characters
	for iter < n && (s[iter] < '0' || s[iter] > '9') {
		iter++
	}
	if iter == n {
		output = ""

	} else {
		output = s[iter:]
	}
	return
}

func GetInt64(s string) (result int64, output string) {
	iter, n := 0, len(s)
	for iter < n && s[iter] >= '0' && s[iter] <= '9' {
		iter++
	}
	result, _ = strconv.ParseInt(s[:iter], 10, 64)
	// Skip the redundant characters
	for iter < n && (s[iter] < '0' || s[iter] > '9') {
		iter++
	}
	if iter == n {
		output = ""

	} else {
		output = s[iter:]
	}
	return
}

package main

import ."fmt"
//import "sort"
import "bufio"
import "os"
//import "string"
//import "time"
//import ."math"

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

func main() {
    defer writer.Flush()

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

}
func solve() {
    n := sint64()
    printf("%d ", n)
    for i := int64(1); i < n; i++ {
        printf("%d ", i)
    }
    printf("\n")

}
func printf(f string, a ...interface{}) {
	Fprintf(writer, f, a...)
}
func sstring() string {
	scanner.Scan()
	return scanner.Text()
}
func sint64() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sum(a []int64) int64{
    ans := int64(0)
    for _, i := range a {
        ans += i
    }
    return ans
}
func abs(x int64) int64 {
    if x < 0 {
        return 0 - x
    }
    return x
}
func min(x, y int64) int64 {
    if x < y {
        return x
    }
    return y
}

package main

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

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

	for test := parseInt(getString(reader)); test > 0; test-- {
		n := parseInt(getString(reader))
		A := make([]int, n)
		for i := 0; i < (n / 2); i++ {
			A[2*i] = 2 * (i + 1)
			A[2*i+1] = 2*i + 1
		}
		if n%2 == 1 {
			A[n-2] = n
			A[n-1] = n - 2
		}
		writer.WriteString(fmt.Sprint(A)[1:2*n] + "\n")
	}
	writer.Flush()
}

func parseInt(str string) int {
	var res int
	size := len(str)
	for i := 0; i < size; i++ {
		digit := int(str[i] - '0')
		for j := (i + 1); j < size; j++ {
			digit = digit<<3 + digit<<1
		}
		res += digit
	}
	return res
}

func getString(in *bufio.Reader) string {
	res, _ := in.ReadString('\n')
	res = strings.ReplaceAll(res, "\n", "")
	res = strings.ReplaceAll(res, "\r", "")
	res = strings.TrimSpace(res)
	return res
}

package main

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

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

func solve(n int) string {
	var x string
	if n%2 == 0 {
		for i := 1; i <= n; i += 2 {
			x += fmt.Sprintf("%d %d ", i+1, i)
		}
	} else {
		x = "2 3 1 "
		for i := 4; i <= n; i += 2 {
			x += fmt.Sprintf("%d %d ", i, i+1)
		}
	}
	return x
}

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

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 n int
		fmt.Fscan(input, &n)
		fmt.Println(n)
		for i := 1; i < n; i++ {
			fmt.Println(i)
		}

	}

}

package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"log"
	"os"
)

func init() {
	log.SetFlags(0)
	log.SetOutput(ioutil.Discard)
}

// func solve(a []int) {
//
// }

func main() {
	log.Println("start")

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

	// num := 0
	// fmt.Fscan(in, &num)
	// for i := 0; i < num; i++ {
	var size int
	fmt.Fscan(in, &size)
	// a := make([]int, size)
	for i := 0; i < size; i++ {
		var num int
		fmt.Fscan(in, &num)
		// log.Printf("num = %#v\n", num)
		fmt.Printf("%d ", num)
		for i := 1; i < num; i++ {
			fmt.Printf("%d ", i)
		}
		fmt.Println()
	}
	// solve(a)
	// }
	log.Println("__end__")
}

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

		solve(n)
		fmt.Println()
	}
}

func solve(n int) {

	if n == 3 {
		fmt.Print(2)
		fmt.Print(" ")
		fmt.Print(3)
		fmt.Print(" ")
		fmt.Print(1)
		fmt.Print(" ")
		return
	}

	if n % 2 == 0 {

		for i := 1; i <= n; i += 2 {
			fmt.Print(i + 1)
			fmt.Print(" ")
			fmt.Print(i)
			fmt.Print(" ")
		}

	} else {
		fmt.Print(2)
		fmt.Print(" ")
		fmt.Print(3)
		fmt.Print(" ")
		fmt.Print(1)
		fmt.Print(" ")

		for i := 4; i <= n; i++ {
			fmt.Print(i + 1)
			fmt.Print(" ")
			fmt.Print(i)
			fmt.Print(" ")
		}
	}
}

//1 2 3 4 5 6 7
//2 3 1 5 4 7 6


You are given n points on a plane. All the points are distinct and no three of them lie on the same line. Find the number of parallelograms with the vertices at the given points.

The first line of the input contains integer n (1 ≤ n ≤ 2000) — the number of points. Each of the next n lines contains two integers (xi, yi) (0 ≤ xi, yi ≤ 109) — the coordinates of the i-th point.

Print the only integer c — the number of parallelograms with the vertices at the given points.

package main

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

var stdin *bufio.Reader
var stdout *bufio.Writer

func init() {
	stdin = bufio.NewReader(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

type Point struct {
	x, y int
}

type Vector struct {
	dx, dy int
}

func main() {
	n, count := 0, 0
	fmt.Fscanf(stdin, "%d\n", &n)

	points := make([]Point, n)
	vectors := make(map[Vector]int)

	for i := 0; i < n; i++ {
		fmt.Fscanf(stdin, "%d%d\n", &points[i].x, &points[i].y)
	}

	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			var vector Vector

			if points[i].x > points[j].x || (points[i].x == points[j].x && points[i].y >= points[j].y) {
				vector = Vector{points[i].x - points[j].x, points[i].y - points[j].y}
			} else {
				vector = Vector{points[j].x - points[i].x, points[j].y - points[i].y}
			}
			count += vectors[vector]
			vectors[vector]++
		}
	}
	fmt.Fprintf(stdout, "%d\n", count / 2)

	stdout.Flush()
}

package main

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

var stdin *bufio.Reader
var stdout *bufio.Writer

func init() {
	stdin = bufio.NewReader(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

type Point struct {
	x, y int
}

type Vector struct {
	dx, dy int
}

func main() {
	n, count := 0, 0
	fmt.Fscanf(stdin, "%d\n", &n)

	points := make([]Point, n)
	vectors := make(map[Vector]int)

	for i := 0; i < n; i++ {
		fmt.Fscanf(stdin, "%d%d\n", &points[i].x, &points[i].y)
	}

	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			var vector Vector

			if points[i].x >= points[j].x {
				vector = Vector{points[i].x - points[j].x, points[i].y - points[j].y}
			} else {
				vector = Vector{points[j].x - points[i].x, points[j].y - points[i].y}
			}
			count += vectors[vector]
			vectors[vector]++
		}
	}
	fmt.Fprintf(stdout, "%d\n", count / 2)

	stdout.Flush()
}


The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test the robot prototype will be placed in cell (x0, y0) of a rectangular squared field of size x × y, after that a mine will be installed into one of the squares of the field. It is supposed to conduct exactly x·y tests, each time a mine is installed into a square that has never been used before. The starting cell of the robot always remains the same.After placing the objects on the field the robot will have to run a sequence of commands given by string s, consisting only of characters 'L', 'R', 'U', 'D'. These commands tell the robot to move one square to the left, to the right, up or down, or stay idle if moving in the given direction is impossible. As soon as the robot fulfills all the sequence of commands, it will blow up due to a bug in the code. But if at some moment of time the robot is at the same square with the mine, it will also blow up, but not due to a bug in the code.Moving to the left decreases coordinate y, and moving to the right increases it. Similarly, moving up decreases the x coordinate, and moving down increases it.The tests can go on for very long, so your task is to predict their results. For each k from 0 to length(s) your task is to find in how many tests the robot will run exactly k commands before it blows up.

The first line of the input contains four integers x, y, x0, y0 (1 ≤ x, y ≤ 500, 1 ≤ x0 ≤ x, 1 ≤ y0 ≤ y) — the sizes of the field and the starting coordinates of the robot. The coordinate axis X is directed downwards and axis Y is directed to the right. The second line contains a sequence of commands s, which should be fulfilled by the robot. It has length from 1 to 100 000 characters and only consists of characters 'L', 'R', 'U', 'D'.

Print the sequence consisting of (length(s) + 1) numbers. On the k-th position, starting with zero, print the number of tests where the robot will run exactly k commands before it blows up.

NoteIn the first sample, if we exclude the probable impact of the mines, the robot's route will look like that: .

package main

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

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

  var numRows, numCols, r0, c0 int
  line, _ := reader.ReadString('\n')
  line = strings.TrimSpace(line)
  fmt.Sscanf(line, "%d%d%d%d", &numRows, &numCols, &r0, &c0)
  dr := []int{ -1, 0, 1, 0 }
  dc := []int{ 0, 1, 0, -1 }
  dirs := map[byte]int{ 'U': 0, 'R': 1, 'D': 2, 'L': 3 }

  s, _ := reader.ReadString('\n')
  s = strings.TrimSpace(s)
  numMoves := len(s)
  explodeTime := make([]int, numMoves + 1)
  cellExploded := make([][]bool, numRows + 1)
  for r := 0; r <= numRows; r++ {
    cellExploded[r] = make([]bool, numCols + 1)
  }
  cellExploded[r0][c0] = true
  explodeTime[0] = 1
  testsLeft := numRows * numCols - 1

  r, c := r0, c0
  for i := 0; i < numMoves; i++ {
    dir := dirs[s[i]]
    R, C := r + dr[dir], c + dc[dir]
    if R < 1 || R > numRows || C < 1 || C > numCols {
      continue
    }
    r, c = R, C
    if !cellExploded[r][c] {
      cellExploded[r][c] = true
      explodeTime[i + 1] = 1
      testsLeft--
    }
  }
  explodeTime[numMoves] += testsLeft

  writer.WriteString(fmt.Sprintf("%d", explodeTime[0]))
  for i := 1; i <= numMoves; i++ {
    writer.WriteString(fmt.Sprintf(" %d", explodeTime[i]))
  }
  writer.WriteString("\n")
}

package main

import "fmt"

func main(){
	var x int
	var y int
	var x0 int
	var y0 int
	var com []byte
	var visited int
	fmt.Scanf("%d %d %d %d ",&x,&y,&x0,&y0)
	map_ := make([][]bool,x + 1)
	for i_,_ := range map_{
		map_[i_] = make([]bool,y + 1)
	}
	fmt.Scanf("%s",&com)
	fmt.Print("1 ")
	visited = 1
	map_[x0][y0] = true
	for i := 0;i < len(com);i++{
		if i == len(com) - 1{
			fmt.Print(x * y - visited)
			break
		}
		switch com[i]{
			case 'U':
			if(x0 > 1){
				x0--
				if map_[x0][y0] == false{
					visited++
					map_[x0][y0] = true
					fmt.Print("1 ")
				}else {
					fmt.Print("0 ")
				}
			}else {
				fmt.Print("0 ")
			}
			case 'D':
			if(x0 < x){
				x0++
				if map_[x0][y0] == false{
					visited++
					map_[x0][y0] = true
					fmt.Print("1 ")
				}else {
					fmt.Print("0 ")
				}
			}else {
				fmt.Print("0 ")
			}
			case 'L':
			if(y0 > 1){
				y0--
				if map_[x0][y0] == false{
					visited++
					map_[x0][y0] = true
					fmt.Print("1 ")
				}else {
					fmt.Print("0 ")
				}
			}else {
				fmt.Print("0 ")
			}
			case 'R':
			if(y0 < y){
				y0++
				if map_[x0][y0] == false{
					visited++
					map_[x0][y0] = true
					fmt.Print("1 ")
				}else {
					fmt.Print("0 ")
				}
			}else {
				fmt.Print("0 ")
			}
		}
	}
}

package main

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

type Dxy struct {
	x, y int
}

var dir map[uint8]Dxy

func initDirMap() {
	dir = make(map[uint8]Dxy)
	dir['L'] = Dxy {
		0, -1,
	}
	dir['R'] = Dxy {
		0, 1,
	}
	dir['U'] = Dxy {
		-1, 0,
	}
	dir['D'] = Dxy {
		1, 0,
	}
}
var mat [500][500] int

func main() {
	initDirMap()

	stdin := bufio.NewReader(os.Stdin)

	var n, m, x0, y0 int
	fmt.Fscanf(stdin, "%d%d%d%d\n", &n, &m, &x0, &y0)

	x0 = x0 - 1
	y0 = y0 - 1

	var cmd string
	fmt.Fscanf(stdin, "%s\n", &cmd)

	cnt := 0
	for i := 0; i < len(cmd); i++ {
		// fmt.Println("")
		// fmt.Println(x0, y0)
		if mat[x0][y0] == 0 {
			fmt.Printf("1 ")
			cnt = cnt + 1
			mat[x0][y0] = 1
		} else {
			fmt.Printf("0 ")
		}

		dxy := dir[cmd[i]]

		x1 := x0 + dxy.x
		y1 := y0 + dxy.y

		// if is valid
		if x1 >=0 && x1 < n && y1 >= 0 && y1 < m {
			x0 = x1
			y0 = y1
		}

	}
	fmt.Println(n * m - cnt)

}

package main

import "fmt"

func main(){
	var x int
	var y int
	var x0 int
	var y0 int
	var com []byte
	var visited int
	fmt.Scanf("%d %d %d %d ",&x,&y,&x0,&y0)
	fmt.Scanf("%s",&com)
	fmt.Print("1 ")
	visited = 1
	for i := 0;i < len(com);i++{
		if i == len(com) - 1{
			fmt.Print(x * y - visited)
			break
		}
		switch com[i]{
			case 'U':
			if(x0 > 1){
				visited++
				x0--
				fmt.Print("1 ")
			}else {
				fmt.Print("0 ")
			}
			case 'D':
			if(x0 < x){
				visited++
				x0++
				fmt.Print("1 ")
			}else {
				fmt.Print("0 ")
			}
			case 'L':
			if(y0 > 1){
				visited++
				y0--
				fmt.Print("1 ")
			}else {
				fmt.Print("0 ")
			}
			case 'R':
			if(y0 < y){
				visited++
				y0++
				fmt.Print("1 ")
			}else {
				fmt.Print("0 ")
			}
		}
	}
}


You have array a1, a2, ..., an. Segment [l, r] (1 ≤ l ≤ r ≤ n) is good if ai = ai - 1 + ai - 2, for all i (l + 2 ≤ i ≤ r).Let's define len([l, r]) = r - l + 1, len([l, r]) is the length of the segment [l, r]. Segment [l1, r1], is longer than segment [l2, r2], if len([l1, r1]) > len([l2, r2]).Your task is to find a good segment of the maximum length in array a. Note that a segment of length 1 or 2 is always good.

The first line contains a single integer n (1 ≤ n ≤ 105) — the number of elements in the array. The second line contains integers: a1, a2, ..., an (0 ≤ ai ≤ 109).

Print the length of the longest good segment in array a.

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

func main() {
	var n,i int
	as,l:=2,2
	fmt.Scan(&n)
	a:=make([]int,200005)
	input:= bufio.NewScanner(os.Stdin)
	input.Split(bufio.ScanWords)
	if n==1 {
		as=1
	}
	for i=1;i<=n;i++ {
		input.Scan()
		aa,_:= strconv.Atoi(input.Text())
		a[i]=aa
		//fmt.Scan(&a[i])
	}
	for i=3;i<=n;i++ {
		if a[i]==(a[i-1]+a[i-2]) {
			l++
		}
		if a[i]!=(a[i-1]+a[i-2]) {
			l=2
		}
		if l>as {
				as=l
		}
	}
	fmt.Println(as)
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    var n int
    fmt.Scan(&n)
    a, ans, cnt := make([]int,n), 0, 0
    for i := 0; i < n; i++ {
        scanner.Scan()
        a[i], _ = strconv.Atoi(scanner.Text())
        if (i >= 2) {
            if a[i] == (a[i-1]+a[i-2]) {
                cnt++
            } else {
                if ans < cnt { ans = cnt }
                cnt = 0
            }
        }
    }
    if ans < cnt { ans = cnt }
    if ans == 0 {
        if n == 1 { fmt.Println(1) } else { fmt.Println(2) }
    } else {
        fmt.Println(ans+2)
    }
}

package main
import (
    "fmt"
    "bufio"
    "os"
)
func get_max(a, b int) int {
    if a > b { return a }
    return b
}

func main() {
    var n, ans int
    var _a [110000]int
    bin := bufio.NewReader(os.Stdin)
    fmt.Fscan(bin, &n)
    for i := 0; i < n;i++ {
        fmt.Fscan(bin, &_a[i])
    }
    a := _a[:n]
    var p int

    for i := 0; i < n; i++ {
        if i < 2 {
            p = i + 1
        } else if a[i] == a[i - 1] + a[i - 2] {
            p = p + 1
        } else {
            p = 2
        }
        ans = get_max(ans, p)
    }
    fmt.Printf("%d\n", ans)
}

package main

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

type Scanner struct {
	r            io.Reader
	split        bufio.SplitFunc
	maxTokenSize int
	token, buf   []byte
	start, end   int
}

func NewScanner(r io.Reader) *Scanner {
	return &Scanner{
		r:            r,
		split:        bufio.ScanWords,
		maxTokenSize: 16777216,
		buf:          make([]byte, 4096),
	}
}

func (s *Scanner) advance(n int) bool {
	if n < 0 || n > s.end-s.start {
		return false
	}
	s.start += n
	return true
}

func (s *Scanner) Text() string {
	return string(s.token)
}

func (s *Scanner) Scan() bool {
	for {
		if s.end > s.start {
			advance, token, err := s.split(s.buf[s.start:s.end], false)
			if err != nil || !s.advance(advance) {
				return false
			}
			s.token = token
			if token != nil {
				return true
			}
		}
		if s.start > 0 && (s.end == len(s.buf) || s.start > len(s.buf)/2) {
			copy(s.buf, s.buf[s.start:s.end])
			s.end -= s.start
			s.start = 0
		}
		if s.end == len(s.buf) {
			if len(s.buf) >= s.maxTokenSize {
				return false
			}
			newSize := len(s.buf) * 2
			if newSize > s.maxTokenSize {
				newSize = s.maxTokenSize
			}
			newBuf := make([]byte, newSize)
			copy(newBuf, s.buf[s.start:s.end])
			s.buf = newBuf
			s.end -= s.start
			s.start = 0
			continue
		}
		for loop := 0; ; {
			n, _ := s.r.Read(s.buf[s.end:len(s.buf)])
			s.end += n
			if n > 0 {
				break
			}
			loop++
			if loop > 100 {
				break
			}
		}
	}
}

func (s *Scanner) Split(split bufio.SplitFunc) {
	s.split = split
}

var w *bufio.Writer = bufio.NewWriter(os.Stdout)
var sc *Scanner = NewScanner(os.Stdin)

func next() string { sc.Scan(); return sc.Text() }

func ni32() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func ni64() int64 {
	sc.Scan()
	n, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return n
}

func pri32(i ...int) {
	for _, ii := range i {
		w.WriteString(strconv.Itoa(ii))
		sp()
	}
}
func pri64(i ...int64) {
	for _, ii := range i {
		w.WriteString(strconv.FormatInt(ii, 10))
		sp()
	}
}
func sp()   { w.WriteByte(' ') }
func endl() { w.WriteByte('\n') }

func min(i, j int) int {
	if i < j {
		return i
	}
	return j
}

func max(i, j int) int {
	if i > j {
		return i
	}
	return j
}

func main() {
	defer w.Flush()
	n := ni32()
	a1, a2, a3 := 0, 0, 0
	cur, ans := 0, min(2, n)
	for i := 0; i < n; i++ {
		a1, a2, a3 = a2, a3, ni32()
		if i >= 2 {
			if a3 == a1+a2 {
				if cur == 0 {
					cur = 3
				} else {
					cur++
				}
				ans = max(ans, cur)
			} else {
				cur = 0
			}
		}
	}
	pri32(ans)
}

// 365B-mic
package main

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

func main() {
    w := bufio.NewScanner(os.Stdin)
    w.Split(bufio.ScanWords)
    var n, a, b, cou int
    var x float64
    fmt.Scan(&n)
    if n <= 2 {
        fmt.Println(n)
        return
    }
    cou = 2
    fmt.Scan(&a, &b)
    d := make([]int, n)
    for i := 2; i < n; i++ {
        w.Scan()
        s, _ := strconv.Atoi(w.Text())
        d[i] = s
    }
    for i := 2; i < n; i++ {
        if d[i] == a+b {
            cou++
        } else {
            x = math.Max(float64(x), float64(cou))
            cou = 2
        }
        a = b
        b = d[i]
    }
    x = math.Max(float64(x), float64(cou))
    fmt.Println(x)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	if n == 1 || n == 2 {
		fmt.Println(n)
		return
	}
	A := make([]int, n)

	var j int
	for i := 0; i < n-1; i++ {
		fmt.Scan(&j)
		A[i] = j
	}
	fmt.Scan(&j)
	A[n-1] = j

	l, r, max := 0, 1, 2
	for r < n-1 {
		if A[r-1] + A[r] == A[r+1] {
			r++
			if r-l+1 > max {
				max = r-l+1
			}
		} else {
			l, r = r, r+1
		}
	}
	fmt.Println(max)
}

package main

import "fmt"

func main() {
    var n int
    var (
        cur uint64
        fst, snd uint64
        cnt, maxcnt int = 2, 2
    )

    fmt.Scan(&n)
    if n < 2 {
        fmt.Println(1)
    } else {
        fmt.Scan(&fst, &snd)

        for i := 2; i<n; i++ {
            fmt.Scan(&cur)
            if cur == fst + snd {
                cnt++
            } else {
                if cnt > maxcnt {
                    maxcnt = cnt
                }
                cnt = 2
            }
            fst = snd
            snd = cur
        }

        if cnt > maxcnt {
            maxcnt = cnt
        }

        fmt.Println(maxcnt)
    }
}

package main

import (
	"fmt"
)

func main() {
	var n,k int
	var s string
	var c [10]int

	fmt.Scan(&n,&k)
	t:=0
	for i:=0;i<n;i++ {
		fmt.Scan(&s)
		b:=1
		for j:=0;j<10;j++ {
			c[j]=0
		}
		for k:=0;k<len(s);k++ {
			c[s[k]-'0']=1
		}
		for j:=0;j<=k;j++ {
			if c[j]==0 {
				b=0
				break
			}
		}
		t+=b
	}
	fmt.Println(t)
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    var n int
    fmt.Scan(&n)
    a, ans, cnt := make([]int,n), 0, 0
    for i := 0; i < n; i++ {
        scanner.Scan()
        a[i], _ = strconv.Atoi(scanner.Text())
        if (i >= 2) {
            if a[i] == (a[i-1]+a[i-2]) {
                cnt++
            } else {
                if ans < cnt { ans = cnt }
                cnt = 0
            }
        }
    }
    if ans < cnt { ans = cnt }
    fmt.Println(ans+2)
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    var n int
    fmt.Scan(&n)
    a, ans, cnt := make([]int,n), 0, 0
    for i := 0; i < n; i++ {
        scanner.Scan()
        a[i], _ = strconv.Atoi(scanner.Text())
        if (i >= 2) {
            if a[i] == (a[i-1]+a[i-2]) {
                cnt++
            } else {
                if ans < cnt { ans = cnt }
                cnt = 0
            }
        }
    }
    if ans < cnt { ans = cnt }
    if ans == 0 {
        fmt.Println(1)
    } else {
        fmt.Println(ans+2)
    }
}

package main
import (
    "fmt"
    "bufio"
    "os"
)
func get_max(a, b int) int {
    if a > b { return a }
    return b
}

func main() {
    var n, ans int
    var _a [110000]int
    bin := bufio.NewReader(os.Stdin)
    fmt.Fscan(bin, &n)
    for i := 0; i < n;i++ {
        fmt.Fscan(bin, &_a[i])
    }
    a := _a[:n]
    var p int

    for i := 0; i < n; i++ {
        if i < 2 {
            p = i + 1
        } else if a[i] == a[i - 1] + a[i - 2] {
            p = p + 1
        } else {
            p = 0
        }
        ans = get_max(ans, p)
    }
    fmt.Printf("%d\n", ans)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	if n == 1 || n == 2 {
		fmt.Println(n)
	}
	A := make([]int, n)

	var j int
	for i := 0; i < n-1; i++ {
		fmt.Scan(&j)
		A[i] = j
	}
	fmt.Scan(&j)
	A[n-1] = j

	l, r, max := 0, 1, 2
	for r < n-1 {
		if A[r-1] + A[r] == A[r+1] {
			r++
			if r-l+1 > max {
				max = r-l+1
			}
		} else {
			l, r = r, r+1
		}
	}
	fmt.Println(max)
}

package main

import "fmt"

func main() {
    var n int
    var (
        cur int
        fst, snd int
        cnt int = 2
    )

    fmt.Scan(&n)
    fmt.Scan(&fst, &snd)

    for i := 2; i<n; i++ {
        fmt.Scan(&cur)
        if cur == fst + snd {
            cnt++
        } else {
            cnt = 2
        }
        fst = snd
        snd = cur
    }

    fmt.Println(cnt)
}

package main

import "fmt"

func main() {
    var n int
    var (
        cur uint64
        fst, snd uint64
        cnt int = 2
    )

    fmt.Scan(&n)
    if n < 2 {
        fmt.Println(1)
    } else {
        fmt.Scan(&fst, &snd)

        for i := 2; i<n; i++ {
            fmt.Scan(&cur)
            if cur == fst + snd {
                cnt++
            } else {
                cnt = 2
            }
            fst = snd
            snd = cur
        }

        fmt.Println(cnt)
    }
}

package main

import "fmt"

func main() {
    var n int
    var (
        cur uint64
        fst, snd uint64
        cnt, maxcnt int = 2, 2
    )

    fmt.Scan(&n)
    if n < 2 {
        fmt.Println(1)
    } else {
        fmt.Scan(&fst, &snd)

        for i := 2; i<n; i++ {
            fmt.Scan(&cur)
            if cur == fst + snd {
                cnt++
            } else {
                if cnt > maxcnt {
                    maxcnt = cnt
                }
                cnt = 2
            }
            fst = snd
            snd = cur
        }

        fmt.Println(maxcnt)
    }
}

package main

import "fmt"

func main() {
    var n int
    var (
        cur int
        fst, snd int
        cnt int = 2
    )

    fmt.Scan(&n)
    if n < 2 {
        fmt.Println(1)
    } else {
        fmt.Scan(&fst, &snd)

        for i := 2; i<n; i++ {
            fmt.Scan(&cur)
            if cur == fst + snd {
                cnt++
            } else {
                cnt = 2
            }
            fst = snd
            snd = cur
        }

        fmt.Println(cnt)
    }
}

package main
import (
	"fmt"
	//"bufio"
	//"os"
	//"strconv"
)

func main() {
	var n,i int
	as,l:=2,2
	fmt.Scan(&n)
	a:=make([]int,200005)
	if n==1 {
		as=1
	}
	for i=1;i<=n;i++ {
		fmt.Scan(&a[i])
	}
	for i=3;i<=n;i++ {
		if a[i]==(a[i-1]+a[i-2]) {
			l++
		}
		if a[i]!=(a[i-1]+a[i-2]) {
			l=2
		}
	}
	if l>as {
		as=l
	}
	fmt.Println(as)
}


Sayaka Saeki is a member of the student council, which has $$$n$$$ other members (excluding Sayaka). The $$$i$$$-th member has a height of $$$a_i$$$ millimeters.It's the end of the school year and Sayaka wants to take a picture of all other members of the student council. Being the hard-working and perfectionist girl as she is, she wants to arrange all the members in a line such that the amount of photogenic consecutive pairs of members is as large as possible.A pair of two consecutive members $$$u$$$ and $$$v$$$ on a line is considered photogenic if their average height is an integer, i.e. $$$\frac{a_u + a_v}{2}$$$ is an integer.Help Sayaka arrange the other members to maximize the number of photogenic consecutive pairs.

The first line contains a single integer $$$t$$$ ($$$1\le t\le 500$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2000$$$)  — the number of other council members. The second line of each test case contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$)  — the heights of each of the other members in millimeters. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$.

For each test case, output on one line $$$n$$$ integers representing the heights of the other members in the order, which gives the largest number of photogenic consecutive pairs. If there are multiple such orders, output any of them.

NoteIn the first test case, there is one photogenic pair: $$$(1, 1)$$$ is photogenic, as $$$\frac{1+1}{2}=1$$$ is integer, while $$$(1, 2)$$$ isn't, as $$$\frac{1+2}{2}=1.5$$$ isn't integer.In the second test case, both pairs are photogenic.

package main

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

func CF1509A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, N, A int
	for fmt.Fscan(in, &T); T > 0; T-- {
		nums := make([]int, 0)
		for fmt.Fscan(in, &N); N > 0; N-- {
			fmt.Fscan(in, &A)
			nums = append(nums, A)
		}
		for _, v := range nums {
			if v%2 == 1 {
				fmt.Fprint(out, v, " ")
			}
		}
		for _, v := range nums {
			if v%2 == 0 {
				fmt.Fprint(out, v, " ")
			}
		}
		fmt.Fprintln(out)
	}
}

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

package main

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

func CF1509A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, N, A int
	for fmt.Fscan(in, &T); T > 0; T-- {
		nums := []int{}
		for fmt.Fscan(in, &N); N > 0; N-- {
			fmt.Fscan(in, &A)
			nums = append(nums, A)
		}
		for _, v := range nums {
			if v%2 == 1 {
				fmt.Fprint(out, v, " ")
			}
		}
		for _, v := range nums {
			if v%2 == 0 {
				fmt.Fprint(out, v, " ")
			}
		}
		fmt.Fprintln(out)
	}
}

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

package main

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

func CF1509A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, N, A int
	for fmt.Fscan(in, &T); T > 0; T-- {
		odds, evens := []int{}, []int{}
		for fmt.Fscan(in, &N); N > 0; N-- {
			fmt.Fscan(in, &A)
			if A&1 == 0 {
				evens = append(evens, A)
			} else {
				odds = append(odds, A)
			}
		}
		for i := 0; i < len(odds); i++ {
			fmt.Fprint(out, odds[i], " ")
		}
		for i := 0; i < len(evens); i++ {
			fmt.Fprint(out, evens[i], " ")
		}
		fmt.Fprintln(out)
	}
}

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

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		var odds []int
		var evens []int
		for j:=0;j<n;j++{
			var x int
			fmt.Fscan(in,&x)
			if x%2 != 0 {
				odds = append(odds,x)
			} else {
				evens = append(evens,x)
			}
		}
		odds = append(odds,evens...)
		for j:=0;j<len(odds);j++{
			fmt.Fprintf(out,"%v ",odds[j])
		}
		fmt.Fprintln(out,)
	}
}

package main

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

const REPEAT bool = true
const CASE   bool = false

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

  if REPEAT {
    var t int
    Fscan(in, &t);
    for i := 1; i <= t; i++ {
      if CASE {
        Fprintf(out, "Case #%d: ", i)
      }
      solve(in, out)
    }
  } else {
    solve(in, out)
  }
}

func solve(in io.Reader, out io.Writer) {
  var n int
  Fscan(in, &n)
  arr := make([]int, n)
  for i := range arr {
    Fscan(in, &arr[i])
  }
  for i := range arr {
    if arr[i] % 2 == 0 {
      Fprint(out, arr[i], " ")
    }
  }
  for i := range arr {
    if arr[i] % 2 != 0 {
      Fprint(out, arr[i], " ")
    }
  }
  Fprintln(out)
}

package main

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

const maxN = 10023

func main() {
  in := bufio.NewReader(os.Stdin)
  out := bufio.NewWriter(os.Stdout)
  defer out.Flush()
  var tt int
  fmt.Fscan(in, &tt)
  for tc := 1; tc <= tt; tc++ {
    var n, xs, ys, a int
    var x[maxN] int
    var y[maxN] int
    fmt.Fscan(in, &n)
    xs = 0
    ys = 0
    for i := 0; i < n; i++ {
      fmt.Fscan(in, &a)
      if a % 2 == 0 {
        y[ys] = a
        ys++
      }else {
        x[xs] = a
        xs++
      }
    }
    for i := 0; i < xs; i++ {
      fmt.Fprintf(out, "%d ", x[i])
    }
    for i := 0; i < ys; i++ {
      fmt.Fprintf(out, "%d ", y[i])
    }
    fmt.Fprint(out, "\n")
  }
}

package main

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

const maxN = 10023

func main() {
  in := bufio.NewReader(os.Stdin)
  out := bufio.NewWriter(os.Stdout)
  defer out.Flush()
  var tt int
  fmt.Fscan(in, &tt)
  for tc := 1; tc <= tt; tc++ {
    var n, xs, ys, a int
    var x[maxN] int
    var y[maxN] int
    fmt.Fscan(in, &n)
    xs = 0
    ys = 0
    for i := 0; i < n; i++ {
      fmt.Fscan(in, &a)
      if a % 2 == 0 {
        y[ys] = a
        ys++
      }else {
        x[xs] = a
        xs++
      }
    }
    for i := 0; i < xs; i++ {
      fmt.Fprintf(out, "%d ", x[i])
    }
    for i := 0; i < ys; i++ {
      fmt.Fprintf(out, "%d ", y[i])
    }
    fmt.Fprintln(out)
  }
}

package main

import ."fmt"
func main(){
    var t,n,x int
    for Scan(&t) ; t>0 ; t-- {
        a := [2][]interface{}{}
        for Scan(&n) ; n>0 ; n-- {
            Scan(&x)
            a[x&1]=append(a[x&1],x)
        }
        Println(a[0]...)
        Println(a[1]...)
    }
}

package main
import ."fmt"

// github.com/EndlessCheng/codeforces-go
func main() {
	var T, n, v int
	for Scan(&T); T > 0; T-- {
		a := [2][]interface{}{}
		for Scan(&n); n > 0; n-- {
			Scan(&v)
			a[v&1] = append(a[v&1], v)
		}
		Println(a[0]...)
		Println(a[1]...)
	}
}

package main

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

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

	var T, n, v int
	for Fscan(in, &T); T > 0; T-- {
		a := [2][]interface{}{}
		for Fscan(in, &n); n > 0; n-- {
			Fscan(in, &v)
			a[v&1] = append(a[v&1], v)
		}
		Fprintln(out, a[0]...)
		Fprintln(out, a[1]...)
	}
}

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

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n := 0, 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		o := make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &o[j])
		}
		p := []int{}
		for j := 0; j < n; j++ {
			if o[j]&1 == 0 {
				p = append(p, o[j])
			} else {
				fmt.Fprint(w, o[j], " ")
			}
		}
		for _, v := range p {
			fmt.Fprint(w, v, " ")
		}
		fmt.Fprintln(w, "")
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

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

func solve(n int, a []int) string {
	var x string
	for _, v := range a {
		if v%2 == 0 {
			x += fmt.Sprintf("%d ", v)
		}
	}
	for _, v := range a {
		if v%2 == 1 {
			x += fmt.Sprintf("%d ", v)
		}
	}
	return x
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		fmt.Println(solve(n, a))
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var T, N, a int
	Fscan(in, &T)
	for t := 0; t < T; t++ {
		Fscan(in, &N)
		es := make([]int, 0)
		os := make([]int, 0)
		for n := 0; n < N; n++ {
			Fscan(in, &a)
			if a%2 == 0 {
				es = append(es, a)
			} else {
				os = append(os, a)
			}
		}
		for _, e := range es {
			Fprint(out, e, " ")
		}
		for _, o := range os {
			Fprint(out, o, " ")
		}
		Fprintln(out)
	}
}

package main

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

var bytes []byte

func nextByte() byte {
	b := bytes[0]
	bytes = bytes[1:]
	return b
}

func ScanInt64() int64 {
	var negative bool
	var result int64

	b := nextByte()

	for ; b < '0' || b > '9'; b = nextByte() {
		if b == '-' {
			negative = true
		}
	}

	for ; '0' <= b && b <= '9'; b = nextByte() {
		result = (result << 3) + (result << 1) + int64(b-'0')
	}

	if negative {
		return -result
	} else {
		return result
	}
}

func ScanInt() int {
	return int(ScanInt64())
}

func ScanString() string {
	builder := strings.Builder{}

	for b := nextByte(); b != '\r'; b = nextByte() {
		if b != '\n' {
			builder.WriteByte(b)
		}
	}

	return builder.String()
}

func init() {
	f, err := os.Open("in.txt")

	if err == nil {
		defer f.Close()
	} else {
		f = os.Stdin
	}

	bytes, _ = ioutil.ReadAll(bufio.NewReader(f))
}

func main() {
	for t := ScanInt(); t > 0; t-- {
		n := ScanInt()
		a := make([]int, n)

		for i := range a {
			a[i] = ScanInt()
		}

		for i, j := 0, n-1; i < j; {
			for i < n && a[i]%2 == 0 {
				i++
			}

			for j >= 0 && a[j]%2 == 1 {
				j--
			}

			if i < j {
				a[i], a[j] = a[j], a[i]
			}
		}

		fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
	}
}

package main

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

type CF1509 struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1509) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1509) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1509) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1509) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1509) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
 Run solve the problem CF1509
 Date: 17/04/21
 User: pepradere
 URL: https://codeforces.com/contest/1509/problem/A
 Problem: CF1509
**/
func (in *CF1509) Run() {
	T := in.NextInt()
	for ; T > 0; T-- {
		N := in.NextInt()
		var even []int
		var odd []int
		for ; N > 0; N-- {
			num := in.NextInt()
			if num %2 == 0{
				even = append(even, num )
			} else {
				odd = append(odd, num)
			}
		}
		var sol []int
		if len(even) > len(odd) {
			sol = append(sol, even...)
			sol = append(sol, odd...)
		} else {
			sol = append(sol, odd...)
			sol = append(sol, even...)
		}

		for i := 0; i < len(sol); i++ {
			if i > 0 {
				fmt.Print(" ")
			}
			fmt.Print(sol[i])
		}
		fmt.Println()
	}

}

func NewCF1509(r *bufio.Reader) *CF1509 {
	return &CF1509{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1509(bufio.NewReader(os.Stdin)).Run()
}

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

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

}

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

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

	for o := 0; o < t; o++ {
		var n int
		fmt.Fscan(input, &n)
		EVEN := make([]int, 0)
		ODD := make([]int, 0)
		for i := 0; i < n; i++ {
			var q int
			fmt.Fscan(input, &q)
			if q%2 == 0 {
				EVEN = append(EVEN, q)
			} else {
				ODD = append(ODD, q)
			}

		}
		t := len(EVEN)
		tt := len(ODD)
		for i := 0; i < t; i++ {
			fmt.Println(EVEN[i])
		}
		for i := 0; i < tt; i++ {
			fmt.Println(ODD[i])
		}

	}
}

package main

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

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

func Scan(a ...interface{})    { fmt.Fscan(reader, a...) }
func Scanln(a ...interface{})  { fmt.Fscanln(reader, a...) }
func Print(a ...interface{})   { fmt.Fprint(writer, a...) }
func Println(a ...interface{}) { fmt.Fprintln(writer, a...) }

func main() {
	defer writer.Flush()
	var t int
	Scanln(&t)
	for ; t > 0; t-- {
		var n int
		Scanln(&n)
		odd := make([]int, 0)
		even := make([]int, 0)
		for i := 0; i < n; i++ {
			var a int
			Scan(&a)
			if a%2 == 1 {
				odd = append(odd, a)
			} else {
				even = append(even, a)
			}
		}
		Scanln()
		for _, v := range odd {
			Print(v, " ")
		}
		for _, v := range even {
			Print(v, " ")
		}
		Println()
	}

}

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 int

		fmt.Fscan(r, &n)

		h := make([]int, n)

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

		ans := solve(h)

		for j := 0; j < len(ans); j++ {
			fmt.Print(ans[j])
			fmt.Print(" ")
		}
		fmt.Println()
	}
}

func solve(h []int) []int {
	var even []int
	var odd []int

	var ans []int

	for i := 0; i < len(h); i++ {
		if h[i]  % 2 == 0 {
			even = append(even, h[i])
		} else {
			odd = append(odd, h[i])
		}
	}
	for j := 0; j < len(even); j++ {
		ans = append(ans, even[j])
	}

	for j := 0; j < len(odd); j++ {
		ans = append(ans, odd[j])
	}

	return ans
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		var odds []int
		var evens []int
		for j:=0;j<n;j++{
			var x int
			fmt.Fscan(in,&x)
			if x%2 != 0 {
				odds = append(odds,x)
			} else {
				evens = append(evens,x)
			}
		}
		odds = append(odds,evens...)
		fmt.Fprintln(out,odds)
	}
}

package main

import ."fmt"
func main(){
    var t,n,x int
    for Scanf("%d",&t) ; t>0 ; t-- {
        a := [2][]interface{}{}
        for Scanf("%d",&n) ; n>0 ; n-- {
            Scanf("%d",&x)
            a[x&1]=append(a[x&1],x)
        }
        Println(a[0]...)
        Println(a[1]...)
    }
}