package main

import "fmt"

func main() {

	var n, k int

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

	k = 1
	var X []int
	lens := make([]int, n+1)
	length := 0

	for ; k < n + 1; k++ {
		X = make([]int, k)
		for num := 0; num < k; num++ {

			X[num] = A[num + 1] - A[num]
		}

		anotherFlag := false
		for num := k; num < n; num++ {
			if X[num % k] != A[num+1]  - A[num] {
				anotherFlag = true
				break
			}
		}

		if !anotherFlag {
			length++
			lens[length-1] = k
		}
	}

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

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n+1)
	for i := range a[1:] {
		fmt.Scan(&a[i+1])
	}

	var ans []int
	for k := 1; k <= n; k++ {
		x := make([]int, k)
		for i := range x {
			x[i] = a[i+1] - a[i]
		}
		good := true
		for i := range a[1:] {
			if a[i+1]-a[i] != x[i%k] {
				good = false
				break
			}
		}
		if good {
			ans = append(ans, k)
		}
	}

	fmt.Println(len(ans))
	for i := range ans {
		if i == len(ans)-1 {
			fmt.Println(ans[i])
		} else {
			fmt.Print(ans[i], " ")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var N int
	var A [1010]int

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

	var diff [1010]int
	diff[0] = A[0]
	for i := 0; i < N-1; i++ {
		diff[i+1] = A[i+1] - A[i]
	}

	var res []int
	for i := 1; i <= N; i++ {
		ok := true
		for j, k := 0, i; ok && k < N; {
			if diff[j] != diff[k] {
				ok = false
			}

			j++
			k++
		}

		if ok {
			res = append(res, i)
		}
	}

	fmt.Printf("%v\n", len(res))
	for i := 0; i < len(res); i++ {
		if i > 0 {
			fmt.Printf(" ")
		}
		fmt.Printf("%v", res[i])
	}
	fmt.Printf("\n")
}

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)
	a := [1111]int{}
	for i := 1; i <= n; i++ {
		scanf("%d ", &a[i])
	}
	x := make([]int, n)
	ans := make([]int, 0)
	aa := make([]int, n+1)
	for j := 1; j <= n; j++ {
		x[j-1] = a[j] - a[j-1]
	}
	for i := 1; i <= n; i++ {

		flag := true

		for j := 1; j <= n; j++ {
			aa[j] = x[(j-1)%i] + aa[j-1]
			if aa[j] != a[j] {
				flag = false
				break
			}
		}

		if flag {
			ans = append(ans, i)
		}
	}
	printf("%d\n", len(ans))
	for i := 0; i < len(ans); i++ {
		printf("%d ", ans[i])
	}
}

package main

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

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextInt()
	A := io.NextIntArrayOffset(N, 1)

	var ans []int
	for k := 1; k <= N; k++ {
		if check(A, k) {
			ans = append(ans, k)
		}
	}
	io.Println(len(ans))
	for _, v := range ans {
		io.Printf("%d ", v)
	}
	io.Println()
}

func check(A []int, k int) bool {
	for i := 0; i+1 < len(A); i++ {
		d := A[i+1] - A[i]
		for j := i; j+1 < len(A); j += k {
			if A[j+1]-A[j] != d {
				return false
			}
		}
	}
	return true
}

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c-'0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c-'0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

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

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}


package main

import (
	"fmt"
	"sort"
)

func ReadInt64() int64 {
	var ret int64
	_, err := fmt.Scan(&ret)
	if err != nil {
		return 0
	}
	return ret
}

func ReadString() string {
	var ret string
	cnt, err := fmt.Scanf("%s", ret)
	if cnt != 1 || err != nil {
		fmt.Printf("cnt=%d, err=%s\n", cnt, err)
		return ""
	}
	return ret
}

type pair struct {
	first  int64
	second int64
}

func main() {
	n, k, sum := int64(0), int64(0), int64(0)
	n, k = ReadInt64(), ReadInt64()
	a, b := make([]pair, n), make([]pair, k+1)

	for i := int64(0); i < n; i++ {
		a[i].first = ReadInt64()
		a[i].second = i + 1
	}
	sort.Slice(a, func(i, j int) bool { return a[i].first < a[j].first })
	for i := int64(0); i < k; i++ {
		sum += a[n-i-1].first
	}
	fmt.Printf("%d\n", sum)
	for i := int64(1); i <= k; i++ {
		b[i] = a[n-i]
	}
	sort.Slice(b, func(i, j int) bool { return b[i].second < b[j].second })
	for i := int64(1); i < k; i++ {
		fmt.Printf("%d ", b[i].second-b[i-1].second)
	}
	fmt.Printf("%d\n", n-b[k-1].second)
}

package main

import (
	"fmt"
	"sort"
)

const (
	M = 2e3 + 5
)

type Array struct {
	x int
	idx int
}

type intArray []Array
type intSlice []int

var n, k int

func (s intArray) Len() int { return len(s) }
func (s intArray) Swap(i, j int){
	s[i].idx, s[j].idx = s[j].idx, s[i].idx
	s[i].x, s[j].x = s[j].x, s[i].x
}
func (s intArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func main() {
	var i int
	fmt.Scanf("%d%d\n", &n, &k)
	var a = make([]int, n)
	var b = make([]Array, n)
	for i = 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
		b[i].idx = i
		b[i].x = a[i]
	}
	sort.Sort(intArray(b))
	var ans = make([]int, k)
	var res int = 0

	for i = 0; i < k; i++ {
		ans[i] = b[n - 1 - i].idx
		res += b[n - 1 - i].x
	}
	sort.Sort(intSlice(ans))
	fmt.Println(res)
	if k == 1 {
		fmt.Print(n)
		return
	}
	for i = 0; i < k; i++ {
		if i == 0 {
			fmt.Print(ans[i] + 1, " ")
		} else if i == k - 1{
			fmt.Print(n - ans[i - 1] - 1, " ")
		} else {
			fmt.Print(ans[i] - ans[i - 1], " ")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

func ReadInt64() int64 {
	var ret int64
	cnt, err := fmt.Scanf("%d", &ret)
	if cnt != 1 || err != nil {
		//fmt.Printf("cnt=%d, err=%s\n", cnt, err)
		_, _ =fmt.Scanf("%d", &ret)

		return ret
	}
	return ret
}

func ReadString() string {
	var ret string
	cnt, err := fmt.Scanf("%s", ret)
	if cnt != 1 || err != nil {
		fmt.Printf("cnt=%d, err=%s\n", cnt, err)
		return ""
	}
	return ret
}

type pair struct {
	first  int64
	second int64
}

func main() {
	n, k, sum := int64(0), int64(0), int64(0)
	n, k = ReadInt64(), ReadInt64()
	a, b := make([]pair, n), make([]pair, k+1)

	for i := int64(0); i < n; i++ {
		a[i].first = ReadInt64()
		a[i].second = i + 1
	}
	//fmt.Print(a)
	sort.Slice(a, func(i, j int) bool {
		if a[i].first != a[j].first {
			return a[i].first < a[j].first
		} else {
			return a[i].second < a[j].second
		}
	})

	//fmt.Print(a)
	for i := int64(0); i < k; i++ {
		sum += a[n-i-1].first
	}
	fmt.Printf("%d\n", sum)
	for i := int64(1); i <= k; i++ {
		b[i] = a[n-i]
	}
	//fmt.Print(b)
	sort.Slice(b, func(i, j int) bool { return b[i].second < b[j].second })
	//fmt.Print(b)
	for i := int64(1); i < k; i++ {
		fmt.Printf("%d ", b[i].second-b[i-1].second)
	}
	fmt.Printf("%d\n", n-b[k-1].second)
}

package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"sort"
)

//Item eh um elemento da fila de prioridades
type Item struct {
	value    int
	priority int
	index    int
}

//PriorityQueue implmenta a heap interface
type PriorityQueue []*Item

//Len retorna o tamanho da  pq
func (pq PriorityQueue) Len() int { return len(pq) }

//Less verifica se um tem maior priotidade que o outro
func (pq PriorityQueue) Less(i, j int) bool { return pq[i].priority < pq[j].priority }

//Swap troca os elementos de lugar
func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

//Push insere um elemento na pq
func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

//Pop remove um elemento da pq
func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1 //for safety
	*pq = old[0 : n-1]
	return item
}

//update modifica o valor e a prioridade de um item na fila
func (pq *PriorityQueue) update(item *Item, value int, priority int) {
	item.value = value
	item.priority = priority
	heap.Fix(pq, item.index)
}

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

type pair struct {
	first  interface{}
	second interface{}
}

type intPair struct {
	first  int64
	second int64
}

type vertex struct {
	list []intPair
}

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

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

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

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

var (
	n, k         int
	dificuldades []int
	ordenados    []int
	maiores      = make(map[int]int)
	tabela       [100000]int
	result       []int

	cnt int
)

func main() {
	var num int

	fmt.Scan(&n, &k)

	for i := 0; i < n; i++ {
		fmt.Scan(&num)
		dificuldades = append(dificuldades, num)
		ordenados = append(ordenados, num)
		maiores[num] = 0
	}

	sort.Ints(ordenados)

	for i := n - 1; i >= n-k; i-- {
		maiores[ordenados[i]]++
		cnt += ordenados[i]
	}

	fmt.Println(cnt)

	cnt = 0
	for i := 0; i < n; i++ {
		cnt++
		if maiores[dificuldades[i]] > 0 {
			maiores[dificuldades[i]]--
			for i < n-1 && maiores[dificuldades[i+1]] == 0 {
				cnt++
				i++
			}
			result = append(result, cnt)
			cnt = 0
		}
	}

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

package main

import (
	"fmt"
	"sort"
)

func ReadInt64() int64 {
	var ret int64
	cnt, err := fmt.Scanf("%d", &ret)
	if cnt != 1 || err != nil {
		//fmt.Printf("cnt=%d, err=%s\n", cnt, err)
		return 0
	}
	return ret
}

func ReadString() string {
	var ret string
	cnt, err := fmt.Scanf("%s", ret)
	if cnt != 1 || err != nil {
		fmt.Printf("cnt=%d, err=%s\n", cnt, err)
		return ""
	}
	return ret
}

type pair struct {
	first  int64
	second int64
}

func main() {
	n, k, sum := int64(0), int64(0), int64(0)
	n, k = ReadInt64(), ReadInt64()
	a, b := make([]pair, n), make([]pair, k+1)

	for i := int64(0); i < n; i++ {
		a[i].first = ReadInt64()
		a[i].second = i + 1
	}
	sort.Slice(a, func(i, j int) bool {
		if a[i].first != a[j].first {
			return a[i].first < a[j].first
		} else {
			return a[i].second < a[j].second
		}
	})

	//fmt.Print(a)
	for i := int64(0); i < k; i++ {
		sum += a[n-i-1].first
	}
	fmt.Printf("%d\n", sum)
	for i := int64(1); i <= k; i++ {
		b[i] = a[n-i]
	}
	//fmt.Print(b)
	sort.Slice(b, func(i, j int) bool { return b[i].second < b[j].second })
	//fmt.Print(b)
	for i := int64(1); i < k; i++ {
		fmt.Printf("%d ", b[i].second-b[i-1].second)
	}
	fmt.Printf("%d\n", n-b[k-1].second)
}

package main

import (
	"fmt"
	"sort"
)

func ReadInt64() int64 {
	var ret int64
	cnt, err := fmt.Scanf("%d", &ret)
	if cnt != 1 || err != nil {
		//fmt.Printf("cnt=%d, err=%s\n", cnt, err)
		return 0
	}
	return ret
}

func ReadString() string {
	var ret string
	cnt, err := fmt.Scanf("%s", ret)
	if cnt != 1 || err != nil {
		fmt.Printf("cnt=%d, err=%s\n", cnt, err)
		return ""
	}
	return ret
}

type pair struct {
	first  int64
	second int64
}

func main() {
	n, k, sum := int64(0), int64(0), int64(0)
	n, k = ReadInt64(), ReadInt64()
	a, b := make([]pair, n), make([]pair, k+1)

	for i := int64(0); i < n; i++ {
		a[i].first = ReadInt64()
		a[i].second = i + 1
	}
	fmt.Print(a)
	sort.Slice(a, func(i, j int) bool {
		if a[i].first != a[j].first {
			return a[i].first < a[j].first
		} else {
			return a[i].second < a[j].second
		}
	})

	fmt.Print(a)
	for i := int64(0); i < k; i++ {
		sum += a[n-i-1].first
	}
	fmt.Printf("%d\n", sum)
	for i := int64(1); i <= k; i++ {
		b[i] = a[n-i]
	}
	fmt.Print(b)
	sort.Slice(b, func(i, j int) bool { return b[i].second < b[j].second })
	fmt.Print(b)
	for i := int64(1); i < k; i++ {
		fmt.Printf("%d ", b[i].second-b[i-1].second)
	}
	fmt.Printf("%d\n", n-b[k-1].second)
}

package main

import (
	"fmt"
	"sort"
)

func ReadInt64() int64 {
	var ret int64
	cnt, err := fmt.Scanf("%d", &ret)
	if cnt != 1 || err != nil {
		//fmt.Printf("cnt=%d, err=%s\n", cnt, err)
		return 0
	}
	return ret
}

func ReadString() string {
	var ret string
	cnt, err := fmt.Scanf("%s", ret)
	if cnt != 1 || err != nil {
		fmt.Printf("cnt=%d, err=%s\n", cnt, err)
		return ""
	}
	return ret
}

type pair struct {
	first  int64
	second int64
}

func main() {
	n, k, sum := int64(0), int64(0), int64(0)
	n, k = ReadInt64(), ReadInt64()
	a, b := make([]pair, n), make([]pair, k+1)

	for i := int64(0); i < n; i++ {
		a[i].first = ReadInt64()
		a[i].second = i + 1
	}
	sort.Slice(a, func(i, j int) bool { return a[i].first < a[j].first })
	fmt.Print(a)
	for i := int64(0); i < k; i++ {
		sum += a[n-i-1].first
	}
	fmt.Printf("%d\n", sum)
	for i := int64(1); i <= k; i++ {
		b[i] = a[n-i]
	}
	fmt.Print(b)
	sort.Slice(b, func(i, j int) bool { return b[i].second < b[j].second })
	fmt.Print(b)
	for i := int64(1); i < k; i++ {
		fmt.Printf("%d ", b[i].second-b[i-1].second)
	}
	fmt.Printf("%d\n", n-b[k-1].second)
}

package main

import (
	"fmt"
	"sort"
)

func ReadInt64() int64 {
	var ret int64
	cnt, err := fmt.Scanf("%d", &ret)
	if cnt != 1 || err != nil {
		//fmt.Printf("cnt=%d, err=%s\n", cnt, err)
		_, _ =fmt.Scanf("%d", &ret)

		return 0
	}
	return ret
}

func ReadString() string {
	var ret string
	cnt, err := fmt.Scanf("%s", ret)
	if cnt != 1 || err != nil {
		fmt.Printf("cnt=%d, err=%s\n", cnt, err)
		return ""
	}
	return ret
}

type pair struct {
	first  int64
	second int64
}

func main() {
	n, k, sum := int64(0), int64(0), int64(0)
	n, k = ReadInt64(), ReadInt64()
	a, b := make([]pair, n), make([]pair, k+1)

	for i := int64(0); i < n; i++ {
		a[i].first = ReadInt64()
		a[i].second = i + 1
	}
	fmt.Print(a)
	sort.Slice(a, func(i, j int) bool {
		if a[i].first != a[j].first {
			return a[i].first < a[j].first
		} else {
			return a[i].second < a[j].second
		}
	})

	fmt.Print(a)
	for i := int64(0); i < k; i++ {
		sum += a[n-i-1].first
	}
	fmt.Printf("%d\n", sum)
	for i := int64(1); i <= k; i++ {
		b[i] = a[n-i]
	}
	fmt.Print(b)
	sort.Slice(b, func(i, j int) bool { return b[i].second < b[j].second })
	fmt.Print(b)
	for i := int64(1); i < k; i++ {
		fmt.Printf("%d ", b[i].second-b[i-1].second)
	}
	fmt.Printf("%d\n", n-b[k-1].second)
}

package main

import (
	"fmt"
	"sort"
)

func ReadInt64() int64 {
	var ret int64
	cnt, err := fmt.Scanf("%d", &ret)
	if cnt != 1 || err != nil {
		//fmt.Printf("cnt=%d, err=%s\n", cnt, err)
		_, _ =fmt.Scanf("%d", &ret)

		return ret
	}
	return ret
}

func ReadString() string {
	var ret string
	cnt, err := fmt.Scanf("%s", ret)
	if cnt != 1 || err != nil {
		fmt.Printf("cnt=%d, err=%s\n", cnt, err)
		return ""
	}
	return ret
}

type pair struct {
	first  int64
	second int64
}

func main() {
	n, k, sum := int64(0), int64(0), int64(0)
	n, k = ReadInt64(), ReadInt64()
	a, b := make([]pair, n), make([]pair, k+1)

	for i := int64(0); i < n; i++ {
		a[i].first = ReadInt64()
		a[i].second = i + 1
	}
	fmt.Print(a)
	sort.Slice(a, func(i, j int) bool {
		if a[i].first != a[j].first {
			return a[i].first < a[j].first
		} else {
			return a[i].second < a[j].second
		}
	})

	fmt.Print(a)
	for i := int64(0); i < k; i++ {
		sum += a[n-i-1].first
	}
	fmt.Printf("%d\n", sum)
	for i := int64(1); i <= k; i++ {
		b[i] = a[n-i]
	}
	fmt.Print(b)
	sort.Slice(b, func(i, j int) bool { return b[i].second < b[j].second })
	fmt.Print(b)
	for i := int64(1); i < k; i++ {
		fmt.Printf("%d ", b[i].second-b[i-1].second)
	}
	fmt.Printf("%d\n", n-b[k-1].second)
}

package main

import (
	"fmt"
	"sort"
)

const (
	M = 2e3 + 5
)

type Array struct {
	x int
	idx int
}

type intArray []Array
type intSlice []int

var n, k int

func (s intArray) Len() int { return len(s) }
func (s intArray) Swap(i, j int){
	s[i].idx, s[j].idx = s[j].idx, s[i].idx
	s[i].x, s[j].x = s[j].x, s[i].x
}
func (s intArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func main() {
	var i int
	fmt.Scanf("%d%d", &n, &k)
	var a = make([]int, n)
	var b = make([]Array, n)
	for i = 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
		fmt.Print(i)
		b[i].idx = i
		b[i].x = a[i]
		fmt.Print(b[i].idx)
	}
	sort.Sort(intArray(b))
	var ans = make([]int, 0)
	var res int = 0

	for i = 0; i < k; i++ {
		fmt.Print(b[n - 1 - i].idx)
		ans = append(ans, b[n - 1 - i].idx)
		res += b[n - 1 - i].x
	}
	sort.Sort(intSlice(ans))
	fmt.Print(ans)
	fmt.Println(res)
	for i = 0; i < k; i++ {
		if i == 0 {
			fmt.Print(ans[i] + 1, " ")
		} else {
			fmt.Print(ans[i] - ans[i - 1], " ")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

const (
	M = 2e3 + 5
)

type Array struct {
	x int
	idx int
}

type intArray []Array
type intSlice []int

var n, k int

func (s intArray) Len() int { return len(s) }
func (s intArray) Swap(i, j int){
	s[i].idx, s[j].idx = s[j].idx, s[i].idx
	s[i].x, s[j].x = s[j].x, s[i].x
}
func (s intArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func main() {
	var i int
	fmt.Scanf("%d%d", &n, &k)
	var a = make([]int, n)
	var b = make([]Array, n)
	for i = 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
		//fmt.Print(i)
		b[i].idx = i
		b[i].x = a[i]
		//fmt.Print(b[i].idx)
	}
	sort.Sort(intArray(b))
	var ans = make([]int, k)
	var res int = 0

	for i = 0; i < k; i++ {
		fmt.Print(b[n - 1 - i].idx)
		ans[i] = b[n - 1 - i].idx
		res += b[n - 1 - i].x
	}
	fmt.Println()
	fmt.Print(b[0].idx, b[0].x)
	fmt.Print(ans)
	fmt.Println()
	sort.Sort(intSlice(ans))
	fmt.Print(ans)
	fmt.Println(res)
	for i = 0; i < k; i++ {
		if i == 0 {
			fmt.Print(ans[i] + 1, " ")
		} else {
			fmt.Print(ans[i] - ans[i - 1], " ")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

const (
	M = 2e3 + 5
)

type Array struct {
	x int
	idx int
}

type intArray []Array
type intSlice []int

var n, k int

func (s intArray) Len() int { return len(s) }
func (s intArray) Swap(i, j int){
	s[i].idx, s[j].idx = s[j].idx, s[i].idx
	s[i].x, s[j].x = s[j].x, s[i].x
}
func (s intArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func main() {
	var i int
	fmt.Scanf("%d%d", &n, &k)
	fmt.Print(n, k)
	var a = make([]int, n)
	var b = make([]Array, n)
	for i = 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
		b[i].idx = i
		b[i].x = a[i]
	}
	sort.Sort(intArray(b))
	var ans = make([]int, 0)
	var res int = 0

	for i = 0; i < k; i++ {
		ans = append(ans, b[n - 1 - i].idx)
		res += b[n - 1 - i].x
	}
	sort.Sort(intSlice(ans))
	fmt.Println(res)
	for i = 0; i < k; i++ {
		if i == 0 {
			fmt.Print(ans[i] + 1, " ")
		} else {
			fmt.Print(ans[i] - ans[i - 1], " ")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

const (
	M = 2e3 + 5
)

type Array struct {
	x int
	idx int
}

type intArray []Array
type intSlice []int

var n, k int

func (s intArray) Len() int { return len(s) }
func (s intArray) Swap(i, j int){
	s[i].idx, s[j].idx = s[j].idx, s[i].idx
	s[i].x, s[j].x = s[j].x, s[i].x
}
func (s intArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func main() {
	var i int
	fmt.Scanf("%d%d", &n, &k)
	var a = make([]int, n)
	var b = make([]Array, n)
	for i = 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
		b[i].idx = i
		b[i].x = a[i]
	}
	sort.Sort(intArray(b))
	var ans = make([]int, 0)
	var res int = 0

	for i = 0; i < k; i++ {
		ans = append(ans, b[n - 1 - i].idx)
		res += b[n - 1 - i].x
	}
	sort.Sort(intSlice(ans))
	fmt.Println(res)
	for i = 0; i < k; i++ {
		if i == 0 {
			fmt.Print(ans[i] + 1, " ")
		} else {
			fmt.Print(ans[i] - ans[i - 1], " ")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

const (
	M = 2e3 + 5
)

type Array struct {
	x int
	idx int
}

type intArray []Array
type intSlice []int

var n, k int

func (s intArray) Len() int { return len(s) }
func (s intArray) Swap(i, j int){
	s[i].idx, s[j].idx = s[j].idx, s[i].idx
	s[i].x, s[j].x = s[j].x, s[i].x
}
func (s intArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func main() {
	var i int
	fmt.Scanf("%d%d\n", &n, &k)
	var a = make([]int, n)
	var b = make([]Array, n)
	for i = 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
		b[i].idx = i
		b[i].x = a[i]
	}
	sort.Sort(intArray(b))
	var ans = make([]int, k)
	var res int = 0

	for i = 0; i < k; i++ {
		ans[i] = b[n - 1 - i].idx
		res += b[n - 1 - i].x
	}
	sort.Sort(intSlice(ans))
	fmt.Println(res)
	for i = 0; i < k; i++ {
		if i == 0 {
			fmt.Print(ans[i] + 1, " ")
		} else {
			fmt.Print(ans[i] - ans[i - 1], " ")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

const (
	M = 2e3 + 5
)

type Array struct {
	x int
	idx int
}

type intArray []Array
type intSlice []int

var n, k int

func (s intArray) Len() int { return len(s) }
func (s intArray) Swap(i, j int){
	s[i].idx, s[j].idx = s[j].idx, s[i].idx
	s[i].x, s[j].x = s[j].x, s[i].x
}
func (s intArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func main() {
	var i int
	fmt.Scanf("%d%d", &n, &k)
	var a = make([]int, n)
	var b = make([]Array, n)
	for i = 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
		//fmt.Print(i)
		b[i].idx = i
		b[i].x = a[i]
		//fmt.Print(b[i].idx)
	}
	sort.Sort(intArray(b))
	var ans = make([]int, 0)
	var res int = 0

	for i = 0; i < k; i++ {
		//fmt.Print(b[n - 1 - i].idx)
		ans = append(ans, b[n - 1 - i].idx)
		res += b[n - 1 - i].x
	}
	fmt.Print(b[0].idx, b[0].x)
	sort.Sort(intSlice(ans))
	fmt.Print(ans)
	fmt.Println(res)
	for i = 0; i < k; i++ {
		if i == 0 {
			fmt.Print(ans[i] + 1, " ")
		} else {
			fmt.Print(ans[i] - ans[i - 1], " ")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

const (
	M = 2e3 + 5
)

type Array struct {
	x int
	idx int
}

type intArray []Array
type intSlice []int

var n, k int

func (s intArray) Len() int { return len(s) }
func (s intArray) Swap(i, j int){
	s[i].idx, s[j].idx = s[j].idx, s[i].idx
	s[i].x, s[j].x = s[j].x, s[i].x
}
func (s intArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func main() {
	var i int
	fmt.Scanf("%d%d", &n, &k)
	var a = make([]int, n)
	var b = make([]Array, n)
	for i = 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
		//fmt.Print(i)
		b[i].idx = i
		b[i].x = a[i]
		//fmt.Print(b[i].idx)
	}
	sort.Sort(intArray(b))
	var ans = make([]int, k)
	var res int = 0

	for i = 0; i < k; i++ {
		//fmt.Print(b[n - 1 - i].idx)
		ans[i] = b[n - 1 - i].idx
		res += b[n - 1 - i].x
	}
	fmt.Print(b[0].idx, b[0].x)
	sort.Sort(intSlice(ans))
	fmt.Print(ans)
	fmt.Println(res)
	for i = 0; i < k; i++ {
		if i == 0 {
			fmt.Print(ans[i] + 1, " ")
		} else {
			fmt.Print(ans[i] - ans[i - 1], " ")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

const (
	M = 2e3 + 5
)

type Array struct {
	x int
	idx int
}

type intArray []Array
type intSlice []int

var n, k int

func (s intArray) Len() int { return len(s) }
func (s intArray) Swap(i, j int){
	s[i].idx, s[j].idx = s[j].idx, s[i].idx
	s[i].x, s[j].x = s[j].x, s[i].x
}
func (s intArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func main() {
	var i int
	fmt.Scanf("%d%d", &n, &k)
	var a = make([]int, n)
	var b = make([]Array, n)
	for i = 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
		//fmt.Print(i)
		b[i].idx = i
		b[i].x = a[i]
		//fmt.Print(b[i].idx)
	}
	fmt.Print(b)
	sort.Sort(intArray(b))
	fmt.Print(b)
	var ans = make([]int, k)
	var res int = 0

	for i = 0; i < k; i++ {
		ans[i] = b[n - 1 - i].idx
		res += b[n - 1 - i].x
	}
	sort.Sort(intSlice(ans))
	fmt.Println(res)
	for i = 0; i < k; i++ {
		if i == 0 {
			fmt.Print(ans[i] + 1, " ")
		} else {
			fmt.Print(ans[i] - ans[i - 1], " ")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

const (
	M = 2e3 + 5
)

type Array struct {
	x int
	idx int
}

type intArray []Array
type intSlice []int

var n, k int

func (s intArray) Len() int { return len(s) }
func (s intArray) Swap(i, j int){
	s[i].idx, s[j].idx = s[j].idx, s[i].idx
	s[i].x, s[j].x = s[j].x, s[i].x
}
func (s intArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func main() {
	var i int
	fmt.Scanf("%d%d", &n, &k)
	var a = make([]int, n)
	var b = make([]Array, n)
	for i = 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
		b[i].idx = i
		b[i].x = a[i]
	}
	sort.Sort(intArray(b))
	var ans = make([]int, 0)
	var res int = 0

	for i = 0; i < k; i++ {
		ans = append(ans, b[n - 1 - i].idx)
		res += b[n - 1 - i].x
	}
	sort.Sort(intSlice(ans))
	fmt.Print(ans)
	fmt.Println(res)
	for i = 0; i < k; i++ {
		if i == 0 {
			fmt.Print(ans[i] + 1, " ")
		} else {
			fmt.Print(ans[i] - ans[i - 1], " ")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

func ReadInt64() int64 {
	var ret int64
	cnt, err := fmt.Scanf("%d", &ret)
	if cnt != 1 || err != nil {
		//fmt.Printf("cnt=%d, err=%s\n", cnt, err)
		return 0
	}
	return ret
}

func ReadString() string {
	var ret string
	cnt, err := fmt.Scanf("%s", ret)
	if cnt != 1 || err != nil {
		fmt.Printf("cnt=%d, err=%s\n", cnt, err)
		return ""
	}
	return ret
}

type pair struct {
	first  int64
	second int64
}

func main() {
	n, k, sum := int64(0), int64(0), int64(0)
	n, k = ReadInt64(), ReadInt64()
	a, b := make([]pair, n), make([]pair, k+1)

	for i := int64(0); i < n; i++ {
		a[i].first = ReadInt64()
		a[i].second = i + 1
	}
	sort.Slice(a, func(i, j int) bool { return a[i].first < a[j].first })
	for i := int64(0); i < k; i++ {
		sum += a[n-i-1].first
	}
	fmt.Printf("%d\n", sum)
	for i := int64(1); i <= k; i++ {
		b[i] = a[n-i]
	}
	sort.Slice(b, func(i, j int) bool { return b[i].second < b[j].second })
	for i := int64(1); i < k; i++ {
		fmt.Printf("%d ", b[i].second-b[i-1].second)
	}
	fmt.Printf("%d\n", n-b[k-1].second)
}

package main

import (
	"fmt"
	"sort"
)

func ReadInt64() int64 {
	var ret int64
	_, err := fmt.Scanf("%d", &ret)
	if err != nil {
		//fmt.Printf("cnt=%d, err=%s\n", cnt, err)
		return 0
	}
	return ret
}

func ReadString() string {
	var ret string
	cnt, err := fmt.Scanf("%s", ret)
	if cnt != 1 || err != nil {
		fmt.Printf("cnt=%d, err=%s\n", cnt, err)
		return ""
	}
	return ret
}

type pair struct {
	first  int64
	second int64
}

func main() {
	n, k, sum := int64(0), int64(0), int64(0)
	n, k = ReadInt64(), ReadInt64()
	a, b := make([]pair, n), make([]pair, k+1)

	for i := int64(0); i < n; i++ {
		a[i].first = ReadInt64()
		a[i].second = i + 1
	}
	sort.Slice(a, func(i, j int) bool { return a[i].first < a[j].first })
	for i := int64(0); i < k; i++ {
		sum += a[n-i-1].first
	}
	fmt.Printf("%d\n", sum)
	for i := int64(1); i <= k; i++ {
		b[i] = a[n-i]
	}
	sort.Slice(b, func(i, j int) bool { return b[i].second < b[j].second })
	for i := int64(1); i < k; i++ {
		fmt.Printf("%d ", b[i].second-b[i-1].second)
	}
	fmt.Printf("%d\n", n-b[k-1].second)
}

package main

import (
	"fmt"
	"sort"
)

func ReadInt64() int64 {
	var ret int64
	cnt, err := fmt.Scanf("%d", &ret)
	if cnt != 1 || err != nil {
		fmt.Printf("cnt=%d, err=%s\n", cnt, err)
		return 0
	}
	return ret
}

func ReadString() string {
	var ret string
	cnt, err := fmt.Scanf("%s", ret)
	if cnt != 1 || err != nil {
		fmt.Printf("cnt=%d, err=%s\n", cnt, err)
		return ""
	}
	return ret
}

type pair struct {
	first  int64
	second int64
}

func main() {
	n, k, sum := int64(0), int64(0), int64(0)
	n, k = ReadInt64(), ReadInt64()
	a, b := make([]pair, n), make([]pair, k+1)

	for i := int64(0); i < n; i++ {
		a[i].first = ReadInt64()
		a[i].second = i + 1
	}
	sort.Slice(a, func(i, j int) bool { return a[i].first < a[j].first })
	for i := int64(0); i < k; i++ {
		sum += a[n-i-1].first
	}
	fmt.Printf("%d\n", sum)
	for i := int64(1); i <= k; i++ {
		b[i] = a[n-i]
	}
	sort.Slice(b, func(i, j int) bool { return b[i].second < b[j].second })
	for i := int64(1); i < k; i++ {
		fmt.Printf("%d ", b[i].second-b[i-1].second)
	}
	fmt.Printf("%d\n", n-b[k-1].second)
}

package main

import (
	"fmt"
	"sort"
)

func ReadInt64() int64 {
	var ret int64
	fmt.Scanf("%d", &ret)
	return ret
}

func ReadString() string {
	var ret string
	cnt, err := fmt.Scanf("%s", ret)
	if cnt != 1 || err != nil {
		fmt.Printf("cnt=%d, err=%s\n", cnt, err)
		return ""
	}
	return ret
}

type pair struct {
	first  int64
	second int64
}

func main() {
	n, k, sum := int64(0), int64(0), int64(0)
	n, k = ReadInt64(), ReadInt64()
	a, b := make([]pair, n), make([]pair, k+1)

	for i := int64(0); i < n; i++ {
		a[i].first = ReadInt64()
		a[i].second = i + 1
	}
	sort.Slice(a, func(i, j int) bool { return a[i].first < a[j].first })
	for i := int64(0); i < k; i++ {
		sum += a[n-i-1].first
	}
	fmt.Printf("%d\n", sum)
	for i := int64(1); i <= k; i++ {
		b[i] = a[n-i]
	}
	sort.Slice(b, func(i, j int) bool { return b[i].second < b[j].second })
	for i := int64(1); i < k; i++ {
		fmt.Printf("%d ", b[i].second-b[i-1].second)
	}
	fmt.Printf("%d\n", n-b[k-1].second)
}


package main

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

func main() {
	io := newFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	for t := io.nextInt(); t > 0; t-- {
		n := io.nextInt()
		a, b := []byte(io.next()), []byte(io.next())

		i, j, inv, dir := 0, n-1, byte(0), 1
		ops := []int{}
		for k := n - 1; k >= 0; k-- {
			if a[j]^inv != b[k] {
				if a[i]^inv == b[k] {
					ops = append(ops, 1)
					a[i] ^= 1
				}
				ops = append(ops, k+1)
				i, j = j, i+dir
				dir = -dir
				inv ^= 1
			} else {
				j -= dir
			}
		}
		io.print(len(ops), " ")
		io.printlnInts(ops...)
	}
}

type fastIO struct {
	*bufio.Reader
	*bufio.Writer
	p [1]byte
}

func newFastIO(r io.Reader, w io.Writer) *fastIO {
	return &fastIO{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)}
}

func (f *fastIO) nextInt() int {
	f.Read(f.p[:])
	for !('0' <= f.p[0] && f.p[0] <= '9') {
		f.Read(f.p[:])
	}
	n := 0
	for '0' <= f.p[0] && f.p[0] <= '9' {
		n = n*10 + int(f.p[0]) - '0'
		f.Read(f.p[:])
	}
	return n
}

func (f *fastIO) nextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.nextInt()
	}
	return a
}

func (f *fastIO) next() string {
	f.Read(f.p[:])
	for f.p[0] <= ' ' {
		f.Read(f.p[:])
	}
	var s []byte
	for f.p[0] > ' ' {
		s = append(s, f.p[0])
		f.Read(f.p[:])
	}
	return string(s)
}

func (f *fastIO) println(a ...interface{}) {
	fmt.Fprintln(f.Writer, a...)
}

func (f *fastIO) print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *fastIO) printInts(a ...int) {
	if len(a) > 0 {
		f.print(a[0])
		for _, x := range a[1:] {
			f.print(" ", x)
		}
	}
}

func (f *fastIO) printlnInts(a ...int) {
	f.printInts(a...)
	f.println()
}

package main

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

func main() {
	var t int
	fmt.Scan(&t)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	for i := 0; i < t; i++ {
		scanner.Scan()
		n := toInt(scanner.Bytes())

		scanner.Scan()
		a := scanner.Text()

		scanner.Scan()
		b := scanner.Text()
		var ans []int

		for j := 0; j < n; j++ {
			if string(a[j]) != string(b[j]) {
				ans = append(ans, (j + 1))
				ans = append(ans, 1)
				ans = append(ans, (j + 1))
			}
		}
		fmt.Printf("%d ", len(ans))
		for _, v := range ans {
			fmt.Printf("%d ", v)
		}
	}
}

func toInt(buf []byte) (n int) {
	for _, v := range buf {
		n = n*10 + int(v-'0')
	}
	return
}

package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

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

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

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

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

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

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

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

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

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

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

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

func main() {
	defer writer.Flush()
	t := sint64()
	for ; t > 0; t-- {
		_ = sint64()
		a := sstring()
		b := sstring()
		res := sol([]byte(a), []byte(b))
		printf("%d ", len(res))
		for _, i := range res {
			printf("%d ", i)
		}
		printf("\n")
	}
}

func sol(a, b []byte) []int64 {
	ret := []int64{}
	for i := int64(len(b) - 1); i > 0; i-- {
		if a[i] == b[i] {
			continue
		}
		if a[0] != a[i] {
			ret = append(ret, 1)
			if a[0] == '0' {
				a[0] = '1'
			} else {
				a[0] = '0'
			}
		}
		ret = append(ret, i+1)
		l := int64(0)
		r := i
		for l < r {
			a[l], a[r] = a[r], a[l]
			l++
			r--
		}
		for j := int64(0); j <= i; j++ {
			if a[j] == '0' {
				a[j] = '1'
			} else {
				a[j] = '0'
			}
		}
	}
	if a[0] != b[0] {
		ret = append(ret, 1)
	}
	// printf("%s %s\n", string(a), string(b))
	return ret
}

package main

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

/*
6
OEYCDK
EYOKCD
KDCEOY
CKHOYE
YOEDKC
DCKYEO
3
IWL
GIW
WLI
*/

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

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

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

type priorityQueue [][2]int

func (pq priorityQueue) Len() int {
	return len(pq)
}

func (pq priorityQueue) Less(i, j int) bool {
	return pq[i][1] > pq[j][1]
}

func (pq priorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *priorityQueue) Push(x interface{}) {
	*pq = append(*pq, x.([2]int))
}

func (pq *priorityQueue) Pop() (res interface{}) {
	res = (*pq)[len(*pq)-1]
	*pq = (*pq)[:len(*pq)-1]
	return res
}

var err error

func nextInt() (n int) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func nextLong() (n int64) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func nextDouble() (n float64) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func next() (n string) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return ""
		}
	}
}

func Fill(a []int, v int) {
	for i := range a {
		a[i] = v
	}
}

func FillB(a []bool, v bool) {
	for i := range a {
		a[i] = v
	}
}

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

var (
	names map[string]int
	words []string
	withs [][]string
	res   []string
	has   []bool
)

func dfs(ind int) {
	if has[ind] {
		return
	}
	has[ind] = true
	for i := len(withs[ind]) - 1; i >= 0; i-- {
		dfs(names[withs[ind][i]])
	}
	res = append(res, words[ind])
}

func main() {
	in = bufio.NewReaderSize(os.Stdin, 8192)
	out = bufio.NewWriterSize(os.Stdout, 8192)
	if false {
		name := "in"
		file1, err := os.Open(name + ".in")
		if err != nil {
			log.Fatal(err)
		}
		// file2, err := os.Create(name + ".out")
		// if err != nil {
		// 	log.Fatal(err)
		// }
		in = bufio.NewReaderSize(file1, 8192)
		// out = bufio.NewWriterSize(file2, 8192)
	}
	defer out.Flush()

	for cases := nextInt(); cases > 0; cases-- {
		n := nextInt()
		a, b := next(), next()
		ord := make([]int, n)
		for i := 0; i <= (n-1)/2; i++ {
			ord[2*i] = i
		}
		for i, curr := n-1, 1; curr < n; i, curr = i-1, curr+2 {
			ord[curr] = i
		}
		res := []int{}
		for i := 0; i < n; i++ {
			x, v := n-1-i, byte(0)
			if i%2 == 1 {
				v = a[ord[i]] ^ 1
			} else {
				v = a[ord[i]]
			}
			if v == b[x] {
				res = append(res, 1)
			}
			res = append(res, x+1)
		}
		printf("%d", len(res))
		for _, v := range res {
			printf(" %d", v)
		}
		printf("\n")
	}
}

package main

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

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

	var T, n int
	var a, b []byte
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &a, &b)
		ans := []interface{}{}
		for i, c := range a {
			if i > 0 && c != a[i-1] {
				ans = append(ans, i)
			}
		}
		if a[n-1] != b[n-1] {
			ans = append(ans, n)
		}
		for i := len(b) - 2; i >= 0; i-- {
			if b[i] != b[i+1] {
				ans = append(ans, i+1)
			}
		}
		Fprint(out, len(ans), " ")
		Fprintln(out, ans...)
	}
}

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


package main

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

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

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

func isV(b byte) bool {
	if b == byte('a') {
		return true
	}
	if b == byte('e') {
		return true
	}
	if b == byte('i') {
		return true
	}
	if b == byte('o') {
		return true
	}
	if b == byte('u') {
		return true
	}
	return false
}

func main() {
	defer writer.Flush()
	var s, t string
	scanf("%s\n%s\n", &s, &t)

	if len(s) != len(t) {
		printf("No")
		return
	}

	for i := 0; i < len(s); i++ {
		if isV(s[i]) != isV(t[i]) {
			printf("No")
			return
		}
	}

	printf("Yes")
	return

}

package main

import "fmt"

func isVowel(c byte) bool {
	if c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' {
		return true
	} else {
		return false
	}
}

func main() {
	m1, m2 := "", ""
	fmt.Scanf("%s\n%s", &m1, &m2)
	if len(m1) != len(m2) {
		fmt.Printf("NO")
		return
	}
	for i := 0; i < len(m1); i++ {
		if isVowel(m1[i]) != isVowel(m2[i]) {
			fmt.Printf("NO")
			return
		}
	}
	fmt.Printf("YES")
}

package main

import "fmt"

func solve(name1, name2 string) bool {
	vowels := map[byte]bool{
		'a': true,
		'e': true,
		'i': true,
		'o': true,
		'u': true,
	}

	if len(name1) != len(name2) {
		return false
	}

	for i := range name1 {
		if vowels[name1[i]] != vowels[name2[i]] {
			return false
		}
	}

	return true
}

func main() {
	name1 := ""
	name2 := ""
	fmt.Scan(&name1, &name2)

	res := solve(name1, name2)

	if res {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

package main

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

func add(mp map[string]bool, v ...interface{}) {
	for _, each := range v {
		mp[each.(string)] = true
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	var s, t string

	vowel := make(map[string]bool)
	add(vowel, "a", "e", "i", "o", "u")

	fmt.Fscan(reader, &s, &t)
	if len(s) > len(t) || len(t) > len(s) {
		fmt.Println("No")
		return
	}

	// fmt.Println(s)
	// fmt.Println(t)
	for i := range s {
		if isVowel(vowel, s[i]) != isVowel(vowel, t[i]) {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}

func isVowel(mp map[string]bool, c byte) bool {
	if mp[string(c)] == true {
		return true
	} else {
		return false
	}
}

package main

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

func isVowel(b byte) bool {
	vowel := []byte("aiueo")
	for _, v := range vowel {
		if v == b {
			return true
		}
	}
	return false
}

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

	if len(text1) != len(text2) {
		fmt.Println("No")
		return
	}
	for k, _ := range text1 {
		if isVowel(text1[k]) != isVowel(text2[k]) {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

package main

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

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Split(bufio.ScanWords)
}

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

func scanBytes() []byte {
	scanner.Scan()
	return scanner.Bytes()
}

func scanInt64() int64 {
	scanner.Scan()
	v, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return v
}

func scanInt() int {
	scanner.Scan()
	v, _ := strconv.Atoi(scanner.Text())
	return v
}

func scanInts(n int) []int {
	l := make([]int, n)
	for i := 0; i < n; i++ {
		scanner.Scan()
		l[i], _ = strconv.Atoi(scanner.Text())
	}

	return l
}

func scanInts64(n int64) []int64 {
	l := make([]int64, n)
	for i := int64(0); i < n; i++ {
		scanner.Scan()
		l[i], _ = strconv.ParseInt(scanner.Text(), 10, 64)
	}

	return l
}

func scanBool() bool {
	scanner.Scan()
	v, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return v == 1
}

func scanBools(n int64) []bool {
	l := make([]bool, n)
	for i := int64(0); i < n; i++ {
		scanner.Scan()
		v, _ := strconv.ParseInt(scanner.Text(), 10, 64)
		l[i] = v == 1
	}

	return l
}

func scanUint64() uint64 {
	scanner.Scan()
	v, _ := strconv.ParseUint(scanner.Text(), 10, 64)
	return v
}

type ByAge []uint64

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

var glasn = map[byte]bool{
	'a': true,
	'e': true,
	'i': true,
	'o': true,
	'u': true,
}

func main() {
	s, t := scanBytes(), scanBytes()

	if len(s) != len(t) {
		fmt.Println("No")
		return
	}

	for i, bs := range s {
		bt := t[i]

		if glasn[bt] != glasn[bs] {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}

func skipZero(a []uint64) []uint64 {
	for len(a) > 0 && a[0] == 0 {
		a = a[1:]
	}

	return a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}

	return -a
}

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

	return b
}

// run on go 1.11.4

package main

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

func next(scn *bufio.Scanner) string {
	scn.Scan()
	return scn.Text()
}

func nextInt(scn *bufio.Scanner) int {
	i, _ := strconv.Atoi(next(scn))
	return i
}

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

	s := next(scn)
	t := next(scn)

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

func solve(s string, t string) string {
	// https://ashitani.jp/golangtips/tips_regexp.html

	c := regexp.MustCompile("[^aeiou]")
	v := regexp.MustCompile("[aeiou]")
  normalizedS := v.ReplaceAllString(c.ReplaceAllString(s, "C"), "V")
  normalizedT := v.ReplaceAllString(c.ReplaceAllString(t, "C"), "V")
  if (normalizedS == normalizedT) {
    return "Yes"
  } else {
    return "No"
  }
}

package main

import (
	"fmt"

	"regexp"
)

func main() {
	s := readString()
	t := readString()

	if fuck(s) == fuck(t) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func fuck(s string) string {
	return vowels.ReplaceAllLiteralString(consonants.ReplaceAllLiteralString(s, "0"), "1")
}

var (
	vowels = regexp.MustCompile("[aeiou]")
	consonants = regexp.MustCompile("[^aeiou]")
)

func readString() (r string) {
	fmt.Scan(&r)
	return
}

package main

import "fmt"

func main() {
	var s, t, res string
	fmt.Scanln(&s)
	fmt.Scanln(&t)
	if len(s) == len(t) {
	asdf:
		for x, y := range s {
			switch string(y) {
			case "a", "e", "i", "o", "u":
				z := string(t[x])
				switch z {
				case "a", "e", "i", "o", "u":
					res = "Yes"
				default:
					res = "No"
					break asdf
				}

			default:
				z := string(t[x])
				switch z {
				case "a", "e", "i", "o", "u":
					res = "No"
					break asdf
				default:
					res = "Yes"
				}
			}
		}
	} else {
		res = "No"
	}
	fmt.Println(res)
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var a, b string
	fmt.Fscan(reader, &a, &b)
	if len(a) != len(b) {
		fmt.Println("No")
		return
	}
	for i := 0; i < len(a); i++ {
		if isVowel(a[i]) != isVowel(b[i]) {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

func isVowel(l byte) bool {
	switch l {
	case 'a':
		return true
	case 'e':
		return true
	case 'i':
		return true
	case 'o':
		return true
	case 'u':
		return true
	}
	return false
}

package main

import (
	"fmt"
)

func main() {
	vowels := map[uint8]bool{'a': true, 'e': true, 'i': true, 'o': true, 'u': true}
	var s, t string
	fmt.Scan(&s, &t)
	if len(s) != len(t) {
		fmt.Println("No")
		return
	}
	for i := 0; i < len(s); i++ {
		if vowels[s[i]] != vowels[t[i]] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

package main

import "fmt"

func isVowl(r byte) bool {
	for _, v := range "aeiou" {
		if rune(r) == v {
			return true
		}
	}
	return false
}

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	flgNG := false
	if len(s) != len(t) {
		flgNG = true
	} else {
		for i := range s {
			if isVowl(s[i]) != isVowl(t[i]) {
				flgNG = true
			}
		}
	}
	b2i := map[bool]int8{false: 0, true: 1}
	fmt.Println([...]string{"Yes", "No"}[b2i[flgNG]])
}

package main

import (
	"fmt"

	"regexp"
)

func main() {
	s := readString()
	t := readString()

	if fuck(s) == fuck(t) {
		println("Yes")
	} else {
		println("No")
	}
}

func fuck(s string) string {
	return vowels.ReplaceAllLiteralString(consonants.ReplaceAllLiteralString(s, "0"), "1")
}

var (
	vowels = regexp.MustCompile("[aeiou]")
	consonants = regexp.MustCompile("[^aeiou]")
)

func readString() (r string) {
	fmt.Scan(&r)
	return
}

package main

import "fmt"

func isVowel(c byte) bool {
	if c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' {
		return true
	} else {
		return false
	}
}

func main() {
	m1, m2 := "", ""
	fmt.Scanf("%s %s", &m1, &m2)
	if len(m1) != len(m2) {
		fmt.Printf("NO")
		return
	}
	for i := 0; i < len(m1); i++ {
		if isVowel(m1[i]) != isVowel(m2[i]) {
			fmt.Printf("NO")
		}
	}
	fmt.Printf("YES")
}

package main

import "fmt"

func isVowel(c byte) bool {
	if c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' {
		return true
	} else {
		return false
	}
}

func main() {
	m1, m2 := "", ""
	fmt.Scanf("%s\n%s", &m1, &m2)
	if len(m1) != len(m2) {
		fmt.Printf("NO")
		return
	}
	for i := 0; i < len(m1); i++ {
		if isVowel(m1[i]) != isVowel(m2[i]) {
			fmt.Printf("NO")
		}
	}
	fmt.Printf("YES")
}

package main

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

type sortRunes []rune

func (s sortRunes) Less(i, j int) bool {
	return s[i] < s[j]
}

func (s sortRunes) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s sortRunes) Len() int {
	return len(s)
}

func SortString(s string) string {
	r := []rune(s)
	sort.Sort(sortRunes(r))
	return string(r)
}

func add(mp map[string]bool, v ...interface{}) {
	for _, each := range v {
		mp[each.(string)] = true
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	var s, t string

	vowel := make(map[string]bool)
	add(vowel, "a", "e", "i", "o", "u")

	fmt.Fscan(reader, &s, &t)
	if len(s) > len(t) || len(t) > len(s) {
		fmt.Println("No")
		return
	}

	s = SortString(s)
	t = SortString(t)

	var count int
	for i := range s {
		if isVowel(vowel, s[i]) && isVowel(vowel, t[i]) || isVowel(vowel, s[i]) && isVowel(vowel, t[i]) {
			count++
		}
	}

	if count < 2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func isVowel(mp map[string]bool, c byte) bool {
	if mp[string(c)] == true {
		return true
	} else {
		return false
	}
}

package main

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

type sortRunes []rune

func (s sortRunes) Less(i, j int) bool {
	return s[i] < s[j]
}

func (s sortRunes) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s sortRunes) Len() int {
	return len(s)
}

func SortString(s string) string {
	r := []rune(s)
	sort.Sort(sortRunes(r))
	return string(r)
}

func add(mp map[string]bool, v ...interface{}) {
	for _, each := range v {
		mp[each.(string)] = true
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	var s, t string

	vowel := make(map[string]bool)
	add(vowel, "a", "e", "i", "o", "u")

	fmt.Fscan(reader, &s, &t)
	if len(s) > len(t) || len(t) > len(s) {
		fmt.Println("No")
		return
	}

	s = SortString(s)
	t = SortString(t)

	var count int
	for i := range s {
		if isVowel(vowel, s[i]) && isVowel(vowel, t[i]) || !isVowel(vowel, s[i]) && !isVowel(vowel, t[i]) {
			count++
		}
	}

	if count == 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func isVowel(mp map[string]bool, c byte) bool {
	if mp[string(c)] == true {
		return true
	} else {
		return false
	}
}

package main

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

type sortRunes []rune

func (s sortRunes) Less(i, j int) bool {
	return s[i] < s[j]
}

func (s sortRunes) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s sortRunes) Len() int {
	return len(s)
}

func SortString(s string) string {
	r := []rune(s)
	sort.Sort(sortRunes(r))
	return string(r)
}

func add(mp map[string]bool, v ...interface{}) {
	for _, each := range v {
		mp[each.(string)] = true
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	var s, t string

	vowel := make(map[string]bool)
	add(vowel, "a", "e", "i", "o", "u")

	fmt.Fscan(reader, &s, &t)
	if len(s) > len(t) || len(t) > len(s) {
		fmt.Println("No")
		return
	}

	s = SortString(s)
	t = SortString(t)

	var count int
	for i := range s {
		if isVowel(vowel, s[i]) && isVowel(vowel, t[i]) || !isVowel(vowel, s[i]) && !isVowel(vowel, t[i]) {
			count++
		}
	}
	if count == 1 || count == len(s) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func isVowel(mp map[string]bool, c byte) bool {
	if mp[string(c)] == true {
		return true
	} else {
		return false
	}
}

package main

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

func add(mp map[string]bool, v ...interface{}) {
	for _, each := range v {
		mp[each.(string)] = true
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	var s, t string

	vowel := make(map[string]bool)
	add(vowel, "a", "e", "i", "o", "u")

	fmt.Fscan(reader, &s, &t)
	if len(s) > len(t) || len(t) > len(s) {
		fmt.Println("No")
		return
	}

	fmt.Println(s)
	fmt.Println(t)
	for i := range s {
		if isVowel(vowel, s[i]) != isVowel(vowel, t[i]) {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}

func isVowel(mp map[string]bool, c byte) bool {
	if mp[string(c)] == true {
		return true
	} else {
		return false
	}
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1323D(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}
	n, ans := read(), 0
	a := make([]int, n)
	for i := range a {
		a[i] = read()
	}
	b := make([]int, n)
	search := func(l, x int) int {
		r := n
		for l < r {
			m := (l + r) >> 1
			if b[m] >= x {
				r = m
			} else {
				l = m + 1
			}
		}
		return l
	}
	for i := uint(0); i < 25; i++ {
		for j, v := range a {
			b[j] = v &^ (-1 << (i + 1))
		}
		sort.Ints(b)
		cnt := 0
		for j, v := range b {
			cnt ^= search(j+1, 2<<i-v) - search(j+1, 1<<i-v)
			cnt ^= n - search(j+1, 3<<i-v)
		}
		ans |= cnt & 1 << i
	}
	Fprint(_w, ans)
}

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

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"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 NextInt64() int64 {
	bytes := NextBytes()
	i, err := Atoi64(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 Atoi64(b []byte) (int64, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	var n int64
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int64(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 reverseInts(a []int) {
	for l, r := 0, len(a)-1; l < r; l, r = l+1, r-1 {
		a[l], a[r] = a[r], a[l]
	}
}

func unique(a []int) int {
	newLen := 0
	n := len(a)
	for i := 0; i < n; i++ {
		if newLen == 0 || a[i] != a[newLen-1] {
			a[newLen] = a[i]
			newLen++
		}
	}
	return newLen
}

func bsearch(a []int, limitMask int, value int) int {
	l := 0
	r := len(a) - 1
	res := len(a)
	for l <= r {
		mid := (l + r) >> 1
		if a[mid]&limitMask >= value {
			res = mid
			r = mid - 1
		} else {
			l = mid + 1
		}
	}
	return res
}

func rangeSum(l, r, i int) int64 {
	if r > i {
		r = i
	}
	if l < r {
		return int64(r - l)
	} else {
		return 0
	}
}

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

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

	var limitMask int

	less := func(i, j int) bool {
		return a[i]&limitMask < a[j]&limitMask
	}

	var result int

	// var res int
	// for i := 0; i < n; i++ {
	// 	for j := i + 1; j < n; j++ {
	// 		res ^= a[i] + a[j]
	// 	}
	// }
	// fmt.Fprintln(out, res)

	for k := 0; k <= 25; k++ {
		nextPow := (1 << uint(k+1))
		limitMask = nextPow - 1
		sort.Slice(a, less)
		currPow := (1 << uint(k))
		var counts [2]int64
		// stderr("K=", k)

		// for i := 0; i < n; i++ {
		// 	stderr("sorted", i, "a[i]", a[i], fmt.Sprintf("%b", a[i]&limitMask))
		// }

		for i := 0; i < n; i++ {
			mask := a[i] & limitMask
			// more := currPow - (mask & (^currPow))
			// carryPos := bsearch(a, limitMask, more)
			firstOneMask := currPow - mask
			firstOnePos := bsearch(a, limitMask, firstOneMask)
			nextZeroMask := nextPow - mask
			nextZeroPos := bsearch(a, limitMask, nextZeroMask)
			secondOnePos := bsearch(a, limitMask, currPow+nextPow-mask)
			counts[0] += rangeSum(0, firstOnePos, i)
			counts[1] += rangeSum(firstOnePos, nextZeroPos, i)
			counts[0] += rangeSum(nextZeroPos, secondOnePos, i)
			counts[1] += rangeSum(secondOnePos, n, i)
			// stderr("k=", k, "mask", fmt.Sprintf("%b", mask), "more", fmt.Sprintf("%b", firstOneMask), "firstOnePos", firstOnePos, "nextZeroMask", fmt.Sprintf("%b", nextZeroMask), "nextZeroPos", nextZeroPos)
			// carryZeroPos :=
			// stderr("k=", k, "mask", fmt.Sprintf("%b", mask), "more", fmt.Sprintf("%b", more), "carryPos", carryPos, "firstOnePos", firstOnePos)
			// if (mask & currPow) == 0 {
			// 	counts[0] += rangeSum(0, min(firstOnePos, carryPos), i)
			// 	counts[1] += rangeSum(carryPos, firstOnePos, i)
			// 	counts[1] += rangeSum(firstOnePos, carryPos, i)
			// 	counts[0] += rangeSum(max(firstOnePos, carryPos), n, i)
			// } else {
			// 	counts[1] += rangeSum(0, min(firstOnePos, carryPos), i)
			// 	counts[0] += rangeSum(carryPos, firstOnePos, i)
			// 	counts[0] += rangeSum(firstOnePos, carryPos, i)
			// 	counts[1] += rangeSum(max(firstOnePos, carryPos), n, i)
			// }
			// stderr("ones", counts[1])
		}
		// stderr("ones", counts[1])
		if counts[1]%2 == 1 {
			result ^= currPow
		}
	}
	fmt.Fprintln(out, result)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1323D(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}
	n, ans := read(), 0
	a := make([]int, n)
	for i := range a {
		a[i] = read()
	}
	b := make([]int, n)
	search := func(l, x int) int {
		r := n
		for l < r {
			m := (l + r) >> 1
			if b[m] >= x {
				r = m
			} else {
				l = m + 1
			}
		}
		return l
	}
	for i := uint(0); i < 25; i++ {
		for j, v := range a {
			b[j] = v &^ (-1 << (i + 1))
		}
		sort.Ints(b)
		cnt := 0
		for j, v := range b {
			cnt ^= n - search(j+1, 3<<i-v) + search(j+1, 2<<i-v) - search(j+1, 1<<i-v)
		}
		ans |= cnt & 1 << i
	}
	Fprint(_w, ans)
}

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

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"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 NextInt64() int64 {
	bytes := NextBytes()
	i, err := Atoi64(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 Atoi64(b []byte) (int64, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	var n int64
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int64(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 reverseInts(a []int) {
	for l, r := 0, len(a)-1; l < r; l, r = l+1, r-1 {
		a[l], a[r] = a[r], a[l]
	}
}

func unique(a []int) int {
	newLen := 0
	n := len(a)
	for i := 0; i < n; i++ {
		if newLen == 0 || a[i] != a[newLen-1] {
			a[newLen] = a[i]
			newLen++
		}
	}
	return newLen
}

func bsearch(a []int, limitMask int, value int) int {
	l := 0
	r := len(a) - 1
	res := len(a)
	for l <= r {
		mid := (l + r) >> 1
		if a[mid]&limitMask >= value {
			res = mid
			r = mid - 1
		} else {
			l = mid + 1
		}
	}
	return res
}

func rangeSum(l, r, i int) int {
	if r > i {
		r = i
	}
	if l < r {
		return r - l
	} else {
		return 0
	}
}

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

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

	var limitMask int

	less := func(i, j int) bool {
		return a[i]&limitMask < a[j]&limitMask
	}

	var result int

	// var res int
	// for i := 0; i < n; i++ {
	// 	for j := i + 1; j < n; j++ {
	// 		res ^= a[i] + a[j]
	// 	}
	// }
	// fmt.Fprintln(out, res)

	for k := 0; k <= 25; k++ {
		nextPow := (1 << uint(k+1))
		limitMask = nextPow - 1
		sort.Slice(a, less)
		currPow := (1 << uint(k))
		var counts [2]int
		// stderr("K=", k)

		// for i := 0; i < n; i++ {
		// 	stderr("sorted", i, "a[i]", a[i], fmt.Sprintf("%b", a[i]&limitMask))
		// }

		for i := 0; i < n; i++ {
			mask := a[i] & limitMask
			// more := currPow - (mask & (^currPow))
			// carryPos := bsearch(a, limitMask, more)
			firstOneMask := currPow - mask
			firstOnePos := bsearch(a, limitMask, firstOneMask)
			nextZeroMask := nextPow - mask
			nextZeroPos := bsearch(a, limitMask, nextZeroMask)
			secondOnePos := bsearch(a, limitMask, currPow+nextPow-mask)
			counts[0] += rangeSum(0, firstOnePos, i)
			counts[1] += rangeSum(firstOnePos, nextZeroPos, i)
			counts[0] += rangeSum(nextZeroPos, secondOnePos, i)
			counts[1] += rangeSum(secondOnePos, n, i)
			// stderr("k=", k, "mask", fmt.Sprintf("%b", mask), "more", fmt.Sprintf("%b", firstOneMask), "firstOnePos", firstOnePos, "nextZeroMask", fmt.Sprintf("%b", nextZeroMask), "nextZeroPos", nextZeroPos)
			// carryZeroPos :=
			// stderr("k=", k, "mask", fmt.Sprintf("%b", mask), "more", fmt.Sprintf("%b", more), "carryPos", carryPos, "firstOnePos", firstOnePos)
			// if (mask & currPow) == 0 {
			// 	counts[0] += rangeSum(0, min(firstOnePos, carryPos), i)
			// 	counts[1] += rangeSum(carryPos, firstOnePos, i)
			// 	counts[1] += rangeSum(firstOnePos, carryPos, i)
			// 	counts[0] += rangeSum(max(firstOnePos, carryPos), n, i)
			// } else {
			// 	counts[1] += rangeSum(0, min(firstOnePos, carryPos), i)
			// 	counts[0] += rangeSum(carryPos, firstOnePos, i)
			// 	counts[0] += rangeSum(firstOnePos, carryPos, i)
			// 	counts[1] += rangeSum(max(firstOnePos, carryPos), n, i)
			// }
			// stderr("ones", counts[1])
		}
		// stderr("ones", counts[1])
		if counts[1]%2 == 1 {
			result ^= currPow
		}
	}
	fmt.Fprintln(out, result)
}


package main

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

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

	var n, v, w int
	Fscan(in, &n)
	a := make([]bool, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	g := make([][]int, n)
	for i := 1; i < n; i++ {
		Fscan(in, &v, &w)
		v--
		w--
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}
	ans := make([]int8, n)
	cnt := make([]int, n)
	var f func(int, int)
	f = func(v, fa int) {
		if a[v] {
			ans[v] = 1
			cnt[v] = 1
		}
		for _, w := range g[v] {
			if w != fa {
				f(w, v)
				cnt[v] += cnt[w]
				if a[w] || ans[w] > 0 && cnt[w] > 1 {
					ans[v] = 1
				}
			}
		}
	}
	f(0, -1)
	f = func(v, fa int) {
		for _, w := range g[v] {
			if w != fa {
				if a[v] || ans[v] > 0 && cnt[0]-cnt[w] > 1 {
					ans[w] = 1
				}
				f(w, v)
			}
		}
	}
	f(0, -1)
	for _, v := range ans {
		Fprint(out, v, " ")
	}
}

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

package main

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

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

type Edge struct {
	fr        int
	to        int
	flagCount int
	rev       *Edge
	active    bool
}

func NewEdge(fr, to int) *Edge {
	return &Edge{fr: fr, to: to, flagCount: -1, rev: nil, active: false}
}

var graph [][]*Edge
var flag []bool
var parent []int
var subtreeCount []int
var queue []int

func countFlagsRec(node, parentNode int) int {
	if flag[node] {
		subtreeCount[node] = 1
	}

	parent[node] = parentNode
	for _, edge := range graph[node] {
		if edge.to != parentNode {
			subtreeCount[node] += countFlagsRec(edge.to, node)
		}
	}
	return subtreeCount[node]
}

// func (e *Edge) countFlagsRec() int {
// 	if e.flagCount != -1 {
// 		return e.flagCount
// 	}

// 	e.flagCount = 0
// 	if flag[e.to] {
// 		e.flagCount++
// 	}
// 	for _, edge := range graph[e.to] {
// 		if edge.to != e.fr {
// 			e.flagCount += edge.countFlagsRec()
// 		}
// 	}
// 	return e.flagCount
// }

func main() {
	var n int
	fmt.Fscan(in, &n)

	flag = make([]bool, n)
	graph = make([][]*Edge, n)

	for i := 0; i < n; i++ {
		var isMarked int
		fmt.Fscan(in, &isMarked)
		flag[i] = isMarked == 1
	}

	for edge := 0; edge < n-1; edge++ {
		var a, b int
		fmt.Fscan(in, &a, &b)
		a--
		b--
		ab := NewEdge(a, b)
		ba := NewEdge(b, a)
		ab.rev = ba
		ba.rev = ab
		graph[a] = append(graph[a], ab)
		graph[b] = append(graph[b], ba)
	}

	parent = make([]int, n)
	subtreeCount = make([]int, n)
	countFlagsRec(0, 0)
	for fr := 0; fr < n; fr++ {
		for _, edge := range graph[fr] {
			if parent[edge.to] == fr {
				edge.flagCount = subtreeCount[edge.to]
			} else {
				edge.flagCount = subtreeCount[0] - subtreeCount[edge.fr]
			}
			if edge.flagCount > 1 {
				edge.rev.active = true
				// fmt.Fprintf(out, "1. active edge: %d -> %d. count = %d\n", edge.rev.fr+1, edge.rev.to+1, edge.flagCount)
			}
		}
	}

	for i := 0; i < n; i++ {
		if flag[i] {
			queue = append(queue, i)
			for _, edge := range graph[i] {
				edge.active = true
				// fmt.Fprintf(out, "2. active edge: %d -> %d\n", edge.fr+1, edge.to+1)
			}
		}
	}

	for len(queue) > 0 {
		var node = queue[0]
		queue = queue[1:]

		for _, edge := range graph[node] {
			if flag[edge.to] {
				continue
			}
			if edge.active {
				flag[edge.to] = true
				queue = append(queue, edge.to)
			}
		}
	}

	var ansBytes = make([]byte, 2*n)
	for i := 0; i < n; i++ {
		if flag[i] {
			ansBytes[i<<1] = '1'
		} else {
			ansBytes[i<<1] = '0'
		}
		ansBytes[(i<<1)|1] = ' '
	}
	fmt.Fprintf(out, "%s\n", string(ansBytes))
	out.Flush()
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"runtime/debug"
)

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

	var n, v, w int
	Fscan(in, &n)
	a := make([]bool, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	g := make([][]int, n)
	for i := 1; i < n; i++ {
		Fscan(in, &v, &w)
		v--
		w--
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}
	ans := make([]int8, n)
	cnt := make([]int, n)
	var f func(int, int)
	f = func(v, fa int) {
		if a[v] {
			ans[v] = 1
			cnt[v] = 1
		}
		for _, w := range g[v] {
			if w != fa {
				f(w, v)
				cnt[v] += cnt[w]
				if a[w] || ans[w] > 0 && cnt[w] > 1 {
					ans[v] = 1
				}
			}
		}
	}
	f(0, -1)
	f = func(v, fa int) {
		for _, w := range g[v] {
			if w != fa {
				if a[v] || ans[v] > 0 && cnt[0]-cnt[w] > 1 {
					ans[w] = 1
				}
				f(w, v)
			}
		}
	}
	f(0, -1)
	for _, v := range ans {
		Fprint(out, v, " ")
	}
}

func main() { CF1626E(os.Stdin, os.Stdout) }
func init() { debug.SetGCPercent(-1) }


package main

import (
	"fmt"
)

func main() {
	var str1, str2 string
	fmt.Scan(&str1)
	fmt.Scan(&str2)

	len1, len2 := len(str1), len(str2)

	total, dec := len1+len2, 0

	if len1 > len2 {
		for i := len2 - 1; i >= 0; i-- {
			if str2[i] != str1[len1-(len2-i)] {
				break
			}
			dec += 2
		}
	} else {
		for i := len1 - 1; i >= 0; i-- {
			if str1[i] != str2[len2-(len1-i)] {
				break
			}
			dec += 2
		}
	}
	fmt.Println(total - dec)
}

package main

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

func main(){
	in:=bufio.NewReader(os.Stdin)
	s:=""
	fmt.Fscan(in,&s)
	t:=""
	fmt.Fscan(in,&t)

	sLen:=len(s)
	tLen:=len(t)
	n:=sLen
	if tLen<n{
		n=tLen
	}
	ans:=sLen-tLen
	if ans<0{
		ans=-ans
	}
	for i:=0;i<n;i++{
		if s[sLen-i-1]!=t[tLen-i-1]{
			ans+=(n-i)*2
			break
		}
	}
	fmt.Print(ans)
}

package main

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

//Item eh um elemento da fila de prioridades
type Item struct {
	value    int
	priority int
	index    int
}

//PriorityQueue implmenta a heap interface
type PriorityQueue []*Item

//Len retorna o tamanho da  pq
func (pq PriorityQueue) Len() int { return len(pq) }

//Less verifica se um tem maior priotidade que o outro
func (pq PriorityQueue) Less(i, j int) bool { return pq[i].priority < pq[j].priority }

//Swap troca os elementos de lugar
func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

//Push insere um elemento na pq
func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

//Pop remove um elemento da pq
func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1 //for safety
	*pq = old[0 : n-1]
	return item
}

//update modifica o valor e a prioridade de um item na fila
func (pq *PriorityQueue) update(item *Item, value int, priority int) {
	item.value = value
	item.priority = priority
	heap.Fix(pq, item.index)
}

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

type pair struct {
	first  interface{}
	second interface{}
}

type intPair struct {
	first  int64
	second int64
}

type vertex struct {
	list []intPair
}

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

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

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

/*************************************************************************/
func main() {
	var (
		str1 string
		str2 string
		cnt  int
	)

	fmt.Scan(&str1)
	fmt.Scan(&str2)

	i := len(str1) - 1
	j := len(str2) - 1
	for j >= 0 && i >= 0 && str1[i] == str2[j] {
		i--
		j--
		cnt++
	}
	fmt.Println(len(str1) - cnt + len(str2) - cnt)
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var s, t string
	fmt.Fscan(in, &s)
	fmt.Fscan(in, &t)
	result := len(s) + len(t)
	for i := 0; i < len(s) && i < len(t) && s[len(s)-1-i] == t[len(t)-1-i]; i++ {
		result -= 2
	}
	fmt.Println(result)
}

package main

import (
	"fmt"
)

func main() {
	var (
		s, t string
		ans int
	)

	fmt.Scan(&s)
	fmt.Scan(&t)
	ans = len(s) + len(t)

	/*for s != t {
		if len(s) > len(t) {
			s = s[1:]
		} else {
			t = t[1:]
		}
		ans++
	}*/

	for i := 0; i < len(s) && i < len(t) && t[len(t) - 1 - i] == s[len(s) - 1 - i]; i++ {
		ans -= 2;
	}

	fmt.Println(ans)
}


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for c:=1;c<=t;c++{
		var n int
		fmt.Fscan(in,&n)
		var s string
		fmt.Fscan(in,&s)
		now := []byte(s)
		flag:=false
		for i:=1;i<=len(s);i++{
			if now[i-1] == '0'{
				flag = true
				if i <= len(s)/2{
					fmt.Fprintln(out,i,len(s),i+1,len(s))
				}
				if i > len(s)/2{
					fmt.Fprintln(out,1,i,1,i-1)
				}
				break
			}
		}
		if !flag{
			fmt.Fprintln(out,1,len(s)-1,2,len(s))
		}
	}
}

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)

		var s string
		fmt.Fscan(r, &s)

		fmt.Println(solve(s))
	}
}

func solve(s string) (int, int, int, int) {
	i := 0; j := len(s)/2
	for ; j < len(s);  {
		if s[j] == '0' {
			return i + 1, j + 1, i + 1, j
		}
		i++
		j++
	}

	if s[len(s)/2 - 1] == '0' {
		return len(s)/2, len(s), len(s)/2 + 1, len(s)

	} else {
		return len(s)/2, len(s) - 1, len(s)/2 + 1, len(s)
	}
}

package main

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

func main() {
	// in := bufio.NewReader(os.Stdin)
	// out := os.Stdout
	var t int
	fmt.Scan(&t)
	for c:=1;c<=t;c++{
		var n int
		fmt.Scan(&n)
		var s string
		fmt.Scan(&s)
		now := []byte(s)
		flag:=false
		for i:=1;i<=len(s);i++{
			if now[i-1] == '0'{
				flag = true
				if i <= len(s)/2{
					fmt.Println(i,len(s),i+1,len(s))
				}
				if i > len(s)/2{
					fmt.Println(1,i,1,i-1)
				}
				break
			}
		}
		if !flag{
			fmt.Println(1,len(s)-1,2,len(s))
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var tests int
	fmt.Fscan(in, &tests)
	for test := 0; test < tests; test++ {
		var n int
		var s string
		fmt.Fscan(in, &n, &s)

		beg := 0
		end := n/2 - 1
		found := false
		for end < n {
			prev := beg - 1
			next := end + 1
			if next < n && s[next] == '0' {
				fmt.Fprintln(out, beg+1, next+1, beg+1, end+1)
				found = true
				break
			} else if beg > 0 && s[prev] == '0' {
				fmt.Fprintln(out, prev+1, end+1, beg+1, end+1)
				found = true
				break
			}
			beg++
			end++
		}

		if found {
			continue
		}
		beg = 0
		end = n/2 - 1
	esc:
		for end < n {
			if equalsZero(s[beg : end+1]) {
				fmt.Fprintln(out, beg+1, end+1, 1, n)
				break
			}
			b := beg + 1
			f := end + 1
			for f < n {
				if equals(s[beg:end+1], s[b:f+1]) {
					fmt.Fprintln(out, beg+1, end+1, b+1, f+1)
					break esc
				}
				b++
				f++
			}
			beg++
			end++
		}
	}
}

func equals(s1, s2 string) bool {
	if len(s1) == len(s2) {
		for i := range s1 {
			if s1[i] != s2[i] {
				return false
			}
		}
		return true
	}
	return false
}

func equalsZero(s string) bool {
	for i := range s {
		if s[i] != '0' {
			return false
		}
	}
	return true
}

package main

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

var in *bufio.Reader

func solve() {
	var n int
	fmt.Fscan(in, &n)

	var s string
	fmt.Fscan(in, &s)

	for i := (n + 1) / 2; i < n; i++ {
		if s[i] == '0' {
			fmt.Printf("%d %d %d %d\n", 1, i+1, 1, i)
			return
		}
	}
	for i := n/2 - 1; i >= 0; i-- {
		if s[i] == '0' {
			fmt.Printf("%d %d %d %d\n", i+1, n, i+2, n)
			return
		}
	}
	fmt.Printf("%d %d %d %d\n", 1, (n+1)/2, n/2+1, n)
}

func main() {
	in = bufio.NewReader(os.Stdin)

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

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

package main

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

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) 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 solve(s string) (l1, r1, l2, r2 int) {
	zeroPos := strings.IndexRune(s, '0')
	if zeroPos == -1 {
		return 0, len(s)-2, 1, len(s)-1
	}

	if zeroPos < len(s) / 2 {
		return zeroPos, len(s)-1, zeroPos+1, len(s)-1
	}
	return 0, zeroPos, 0, zeroPos-1
}

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

	for i := 0; i < tests; i++ {
		_, s := stdin.Int(), stdin.Word()
		l1, r1, l2, r2 := solve(s)
		fmt.Println(l1+1, r1+1, l2+1, r2+1)
	}
}

package main

import (
	"fmt"
)

func findPairs(bin string, n int) [4]int {
	m := int(n / 2)

	for i := 0; i < n; i++ {
		if bin[i] == '0' {
			if i < m {
				return [4]int{i + 1, n, i + 2, n}
			} else {
				return [4]int{1, i + 1, 1, i}
			}
		}
	}

	return [4]int{1, n - 1, 2, n}
}

func main() {
	t := 0
	fmt.Scanln(&t)

	for i := 0; i < t; i++ {
		n := 0
		s := ""
		fmt.Scanln(&n)
		fmt.Scanln(&s)

		// ns = append(ns, n)
		// bins = append(bins, s)

		// if t > 10 {
		// 	fmt.Println(n, s)
		// }
		r := findPairs(s, n)
		fmt.Printf("%d %d %d %d\n", r[0], r[1], r[2], r[3])
	}
}

package main

import (
	"fmt"
)

type Visited struct{
	value int64
	from int
	to int
}

var binToDec = binToDecFactory()

func binToDecFactory() func(string)int64 {
	cache := map[string]int64{}

	return func(bin string) int64 {
		if v, ok := cache[bin]; ok {
			return v
		}

		// do the math
		r := int64(0)
		l := len(bin)

		t := int64(1)
		for i := l - 1; i >= 0; i-- {
			if bin[i] == '1' {
				r += t
			}

			t *= 2
		}

		cache[bin] = r
		return r
	}
}

func findPairs(bin string, n int) [4]int {
	var r [4]int
	var visited []Visited

	m := int(n / 2)

	for i := 0; i <= m; i++ {
		if bin[i] == '0' {
			continue
		}

		for j := i + m - 1; j < n; j++ {
			dec := binToDec(bin[i:j+1])

			for _, v := range visited {
				if dec % v.value == 0 {
					return [4]int{i + 1, j + 1, v.from, v.to}
				}

				if v.value % dec == 0 {
					return [4]int{v.from, v.to, i + 1, j + 1}
				}
			}

			visited = append(visited, Visited{dec, i + 1, j + 1})
		}
	}

	return r
}

func main() {
	t := 0
	fmt.Scanf("%d", &t)

	bins := []string{}
	ns := []int{}

	for i := 0; i < t; i++ {
		n := 0
		s := ""
		fmt.Scanf("%d", &n)
		fmt.Scanf("%s", &s)

		ns = append(ns, n)
		bins = append(bins, s)
	}

    fmt.Println(bins, ns)

	for i := 0; i < t; i++ {
		r := findPairs(bins[i], ns[i])
		fmt.Printf("%d %d %d %d\n", r[0], r[1], r[2], r[3])
	}
}

package main

import (
	"fmt"
)

type Visited struct{
	value int64
	from int
	to int
}

var binToDec = binToDecFactory()

func binToDecFactory() func(string)int64 {
	cache := map[string]int64{}

	return func(bin string) int64 {
		if v, ok := cache[bin]; ok {
			return v
		}

		// do the math
		r := int64(0)
		l := len(bin)

		t := int64(1)
		for i := l - 1; i >= 0; i-- {
			if bin[i] == '1' {
				r += t
			}

			t *= 2
		}

		cache[bin] = r
		return r
	}
}

func findPairs(bin string, n int) [4]int {
	var r [4]int
	var visited []Visited

	m := int(n / 2)

	for i := 0; i <= m; i++ {
		if bin[i] == '0' {
			continue
		}

		for j := i + m - 1; j < n; j++ {
			dec := binToDec(bin[i:j+1])

			for _, v := range visited {
				if dec % v.value == 0 {
					return [4]int{i + 1, j + 1, v.from, v.to}
				}

				if v.value % dec == 0 {
					return [4]int{v.from, v.to, i + 1, j + 1}
				}
			}

			visited = append(visited, Visited{dec, i + 1, j + 1})
		}
	}

	return r
}

func main() {
	t := 0
	fmt.Scanf("%d", &t)

	bins := []string{}
	ns := []int{}

	for i := 0; i < t; i++ {
		n := 0
		s := ""
		fmt.Scanf("%d", &n)
		fmt.Scanf("%s", &s)

		ns = append(ns, n)
		bins = append(bins, s)
	}

	for i := 0; i < t; i++ {
		r := findPairs(bins[i], ns[i])
		fmt.Printf("%d %d %d %d\n", r[0], r[1], r[2], r[3])
	}
}

package main

import (
	"fmt"
)

type Visited struct{
	value int64
	from int
	to int
}

var binToDec = binToDecFactory()

func binToDecFactory() func(string)int64 {
	cache := map[string]int64{}

	return func(bin string) int64 {
		if v, ok := cache[bin]; ok {
			fmt.Println("cache", v)
			return v
		}

		// do the math
		r := int64(0)
		l := len(bin)

		t := int64(1)
		for i := l - 1; i >= 0; i-- {
			if bin[i] == '1' {
				r += t
			}

			t *= 2
		}

		cache[bin] = r
		return r
	}
}

func findPairs(bin string, n int) [4]int {
	var r [4]int
	var visited []Visited

	m := int(n / 2)

	for i := 0; i <= m; i++ {
		if bin[i] == '0' {
			continue
		}

		for j := i + m - 1; j < n; j++ {
			dec := binToDec(bin[i:j+1])

			for _, v := range visited {
				if dec % v.value == 0 {
					return [4]int{i + 1, j + 1, v.from, v.to}
				}

				if v.value % dec == 0 {
					return [4]int{v.from, v.to, i + 1, j + 1}
				}
			}

			visited = append(visited, Visited{dec, i + 1, j + 1})
		}
	}

	fmt.Println(visited)
	return r
}

func main() {
	t := 0
	fmt.Scanf("%d", &t)

	for i := 0; i < t; i++ {
		n := 0
		s := ""
		fmt.Scanf("%d", &n)
		fmt.Scanf("%s", &s)

		r := findPairs(s, n)
		fmt.Printf("%d %d %d %d\n", r[0], r[1], r[2], r[3])
	}
}

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)

		var s string
		fmt.Fscan(r, &s)

		fmt.Println(solve(s))
	}
}

func solve(s string) (int, int, int, int) {
	i := 0; j := len(s)/2 + 1
	for ; j < len(s);  {
		if s[j] == '0' {
			return i + 1, j + 1, i + 1, j
		}
		i++
		j++
	}

	if s[len(s)/2 - 1] == '0' {
		return len(s)/2, len(s), len(s)/2 + 1, len(s)

	} else {
		return len(s)/2, len(s) - 1, len(s)/2 + 1, len(s)
	}
}

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)

		var s string
		fmt.Fscan(r, &s)

		fmt.Println(solve(s))
	}
}

func solve(s string) (int, int, int, int) {
	i := 0; j := len(s)/2 + 1
	for ; j < len(s);  {
		if s[j] == '0' {
			return i + 1, j, i + 1, j + 1
		}
		i++
		j++
	}

	if s[len(s)/2 - 1] == '0' {
		return len(s)/2, len(s), len(s)/2 + 1, len(s)

	} else {
		return len(s)/2, len(s) - 1, len(s)/2 + 1, len(s)
	}
}

package main
import (
	"fmt"
	// "sort"
	// "reflect"
)
func puts(x string){
	fmt.Println(x)
}
func print(x int){
	fmt.Print(x);
	fmt.Print(" ");
}
func test_case(){
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	var indx int
	for i,val:=range s{
		var ok rune
		ok=rune(val)
		temp:=string(ok)
		if temp=="0"{
			indx=i
		}

	}
	indx=indx+1
	half:=(len(s)+1)/2
	if(indx>=half+1){
		fmt.Print(1)
		fmt.Print(" ")
		fmt.Print(indx)
		fmt.Print(" ")
		fmt.Print(1)
		fmt.Print(" ")
		fmt.Print(indx-1)
	}else if indx<=half{
		fmt.Print(indx)
		fmt.Print(" ")
		fmt.Print(len(s))
		fmt.Print(" ")
		fmt.Print(indx+1)
		fmt.Print(" ")
		fmt.Print(len(s))
	}
	puts("")

}
func main(){
	var t int
	fmt.Scan(&t)
	for t>0{
		test_case()
		t-=1
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for c:=1;c<=t;c++{
		var s string
		fmt.Fscan(in,&s)
		now := []byte(s)
		flag:=false
		for i:=1;i<=len(s);i++{
			if now[i-1] == '0'{
				flag = true
				if i <= len(s)/2{
					fmt.Fprintln(out,i,len(s),i+1,len(s))
				}
				if i > len(s)/2{
					fmt.Fprintln(out,1,i,1,i-1)
				}
				break
			}
		}
		if !flag{
			fmt.Fprintln(out,1,len(s)-1,2,len(s))
		}
	}
}