// https://serhatgiydiren.github.io

package main

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

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

func solve(test_id int) {
 var n int
 var s,s1,s2 string
 fmt.Fscanf(reader, "%d\n", &n)
 fmt.Fscanf(reader, "%s\n", &s)
 diff_seen := false
 for i := 0 ; i < n ; i++ {
  if diff_seen {
   s1 += "0"
   s2 += string(s[i])
  } else {
   if s[i] == '2' {
    s1 += "1"
    s2 += "1"
   } else if s[i] == '1' {
    s1 += "1"
    s2 += "0"
    diff_seen = true
   } else {
    s1 += "0"
    s2 += "0"
   }
  }
 }
 fmt.Fprintf(writer, "%s\n%s\n", s1, s2)
}

func solve_cases() {
 defer writer.Flush()
 t := 1
 fmt.Fscanf(reader, "%d\n", &t)
 for i := 0 ; i < t ; i++ {
  solve(i)
 }
}

func main() {
 solve_cases()
}

package main

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

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < cases; i++ {
		readLine(reader)
		line := readLine(reader)
		str1 := strings.Builder{}
		str2 := strings.Builder{}
		str1.WriteByte('1')
		str2.WriteByte('1')
		a := 0
		// fmt.Println(line)
		for i := 1; i < len(line); i++ {
			x := line[i] - '0'
			switch x {
			case 0:
				str1.WriteByte('0')
				str2.WriteByte('0')
			case 1:
				if a == 0 {
					str1.WriteByte('1')
					str2.WriteByte('0')
					a = 1
				} else {
					str1.WriteByte('0')
					str2.WriteByte('1')
				}
			case 2:
				if a == 0 {
					str1.WriteByte('1')
					str2.WriteByte('1')
				} else {
					str1.WriteByte('0')
					str2.WriteByte('2')
				}
			}
		}
		fmt.Println(str1.String())
		fmt.Println(str2.String())
	}
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

/*
URL:
https://codeforces.com/problemset/problem/1328/C
*/

package main

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

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

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

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

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

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

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

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

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

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

var (
	t int
	n int
	S []rune
)

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

		solve()
	}
}

func solve() {
	A, B := []rune{}, []rune{}
	flag := false
	for i := 0; i < n; i++ {
		if flag {
			A = append(A, '0')
			B = append(B, S[i])
			continue
		}

		if S[i] == '2' {
			A = append(A, '1')
			B = append(B, '1')
		} else if S[i] == '0' {
			A = append(A, '0')
			B = append(B, '0')
		} else {
			A = append(A, S[i])
			B = append(B, '0')
			flag = true
		}
	}

	fmt.Println(string(A))
	fmt.Println(string(B))
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

package main

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

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

	var T, n int
	var s []byte
o:
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &s)
		t := []byte{}
		for i, b := range s {
			if b == '1' {
				Fprintf(out, "%s1%s\n", t, strings.Repeat("0", n-1-i))
				Fprintf(out, "%s0%s\n", t, s[i+1:])
				continue o
			}
			t = append(t, '0'+b&15/2)
		}
		Fprintf(out, "%s\n", t)
		Fprintf(out, "%s\n", t)
	}
}

package main

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

const N = 50050
var s string
var nt int
var n int
var a, b [N] int

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

	fmt.Fscanf(reader, "%d\n", &nt)
	for kk := 0; kk < nt; kk++ {
		fmt.Fscanf(reader, "%d\n", &n)
		fmt.Fscanf(reader, "%s\n", &s)

		var have = false

		for i := 0; i < n; i++ {
			var value = int(s[i] - '0')
			if value == 0 {
				a[i] = 0
				b[i] = 0
				continue
			}

			if have {
				a[i] = 0
				b[i] = value
			} else {
				if value == 1 {
					a[i] = 1
					b[i] = 0
					have = true
				} else {
					a[i] = 1
					b[i] = 1
				}
			}

		}

		for i := 0; i < n; i++ {
			fmt.Fprintf(writer, "%d", a[i])
		}
		fmt.Fprintf(writer, "\n")
		for i := 0; i < n; i++ {
			fmt.Fprintf(writer, "%d", b[i])
		}
		fmt.Fprintf(writer, "\n")
	}
}

package main

import (
	// "os"
	// "log"
	"fmt"
	"bytes"
)

type Pair struct {
    first, second int
}

func main() {
	/*stdin, err := os.OpenFile("lol.txt", os.O_RDONLY|os.O_CREATE, 0666)

    if err != nil {
        log.Fatal(err)
    }
    os.Stdin = stdin*/

    var t, n int
    var s string

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

        var buffer1, buffer2 bytes.Buffer
        choices := [9]Pair{ {0, 0}, {0, 1}, {1, 0}, {1, 1}, {0, 2}, {2, 0}, {1, 2}, {2, 1}, {2, 2}}
        choices2 := [9]Pair{ {0, 0}, {0, 1}, {1, 0}, {0, 2}, {2, 0}, {1, 1}, {1, 2}, {2, 1}, {2, 2}}

        flag := false
        for j := 0; j < n; j++ {
			z := int(s[j]) - 48

			if flag == true {
				for _, p := range choices2 {
					x, y := p.first, p.second
					if (x + y) % 3 == z {
						buffer2.WriteString(string(x + 48))
						buffer1.WriteString(string(y + 48))
						if x != y {
							flag = true
						}
						break
					}
				}
				continue
			}

			for _, p := range choices {
				x, y := p.first, p.second
				if (x + y) % 3 == z {
					buffer1.WriteString(string(x + 48))
					buffer2.WriteString(string(y + 48))
					if x != y {
						flag = true
					}
					break
				}
			}
		}

		fmt.Println(buffer1.String())
		fmt.Println(buffer2.String())
    }
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		in.ReadLine()
		flag := false
		var a, b string
		for j := 0; j < n; j++ {
			char, _ := in.ReadByte()
			if flag {
				switch char {
				case '0':
					a += "0"
					b += "0"
				case '1':
					a += "1"
					b += "0"
				case '2':
					a += "2"
					b += "0"
				}
			} else {
				switch char {
				case '0':
					a += "0"
					b += "0"
				case '1':
					a += "0"
					b += "1"
					flag = true
				case '2':
					a += "1"
					b += "1"
				}
			}
		}
		in.ReadLine()
		fmt.Fprintln(out, a)
		fmt.Fprintln(out, b)
	}
	out.Flush()
}

package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

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

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

var sc = newScanner()

func main() {
	t := scanInt()
	for i := 0; i < t; i++ {
		n, x := scanInt(), scanString()
		solve(n, x)
	}
}

func solve(n int, x string) {
	a := make([]int, n)
	b := make([]int, n)
	found := false
	for i := 0; i < n; i++ {
		c := int(x[i] - '0')
		if found {
			a[i] = 0
			b[i] = c
			continue
		}
		switch c {
		case 2:
			a[i] = 1
			b[i] = 1
		case 1:
			found = true
			a[i] = 1
			b[i] = 0
		}
	}
	for i := 0; i < n; i++ {
		fmt.Print(a[i])
	}
	fmt.Println()
	for i := 0; i < n; i++ {
		fmt.Print(b[i])
	}
	fmt.Println()
}

// Число называется троичным, если оно содержит только цифры 0, 1 и 2. Например, следующие числа являются
// троичными: 1022, 11, 21, 2002.
// Вам задано длинное троичное число x. Первая (самая левая) цифра числа x гарантированно является 2, остальные цифры
// числа x могут быть 0, 1 или 2 .
//
// Определим троичную операцию XOR ⊙  над двумя троичными числами a и b (оба имеют длину n) как число c=a⊙b
// длины n, где ci=(ai+bi)%3 (где % — операция взятия по модулю).
// Другими словами, сложим соответствующие цифры и возьмем остатки от сумм при делении на 3.
// Например, 10222⊙11021=21210.
// Ваша задача — найти такие троичные числа a и b (оба длины n и без лидирующих нулей), что a⊙b=x и
// max(a,b) — минимально возможный.
//
// Вам нужно ответить на t независимых наборов входных данных.
package main

import (
	"bufio"
	"bytes"
	"flag"
	"fmt"
	"log"
	"os"
	"runtime/pprof"
)

var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")

func calculate(character byte) (byte, byte) {
	switch character {
	case '2':
		return '1', '1'
	case '1':
		return '1', '0'
	case '0':
		return '0', '0'
	default:
		panic(character)
	}
}

func processString(line []byte) ([]byte, []byte) {
	length := len(line)
	a := make([]byte, 0, length)
	b := make([]byte, 0, length)
	var i int
	for i = 0; i < length; i++ {
		a1, b1 := calculate(line[i])
		a = append(a, a1)
		b = append(b, b1)
		if a1 > b1 {
			i++
			break
		}
	}
	for ; i < length; i++ {
		a = append(a, '0')
		b = append(b, line[i])
	}
	return a, b
}

func main() {
	flag.Parse()
	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}
	var n uint64
	var t int64
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	_, err := fmt.Fscanf(reader, "%d\n", &n)
	if err != nil {
		fmt.Printf("err1: %v", err.Error())
		os.Exit(1)
	}
	for ; n > 0; n-- {

		_, err = fmt.Fscanf(reader, "%d\n", &t)
		if err != nil {
			fmt.Printf("err2: %v", err.Error())
			os.Exit(1)
		}
		line, _ := reader.ReadBytes('\n')
		line = bytes.TrimSpace(line)
		a, b := processString(line)
		fmt.Fprintf(writer, "%s\n%s\n", a, b)
	}
	writer.Flush()
}

// Author: sighduck
// URL: https://codeforces.com/contest/1328/problem/C

package main

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

func Solve(n int, x string) (string, string) {
	a := make([]string, n)
	b := make([]string, n)
	gt := false
	for i := 0; i < n; i++ {
		if x[i] == '2' && !gt {
			a[i] = "1"
			b[i] = "1"
		} else if x[i] == '2' && gt {
			a[i] = "0"
			b[i] = "2"
		} else if x[i] == '0' {
			a[i] = "0"
			b[i] = "0"
		} else if x[i] == '1' && !gt {
			a[i] = "1"
			b[i] = "0"
			gt = true
		} else if x[i] == '1' && gt {
			a[i] = "0"
			b[i] = "1"
		}
	}
	return strings.Join(a, ""), strings.Join(b, "")
}

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

	var t int
	fmt.Fscanf(reader, "%d\n", &t)
	for i := 0; i < t; i++ {
		var n int
		var x string
		fmt.Fscanf(reader, "%d\n%s\n", &n, &x)
		a, b := Solve(n, x)
		fmt.Fprintf(writer, "%s\n%s\n", a, b)
	}
}

package main

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

type WordScanner interface {
	NextInt() int
	NextInt64() int64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	return &wordScannerImpl{Scanner: s}
}

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

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

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

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

type writerImpl struct {
	*bufio.Writer
}

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

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

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

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

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		_ = reader.NextString()
		x := reader.NextString()
		a, b := sol(x)
		writer.Printf("%s\n", a)
		writer.Printf("%s\n", b)
	}
}

func sol(x string) (string, string) {
	a := []rune{}
	b := []rune{}
	unbalanced := false // if true, add higher num to b
	for _, r := range x {
		if unbalanced {
			a = append(a, '0')
			b = append(b, r)
		} else {
			if r == '2' {
				a = append(a, '1')
				b = append(b, '1')
			}
			if r == '1' {
				a = append(a, '1')
				b = append(b, '0')
				unbalanced = true
			}
			if r == '0' {
				a = append(a, '0')
				b = append(b, '0')
			}
		}
	}
	return string(a), string(b)
}

package main

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

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

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func scanAllStr() (string, error) {
	str, err := reader.ReadString('\n')
	if err != nil {
		return "", err
	}
	return strings.TrimRight(str, "\n\r"), nil
}

func main() {
	defer writer.Flush()

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

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

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

	var x string
	scanf("%s\n", &x)

	rawX := []byte(x)

	a := make([]byte, length)
	b := make([]byte, length)

	var isDiffered bool
	for i := 0; i< length; i++{
		switch rawX[i] {
		case '0':
				a[i] = '0'
				b[i] = '0'
		case '1':
			if isDiffered {
				a[i] = '0'
				b[i] = '1'
			} else {
				a[i] = '1'
				b[i] = '0'
				isDiffered = true
			}
		case '2':
			if isDiffered {
				a[i] = '0'
				b[i] = '2'
			} else {
				a[i] = '1'
				b[i] = '1'
			}
		}
	}

	printf("%s\n%s\n", a, b)
}

package main

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

var reader io.Reader
var scanner *bufio.Scanner

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

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

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

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}
func 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 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)

	T := NextInt()
	a := make([]byte, 100000)
	b := make([]byte, 100000)

	for t := 0; t < T; t++ {
		n := NextInt()
		s := NextBytes()
		// 0 => 0, 0
		// 1 => 0, 1
		// 2 => 1, 1
		equal := true
		for i := 0; i < n; i++ {
			if s[i] == '0' {
				a[i] = '0'
				b[i] = '0'
			} else if s[i] == '1' {
				if equal {
					a[i] = '0'
					b[i] = '1'
					equal = false
				} else {
					a[i] = '1'
					b[i] = '0'
				}
			} else if s[i] == '2' {
				if equal {
					a[i] = '1'
					b[i] = '1'
				} else {
					a[i] = '2'
					b[i] = '0'
				}
			}
		}
		fmt.Fprintln(out, string(a[:n]))
		fmt.Fprintln(out, string(b[:n]))
	}

}

package main

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

func main() {
	for t := ScanInt64(); t > 0; t-- {
		n, stringValue := ScanInt(), ScanWord()
		firstString, secondString := "", ""
		flag := false

		for i := 0; i < n; i++{
			if stringValue[i] == '2'{
				if flag{
					firstString += "2"
					secondString += "0"
				}else{
					firstString += "1"
					secondString += "1"
				}
			}else if stringValue[i] == '1'{
				firstString += "1"
				secondString += "0"
				if !flag{
					flag = true
					temp := firstString
					firstString = secondString
					secondString = temp
				}
			}else{
				firstString += "0"
				secondString += "0"
			}
		}
		P(firstString)
		P(secondString)
	}

	close(O)
	oWg.Wait()
}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

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

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func swapString(a,b string){

}

package main

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

func main() {
	for t := ScanInt64(); t > 0; t-- {
		n, stringValue := ScanInt(), ScanWord()
		firstString, secondString := "", ""
		flag := false

		for i := 0; i < n; i++{
			if stringValue[i] == '2'{
				if flag{
					firstString += "2"
					secondString += "0"
				}else{
					firstString += "1"
					secondString += "1"
				}
			}else if stringValue[i] == '1'{
				firstString += "1"
				secondString += "0"
				if !flag{
					flag = true
					swapString(firstString, secondString)
				}
			}else{
				firstString += "0"
				secondString += "0"
			}
		}
		P(firstString)
		P(secondString)
	}

	close(O)
	oWg.Wait()
}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

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

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func swapString(a,b string)(string, string){
	return b,a
}

package main

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

func main() {
	for t := ScanInt64(); t > 0; t-- {
		n, stringValue := ScanInt(), ScanWord()
		firstString, secondString := "", ""
		flag := false

		for i := 0; i < n; i++{
			if stringValue[i] == '2'{
				if flag{
					firstString += "2"
					secondString += "0"
				}else{
					firstString += "1"
					secondString += "1"
				}
			}else if stringValue[i] == '1'{
				firstString += "1"
				secondString += "0"
				if !flag{
					flag = true
					swapString(firstString, secondString)
				}
			}else{
				firstString += "0"
				secondString += "0"
			}
		}
		P(firstString)
		P(secondString)
	}

	close(O)
	oWg.Wait()
}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

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

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func swapString(a,b string){
	temp := a
	a = b
	b = temp
}

package main

import (
	// "os"
	// "log"
	"fmt"
	"bytes"
)

type Pair struct {
    first, second int
}

func main() {
	/*stdin, err := os.OpenFile("lol.txt", os.O_RDONLY|os.O_CREATE, 0666)

    if err != nil {
        log.Fatal(err)
    }
    os.Stdin = stdin*/

    var t, n int
    var s string

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

        var buffer1, buffer2 bytes.Buffer
        choices := [9]Pair{ {0, 0}, {0, 1}, {1, 0}, {1, 1}, {0, 2}, {2, 0}, {1, 2}, {2, 1}, {2, 2}}
        choices2 := [9]Pair{ {0, 0}, {0, 1}, {1, 0}, {0, 2}, {2, 0}, {1, 1}, {1, 2}, {2, 1}, {2, 2}}

        flag := false
        for j := 0; j < n; j++ {
			z := int(s[j]) - 48

			if flag == true {
				for _, p := range choices2 {
					x, y := p.first, p.second
					if (x + y) % 3 == z {
						buffer1.WriteString(string(x + 48))
						buffer2.WriteString(string(y + 48))
						if x != y {
							flag = true
						}
						break
					}
				}
				continue
			}

			for _, p := range choices {
				x, y := p.first, p.second
				if (x + y) % 3 == z {
					buffer1.WriteString(string(x + 48))
					buffer2.WriteString(string(y + 48))
					if x != y {
						flag = true
					}
					break
				}
			}
		}

		fmt.Println(buffer1.String())
		fmt.Println(buffer2.String())
    }
}

package main

import (
	// "os"
	// "log"
	"fmt"
	"bytes"
)

type Pair struct {
    first, second int
}

func main() {
	/*stdin, err := os.OpenFile("lol.txt", os.O_RDONLY|os.O_CREATE, 0666)

    if err != nil {
        log.Fatal(err)
    }
    os.Stdin = stdin*/

    var t, n int
    var s string

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

        var buffer1, buffer2 bytes.Buffer
        choices := [9]Pair{ {0, 0}, {0, 1}, {1, 0}, {1, 1}, {0, 2}, {2, 0}, {1, 2}, {2, 1}, {2, 2}}

        for j := 0; j < n; j++ {
			z := int(s[j]) - 48

			for _, p := range choices {
				x, y := p.first, p.second
				if (x + y) % 3 == z {
					buffer1.WriteString(string(x + 48))
					buffer2.WriteString(string(y + 48))
					break
				}
			}
		}

		fmt.Println(buffer1.String())
		fmt.Println(buffer2.String())
    }
}

// Число называется троичным, если оно содержит только цифры 0, 1 и 2. Например, следующие числа являются
// троичными: 1022, 11, 21, 2002.
// Вам задано длинное троичное число x. Первая (самая левая) цифра числа x гарантированно является 2, остальные цифры
// числа x могут быть 0, 1 или 2 .
//
// Определим троичную операцию XOR ⊙  над двумя троичными числами a и b (оба имеют длину n) как число c=a⊙b
// длины n, где ci=(ai+bi)%3 (где % — операция взятия по модулю).
// Другими словами, сложим соответствующие цифры и возьмем остатки от сумм при делении на 3.
// Например, 10222⊙11021=21210.
// Ваша задача — найти такие троичные числа a и b (оба длины n и без лидирующих нулей), что a⊙b=x и
// max(a,b) — минимально возможный.
//
// Вам нужно ответить на t независимых наборов входных данных.
package main

import (
	"bufio"
	"bytes"
	"flag"
	"fmt"
	"log"
	"os"
	"runtime/pprof"
)

var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")

func calculate(character byte) (byte, byte) {
	switch character {
	case '2':
		return '1', '1'
	case '1':
		return '1', '0'
	case '0':
		return '0', '0'
	default:
		panic(character)
	}
}

func processString(line []byte) ([]byte, []byte) {
	length := len(line)
	a := make([]byte, 0, length)
	b := make([]byte, 0, length)
	var i int
	for i = 0; i < length; i++ {
		a1, b1 := calculate(line[i])
		a = append(a, a1)
		b = append(b, b1)
		if a1 > b1 {
			break
		}
	}
	for ; i < length; i++ {
		a = append(a, '0')
		b = append(b, line[i])
	}
	return a, b
}

func main() {
	flag.Parse()
	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}
	var n uint64
	var t int64
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	_, err := fmt.Fscanf(reader, "%d\n", &n)
	if err != nil {
		fmt.Printf("err1: %v", err.Error())
		os.Exit(1)
	}
	for ; n > 0; n-- {

		_, err = fmt.Fscanf(reader, "%d\n", &t)
		if err != nil {
			fmt.Printf("err2: %v", err.Error())
			os.Exit(1)
		}
		line, _ := reader.ReadBytes('\n')
		line = bytes.TrimSpace(line)
		a, b := processString(line)
		fmt.Fprintf(writer, "%s\n%s\n", a, b)
	}
	writer.Flush()
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF528B(_r io.Reader, out io.Writer) {
	type pair struct{ x, y int }
	in := bufio.NewReader(_r)
	var n, ans int
	Fscan(in, &n)
	a := make([]pair, n)
	for i := range a {
		Fscan(in, &a[i].x, &a[i].y)
	}
	sort.Slice(a, func(i, j int) bool { x, y := a[i], a[j]; return x.x+x.y < y.x+y.y })
	cur := pair{-1e9, 0}
	for _, p := range a {
		if p.x-cur.x >= p.y+cur.y {
			ans++
			cur = p
		}
	}
	Fprint(out, ans)
}

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

package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Split(bufio.ScanWords)
	if !sc.Scan() {
		panic("could not scan a word from the reader")
	}
	return sc.Text()
}

func nextInt() int {
	i, e := strconv.Atoi(next())
	if e != nil {
		panic(e)
	}
	return i
}

// import "container/heap"
type item struct {
	from, to int
}

func newItem(f, t int) *item {
	return &item{f, t}
}

type priorityQueue []*item

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

func (pq priorityQueue) Less(i, j int) bool {
	return pq[i].to < pq[j].to
}

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

func (pq *priorityQueue) Push(x interface{}) {
	item := x.(*item)
	*pq = append(*pq, item)
}

func (pq *priorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

func main() {
	N := nextInt()
	pq := make(priorityQueue, 0, 525000)
	heap.Init(&pq)
	for i := 0; i < N; i++ {
		x, w := nextInt(), nextInt()
		heap.Push(&pq, newItem(x-w, x+w))
	}
	res := 0
	pos := -(1 << 30)
	for i := 0; i < N; i++ {
		pt := heap.Pop(&pq).(*item)
		if pos <= pt.from {
			res++
			pos = pt.to
		}
	}
	fmt.Println(res)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF528B(_r io.Reader, out io.Writer) {
	type pair struct{ x, y int }
	in := bufio.NewReader(_r)
	var n, ans int
	Fscan(in, &n)
	a := make([]pair, n)
	for i := range a {
		Fscan(in, &a[i].x, &a[i].y)
	}
	sort.Slice(a, func(i, j int) bool { x, y := a[i], a[j]; return x.x+x.y < y.x+y.y })
	cur := pair{}
	for _, p := range a {
		if p.x >= cur.x {
			ans++
			cur = p
		}
	}
	Fprint(out, ans)
}

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


package main

import (
	. "fmt"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	var qs [10][2][]int
	var f func(d, tp, l, r int)
	f = func(d, tp, l, r int) {
		if d == 10 {
			return
		}
		for i := l; i < r; i++ {
			qs[d][tp] = append(qs[d][tp], i)
		}
		f(d+1, 0, l, (l+r)/2)
		f(d+1, 1, (l+r)/2, r)
	}
	var t, n int
	for Scan(&t); t > 0; t-- {
		qs = [10][2][]int{}
		Scan(&n)
		f(0, 0, 1, 1+n/2)
		f(0, 1, 1+n/2, n+1)
		ans := 0
		for _, q := range qs {
			if len(q[0]) == 0 || len(q[1]) == 0 {
				break
			}
			Print(len(q[0]), len(q[1]))
			for _, a := range q {
				for _, v := range a {
					Print(" ", v)
				}
			}
			Println()
			Scan(&n)
			if n > ans {
				ans = n
			}
		}
		Println(-1, ans)
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	out := bufio.NewWriter(os.Stdout)
	var qs [10][2][]int
	var f func(d, tp, l, r int)
	f = func(d, tp, l, r int) {
		if d == 10 {
			return
		}
		for i := l; i < r; i++ {
			qs[d][tp] = append(qs[d][tp], i)
		}
		f(d+1, 0, l, (l+r)/2)
		f(d+1, 1, (l+r)/2, r)
	}
	var t, n int
	for Scan(&t); t > 0; t-- {
		qs = [10][2][]int{}
		Scan(&n)
		f(0, 0, 1, 1+n/2)
		f(0, 1, 1+n/2, n+1)
		ans := 0
		for _, q := range qs {
			if len(q[0]) == 0 || len(q[1]) == 0 {
				break
			}
			Fprint(out, len(q[0]), len(q[1]))
			for _, a := range q {
				for _, v := range a {
					Fprint(out, " ", v)
				}
			}
			Fprintln(out)
			out.Flush()
			Scan(&n)
			if n > ans {
				ans = n
			}
		}
		Fprintln(out, -1, ans)
		out.Flush()
	}
}

package main

import (
	. "fmt"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	var qs [10][2][]int
	var f func(d, tp, l, r int)
	f = func(d, tp, l, r int) {
		if d == 10 {
			return
		}
		for i := l; i < r; i++ {
			qs[d][tp] = append(qs[d][tp], i)
		}
		f(d+1, 0, l, (l+r)/2)
		f(d+1, 1, (l+r)/2, r)
	}
	var t, n int
	for Scan(&t); t > 0; t-- {
		qs := [10][2][]int{}
		Scan(&n)
		f(0, 0, 1, n/2)
		f(0, 1, n/2, n+1)
		ans := 0
		for _, q := range qs {
			if len(q[0]) == 0 || len(q[1]) == 0 {
				break
			}
			Print(len(q[0]), len(q[1]))
			for _, a := range q {
				for _, v := range a {
					Print(" ", v)
				}
			}
			Println()
			Scan(&n)
			if n > ans {
				ans = n
			}
		}
		Println(-1, ans)
	}
}

package main

import (
	. "fmt"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	var qs [10][2][]int
	var f func(d, tp, l, r int)
	f = func(d, tp, l, r int) {
		if d == 10 {
			return
		}
		for i := l; i < r; i++ {
			qs[d][tp] = append(qs[d][tp], i)
		}
		f(d+1, 0, l, (l+r)/2)
		f(d+1, 1, (l+r)/2, r)
	}
	var t, n int
	for Scan(&t); t > 0; t-- {
		qs = [10][2][]int{}
		Scan(&n)
		f(0, 0, 1, n/2)
		f(0, 1, n/2, n+1)
		ans := 0
		for _, q := range qs {
			if len(q[0]) == 0 || len(q[1]) == 0 {
				break
			}
			Print(len(q[0]), len(q[1]))
			for _, a := range q {
				for _, v := range a {
					Print(" ", v)
				}
			}
			Println()
			Scan(&n)
			if n > ans {
				ans = n
			}
		}
		Println(-1, ans)
	}
}


package main

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

var scanner = bufio.NewScanner(os.Stdin)

func scanNum() int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}
func main() {
	scanner.Split(bufio.ScanWords)
	n := scanNum()
	if n == 3 {
		fmt.Println("1 2 3")
		os.Exit(0)
	}
	a := make([][2]int, n+1)
	for i := 0; i < n; i++ {
		a[i+1] = [2]int{scanNum(), scanNum()}
	}

	res := []int{1}
	for len(res) < n {
		cur := res[len(res)-1]
		c1, c2 := a[cur][0], a[cur][1]
		next := c1

		c2IsNext := (a[c1][0] != c2) && (a[c1][1] != c2)
		if c2IsNext {
			next = c2
		}

		res = append(res, next)
	}

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

package main

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

var scanner = bufio.NewScanner(os.Stdin)

func scanNum() int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}
func main() {
	scanner.Split(bufio.ScanWords)
	n := scanNum()
	a := make([][2]int, n+1)
	for i := 0; i < n; i++ {
		a[i+1] = [2]int{scanNum(), scanNum()}
	}

	res, memo := []int{1}, map[int]bool{1: true}
	for len(res) < n {
		cur := res[len(res)-1]
		c1, c2 := a[cur][0], a[cur][1]
		next := c1

		// I think this memo defense will only be used when n === 3
		if !memo[c1] && !memo[c2] {
			c2IsNext := (a[c1][0] != c2) && (a[c1][1] != c2)
			if c2IsNext {
				next = c2
			}
		} else {
			if memo[c1] {
				next = c2
			}
		}

		res, memo[next] = append(res, next), true
	}

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

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"os"
)

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	pn := make([]int, n + 1)
	pnn := make([]int, n + 1)
	for i := 1;i <= n;i ++ {
		fmt.Fscanf(reader, "%d %d\n", &pn[i], &pnn[i])
	}
	if n == 3 {
		fmt.Printf("1 2 3")
		return
	}

	res := make([]int, n)
	res[0] = 1;
	for i := 0;i < n - 1;i ++ {
		p := res[i]
		if pn[pn[p]] == pnn[p] || pnn[pn[p]] == pnn[p] {
			res[i + 1] = pn[p]
		} else {
			res[i + 1] = pnn[p]
		}
	}
	for i := 0;i < n;i ++ {
		fmt.Printf("%d ", res[i])
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func swap(a ,b *int) {
	tmp := *a
	*a = *b
	*b = tmp
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscanf(buf, "%d\n", &n)
	ans := make([]int ,n)
	mat := make([][]int,n+1)
	for i:=1;i <= n;i++{
		mat[i] = make([]int,2)
		fmt.Fscanf(buf,"%d %d\n",&mat[i][0],&mat[i][1])
	}
	if n == 3{
		fmt.Printf("1 2 3\n")
		return
	}
	ans[0] = 1

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

package main

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

func main() {
	start := time.Now()
	defer func() {
		run := time.Since(start)
		_ = run
		// fmt.Println("Run in", run)
	}()

	var stdin *bufio.Reader
	// LOCAL
	f, _ := os.Open("input.txt")
	stdin = bufio.NewReader(f)

	// ONLINE JUDGE
	stdin = bufio.NewReader(os.Stdin)

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

	var a1 = make([]int, n)
	var a2 = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(stdin, &a1[i], &a2[i])
		a1[i]--
		a2[i]--
	}

	var HasCommon func(int, int) int
	HasCommon = func(i, j int) int {
		switch {
		case a1[i] == a1[j], a1[i] == a2[j]:
			return a1[i]
		case a2[i] == a1[j], a2[i] == a2[j]:
			return a2[i]
		default:
			return -1
		}
	}

	var res = make([]int, n)
	res[0] = 0

	var common = HasCommon(0, a1[0])
	if common == -1 {
		common = HasCommon(0, a2[0])
		res[1] = a2[0]
	} else {
		res[1] = a1[0]
	}

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

	for _, num := range res {
		fmt.Print(num+1, " ")
	}
	fmt.Println()
}

package main

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

var scanner = bufio.NewScanner(os.Stdin)

func scanNum() int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}
func main() {
	scanner.Split(bufio.ScanWords)
	n := scanNum()
	a := make([][2]int, n+1)
	for i := 0; i < n; i++ {
		a[i+1] = [2]int{scanNum(), scanNum()}
	}

	res := []int{1}
	for len(res) < n {
		cur := res[len(res)-1]
		c1, c2 := a[cur][0], a[cur][1]
		c2IsNext := (a[c1][0] != c2) && (a[c1][1] != c2)

		if c2IsNext {
			res = append(res, c2)
		} else {
			res = append(res, c1)
		}
	}

	fmt.Print(res[0])
	for i := 1; i < n; i++ {
		fmt.Printf(" %d", res[i])
	}
	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, k int
		_, _ = fmt.Fscan(in, &n, &k)

		var h [101]int
		for i := 0; i < n; i++ {
			_, _ = fmt.Fscan(in, &h[i])
		}

		grid := makeGrid(h, n)
		ans := -1
		for i := 0; i < k; i++ {
			ans = dfs(&grid, 0, 100, n)
			if ans == -1 {
				break
			}
		}
		fmt.Println(ans)
	}
}

func makeGrid(h [101]int, n int) [101][101]bool {
	var grid [101][101]bool
	for i := 0; i < n; i++ {
		for j := 0; j < h[i]; j++ {
			grid[i][j] = true
		}
	}
	return grid
}

func dfs(grid *[101][101]bool, x, y, n int) int {
	if (y > 0) && (!grid[x][y-1]) {
		return dfs(grid, x, y-1, n)
	}
	if (x < n-1) && (!grid[x+1][y]) {
		return dfs(grid, x+1, y, n)
	}
	if x == n-1 {
		return -1
	}
	grid[x][y] = true
	return x + 1
}

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

var (
	_r = bufio.NewReader(os.Stdin)
	_w = bufio.NewWriter(os.Stdout)
)

func _solve(){
	var n,k int
	fmt.Fscan(_r, &n, &k)
	h := make([]int, n)
	for i:=0;i<n;i++ { fmt.Fscan(_r, &h[i]) }
	var at int
	for k > 0 {
		at = -1
		for i := 0; i < n-1; i++ {
			if(h[i] < h[i+1]){
				at = i
				break
			}
		}
		if at == -1 { break }
		h[at]++
		k--
	}
	if at == -1 {
		fmt.Fprintln(_w, -1)
	} else {
		fmt.Fprintln(_w, at+1)
	}

}

func main() {

	defer _w.Flush()

	var times int
	fmt.Fscan(_r, &times)
	for t:=0;t<times;t++{
		_solve()
	}

}

package main

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

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

var a [105]int
var n, k int

func gogo() int {
	pos := 1
	for pos <= n && a[pos] >= a[pos+1] {
		pos ++
	}
	if pos > n {
		pos = -1
	} else {
		a[pos]++
	}
	return pos
}

func main() {
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		t--
		fmt.Fscan(in, &n, &k)
		a[n+1] = 0
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
		}

		pos := -1
		for i := 1; i <= k; i++ {
			pos = gogo()
			if pos == -1 {
				break;
			}
		}
		fmt.Fprintln(out, pos)
	}
	out.Flush()
}

package main

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

func main() {
	//problemA()
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var cases int
	Fscan(in,&cases)
	for ;cases>0;cases-- {
		var l int
		var k int
		Fscan(in,&l,&k)
		arr:=make([]int,l)
		for i:=0;i<l;i++{
			Fscan(in,&arr[i])
		}
		result:=roll(0,arr,k,0,-1)
		Println(result)
	}

}

func roll(index int, arr []int, k int, count int, previous int)  int{
	if index == len(arr)-1 {
		return -1
	}
	if count == k {
		return previous+1
	}
	if arr[index]<arr[index+1] {
		arr[index]=arr[index]+1
		return roll(0,arr,k,count+1,index)
	} else {
		return roll(index+1,arr,k,count,index)
	}
}

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, k := ScanInt(), ScanInt()
		h := make([]int, n)

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

		ind := -1

		for ; k > 0; k-- {
			for ind = 1; ind < n && h[ind-1] >= h[ind]; ind++ {
			}

			if ind < n {
				h[ind-1]++
			} else {
				ind = -1
				break
			}
		}

		fmt.Println(ind)
	}
}

package main

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

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

	tc := readNum(reader)

	var buf bytes.Buffer

	for tc > 0 {
		tc--
		n, k := readTwoNums(reader)
		H := readNNums(reader, n)
		res := solve(H, k)
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	fmt.Print(buf.String())
}

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

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

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

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

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

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

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

	return i
}

func solve(H []int, K int) int {
	n := len(H)
	// H[i] < H[i+1]
	for K > 0 {
		var i int
		for i+1 < n && H[i] >= H[i+1] {
			i++
		}
		if i+1 == n {
			return -1
		}

		// H[i] < H[i+1]
		x := H[i+1] - H[i]
		if i > 0 {
			x = min(x, H[i-1]-H[i])
		}

		if x == 0 {
			x++
		}

		H[i] += x
		K -= x
		if K <= 0 {
			return i + 1
		}
	}
	//return
	return -1
}

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

package main

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

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

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

	for ; t > 0; t-- {
		fmt.Fscan(in, &n, &k)
		h := make([]int, n+1)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &h[i])
		}

		lowPoint := 0
		rocks := 0
		for {
			lowPoint = 0
			for ; lowPoint < n && h[lowPoint] >= h[lowPoint+1]; lowPoint++ {
			}
			if lowPoint == n {
				fmt.Println(-1)
				break
			}
			if lowPoint == 0 || h[lowPoint-1] >= h[lowPoint+1] {
				rocks += h[lowPoint+1] - h[lowPoint]
				h[lowPoint] = h[lowPoint+1]
			} else {
				if h[lowPoint-1] == h[lowPoint] {
					rocks++
					h[lowPoint]++
				} else {
					rocks += h[lowPoint-1] - h[lowPoint]
					h[lowPoint] = h[lowPoint-1]
				}
			}
			if rocks >= k {
				fmt.Println(lowPoint + 1)
				break
			}
		}
	}
}

package main

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

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

	solve := func(Case int) {
		var n, k int
		Fscan(in, &n, &k)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		for kk := 1; kk <= k; kk++ {
			i := 0
			for ; i < n-1; i++ {
				if a[i] < a[i+1] {
					a[i]++
					break
				}
			}
			if i == n-1 {
				Fprintln(out, -1)
				return
			}
			if kk == k {
				Fprintln(out, i+1)
			}
		}
	}

	var t int
	Fscan(in, &t)
	for Case := 1; Case <= t; Case++ {
		solve(Case)
	}

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

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

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

var (
	_r = bufio.NewReader(os.Stdout)
	_w = bufio.NewWriter(os.Stdout)
)

func _solve(){
	var n,k int
	fmt.Fscan(_r, &n, &k)
	h := make([]int,n)
	for i:=0;i<n;i++{ fmt.Fscan(_r, &h[i]) }
	at := -1
	for k > 0 {
		for i:=0;i<n-1;i++{
			if(h[i]<h[i+1]){
				at=i
				break
			}
		}
		if at == -1 { break }
		h[at]++
		k--
	}
	fmt.Fprintln(_w, at+1)

}

func main() {

	defer _w.Flush()

	var times int
	fmt.Fscan(_r, &times)
	for t:=0;t<times;t++{
		_solve()
	}

}


package main

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

var _, _, _ = main, rw, do

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

func rw(r io.Reader, w io.Writer) {
	var t int
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		var n int
		fmt.Fscan(r, &n)
		a := make([]int, n)
		for i := range a {
			fmt.Fscan(r, &a[i])
		}
		w1 := do(n, a)
		fmt.Fprintln(w, w1)
	}
}

func do(n int, a []int) int {
	m := make(map[int]bool)
	s := 0
	d := 0
	for i := range a {
		m[s] = true
		s ^= a[i]
		if m[s] {
			d++
			s = 0
			m = make(map[int]bool)
		}
	}
	return n - d
}

package main

import (
	"fmt"
	"os"
)

func main() {
	in := os.Stdin
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		temp := make([]int, n+1)
		f := make([]int, n+1)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &temp[i+1])
			temp[i+1] = temp[i+1] ^ temp[i]
		}
		mp := make(map[int]int)
		mp[0] = 0
		for j := 0; j < n; j++ {
			f[j+1] = f[j] + 1
			if value, ok := mp[temp[j+1]]; ok {
				f[j+1] = min(f[j+1], f[value]+j-value)
			}
			mp[temp[j+1]] = j + 1

		}
		fmt.Println(f[n])
	}
}

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

package main

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

const MOD int64 = 1000000007

var n int

var a[]int

// ByAge implements sort.Interface based on the Age field.
type ByV []*pair

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

func main() {

	read := bufio.NewReader(os.Stdin)

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

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

		fmt.Fscan(read, &n)

		a = make([]int,  n)

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

		fmt.Println(solve())
	}
}

type pair struct {
	v int
	idx []int
}

func solve() int {
	var mps [2]map[int]int

	mps[0] = make(map[int]int)
	mps[1] = make(map[int]int)

	mps[0][a[0]] = 0

	cnt := 0

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

		for k, v := range mps[cnt] {
			if k == 0 {
				if mps[cnt ^ 1][a[i]] == 0 {
					mps[cnt ^ 1][a[i]] = v
				} else {
					mps[cnt ^ 1][a[i]] = min(v, mps[cnt ^ 1][a[i]])
				}

			} else {
				if mps[cnt ^ 1][a[i]] == 0 {
					mps[cnt ^ 1][a[i]] = v + 1
				} else {
					mps[cnt ^ 1][a[i]] = min(v + 1, mps[cnt ^ 1][a[i]])
				}

				if mps[cnt ^ 1][k ^ a[i]] == 0 {
					mps[cnt ^ 1][k ^ a[i]] = v + 1
				} else {
					mps[cnt ^ 1][k ^ a[i]] = min(v + 1, mps[cnt ^ 1][k ^ a[i]])
				}

			}
		}

		for k := range mps[cnt] {
			delete(mps[cnt], k)
		}

		cnt ^= 1
	}

	var m int = n

	var mp map[int]int

	if len(mps[0]) > 0 {
		mp = mps[0]

	} else {
		mp = mps[1]
	}

	for k, v := range mp {
		if k == 0 {
			m = min(m , v)
		} else {
			m = min(m , v + 1)
		}
	}

	return m
}

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

	return b
}

//1 2 4 4 3

//0 - 1
//3 - 1

//IQ = 87

//........105....99...87..87..87..87.87.......87....

//            86

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

package main

import (
	"fmt"
	"os"
)

func main() {
	in := os.Stdin
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		temp := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &temp[i])
		}
		ans := 0
		j := 0
		for j < n {
			if temp[j] == 0 {
				j++
				continue
			}
			s := j
			j++
			for j < n {
				if temp[j] == temp[s] {
					j++
				} else {
					break
				}
			}
			if j == n {
				ll := j - s + 1
				ans += ll / 2
			} else if temp[j] == 0 {
				ll := j - s + 1
				ans += ll / 2
			} else {
				if j+1 < n && temp[j]^temp[s] == temp[j+1] {
					ll := j - s + 2
					ans += ll / 2
					temp[j] = temp[j] ^ temp[s]
				} else {
					ll := j - s + 1
					if ll%2 == 1 {
						ans += (ll - 1) / 2
					} else {
						ans += ll / 2
						temp[j] = temp[j] ^ temp[s]
					}
				}
			}

		}
		fmt.Println(ans)
	}
}

package main

import (
	"fmt"
	"os"
)

func main() {
	in := os.Stdin
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		temp := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &temp[i])
		}
		ans := 0
		j := 0
		for j < n {
			if temp[j] == 0 {
				j++
				continue
			}
			s := j
			j++
			for j < n {
				if temp[j] == temp[s] {
					j++
				} else {
					break
				}
			}
			if j == n {
				ll := j - s + 1
				ans += ll / 2
			} else {
				if temp[j] != 0 && (j+1 < n && temp[j]^temp[s] == temp[j+1]) {
					ll := j - s + 2
					ans += ll / 2
					temp[j] = temp[j] ^ temp[s]
				} else {
					ll := j - s + 1
					if ll%2 == 1 || temp[j] == 0 {
						ans += (ll - 1) / 2
					} else {
						ans += ll / 2
						temp[j] = temp[j] ^ temp[s]
					}
				}
			}

		}
		fmt.Println(ans)
	}
}

package main

import (
	"fmt"
	"os"
)

func main() {
	in := os.Stdin
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		temp := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &temp[i])
		}
		ans := 0
		j := 0
		for j < n {
			if temp[j] == 0 {
				j++
				continue
			}
			s := j
			j++
			for j < n {
				if temp[j] == temp[s] {
					j++
				} else {
					break
				}
			}
			if j == n {
				ll := j - s + 1
				ans += ll / 2
			} else {
				if j+1 < n && temp[j]^temp[s] == temp[j+1] {
					ll := j - s + 2
					ans += ll / 2
					temp[j] = temp[j] ^ temp[s]
				} else {
					ll := j - s + 1
					if ll%2 == 0 {
						ans += ll / 2
						temp[j] = temp[j] ^ temp[s]
					} else {
						ans += (ll - 1) / 2
					}
				}
			}

		}
		fmt.Println(ans)
	}
}

package main

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

const MOD int64 = 1000000007

var n int

var a[]int

// ByAge implements sort.Interface based on the Age field.
type ByV []*pair

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

func main() {

	read := bufio.NewReader(os.Stdin)

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

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

		fmt.Fscan(read, &n)

		a = make([]int,  n)

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

		fmt.Println(solve())
	}
}

type pair struct {
	v int
	idx []int
}

func solve() int {
	var mps [2]map[int]int

	mps[0] = make(map[int]int)
	mps[1] = make(map[int]int)

	mps[0][a[0]] = 0

	cnt := 0

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

		for k, v := range mps[cnt] {
			if k == 0 {
				mps[cnt ^ 1][a[i]] = v

			} else {
				if mps[cnt ^ 1][a[i]] == 0 {
					mps[cnt ^ 1][a[i]] = v + 1
				} else {
					mps[cnt ^ 1][a[i]] = min(v + 1, mps[cnt ^ 1][a[i]])
				}

				if mps[cnt ^ 1][k ^ a[i]] == 0 {
					mps[cnt ^ 1][k ^ a[i]] = v + 1
				} else {
					mps[cnt ^ 1][k ^ a[i]] = min(v + 1, mps[cnt ^ 1][k ^ a[i]])
				}

			}
		}

		for k := range mps[cnt] {
			delete(mps[cnt], k)
		}

		cnt ^= 1
	}

	var m int = n

	var mp map[int]int

	if len(mps[0]) > 0 {
		mp = mps[0]

	} else {
		mp = mps[1]
	}

	for k, v := range mp {
		if k == 0 {
			m = min(m , v)
		} else {
			m = min(m , v + 1)
		}
	}

	return m
}

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

	return b
}

//1 2 4 4 3

//0 - 1
//3 - 1

//IQ = 87

//........105....99...87..87..87..87.87.......87....

//            86

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

package main

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

const MOD int64 = 1000000007

var n int

var a[]int

// ByAge implements sort.Interface based on the Age field.
type ByV []*pair

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

func main() {

	read := bufio.NewReader(os.Stdin)

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

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

		fmt.Fscan(read, &n)

		a = make([]int,  n)

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

		fmt.Println(solve())
	}
}

type pair struct {
	v int
	idx []int
}

func solve() int {
	var mps [2]map[int]int

	mps[0] = make(map[int]int)
	mps[1] = make(map[int]int)

	mps[0][a[0]] = 0

	cnt := 0

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

		for k, v := range mps[cnt] {
			if k == 0 {
				mps[cnt ^ 1][a[i]] = v

			} else {
				if mps[cnt ^ 1][a[i]] == 0 {
					mps[cnt ^ 1][a[i]] = v + 1
				} else {
					mps[cnt ^ 1][a[i]] = min(v + 1, mps[cnt ^ 1][a[i]])
				}

				if mps[cnt ^ 1][k ^ a[i]] == 0 {
					mps[cnt ^ 1][k ^ a[i]] = v + 1
				} else {
					mps[cnt ^ 1][k ^ a[i]] = min(v + 1, mps[cnt ^ 1][k ^ a[i]])
				}

			}
		}

		for k := range mps[cnt] {
			delete(mps[cnt], k)
		}

		cnt ^= 1
	}

	var m int = n + 1

	var mp map[int]int

	if len(mps[0]) > 0 {
		mp = mps[0]

	} else {
		mp = mps[1]
	}

	for k, v := range mp {
		if k == 0 {
			m = min(m , v)
		} else {
			m = min(m , v + 1)
		}
	}

	return m
}

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

	return b
}

//1 2 4 4 3

//0 - 1
//3 - 1

//IQ = 87

//........105....99...87..87..87..87.87.......87....

//            86

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


/*********************************************************************************
*     File Name           :     C.go
*     Created By          :     YIMMON, yimmon.zhuang@gmail.com
*     Creation Date       :     [2014-03-29 23:16]
*     Last Modified       :     [2014-03-29 23:27]
*     Description         :
**********************************************************************************/

package main

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

func main() {
    scanner.Split(bufio.ScanWords)

    n := scanner.NextInt()
    var a = make([][]int8, n)
    for i := 0; i < n; i++ {
        a[i] = make([]int8, n)
        for j := 0; j < n; j++ {
            a[i][j] = int8(scanner.NextInt())
        }
    }
    ans := int8(0)
    for i := 0; i < n; i++ {
        for j := 0; j < n; j++ {
            ans ^= a[i][j] & a[j][i]
        }
    }
    q := scanner.NextInt()
    res := make([]byte, 0)
    for i := 0; i < q; i++ {
        t := scanner.NextInt()
        if t == 3 {
            res = append(res, byte(ans+'0'))
        } else {
            scanner.NextInt()
            ans ^= 1
        }
    }
    fmt.Println(string(res))
}

type Scanner struct {
    *bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) Next() string {
    if !self.Scan() {
        panic(self.Err())
    }
    return self.Text()
}

func (self *Scanner) NextInt() int {
    x, err := strconv.Atoi(self.Next())
    if err != nil {
        panic(err)
    }
    return x
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    writer := bufio.NewWriter(os.Stdout)

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

    n := ScanInt()
    ans := 0
    for i := 0; i < n; i++ {
        for j := 0; j < n; j++ {
            a := ScanInt()
            if i == j { ans ^= a }
        }
    }
    q := ScanInt()
    for ; q > 0; q-- {
        t := ScanInt()
        if t == 3 {
            a := strconv.Itoa(ans)
            if a != "" {
                writer.WriteString(a)
            }
        } else {
            _ = ScanInt()
            ans ^= 1
        }
    }
    writer.WriteRune('\n')
    writer.Flush()
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    writer := bufio.NewWriter(os.Stdout)

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

    n := ScanInt()
    ans := 0
    for i := 0; i < n; i++ {
        for j := 0; j < n; j++ {
            a := ScanInt()
            if i == j { ans ^= a }
        }
    }
    q := ScanInt()
    for ; q > 0; q-- {
        t := ScanInt()
        if t == 3 {
            writer.WriteString(strconv.Itoa(ans))
        } else {
            _ = ScanInt()
            ans ^= 1
        }
    }
    writer.WriteRune('\n')
    writer.Flush()
}

package main

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

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

func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt()

	a := make([][]int, n)
	var result []uint8

	for row:=0; row<n; row++ {
		a[row] = make([]int, n)
		for col:=0; col<n; col++ {
			a[row][col] = nextInt()
		}
	}

	unsusualSquare := 0

	for i:=0; i<n; i++ {
		unsusualSquare += a[i][i]
	}

	unsusualSquare %= 2

	numberOfQueries := nextInt()

	for query:=0; query<numberOfQueries; query++ {
		typeOfQuery := nextInt()

		switch typeOfQuery {
		// case 1:
		// 	// row := nextInt() - 1
		// 	// for i:=0; i<n; i++ {
		// 	// 	a[row][i] = 1 - a[row][i]
		// 	// }
		// case 2:
			// col := nextInt() - 1
			// for i:=0; i<n; i++ {
			// 	a[i][col] = 1 - a[i][col]
			// }
		case 1,2 :
			unsusualSquare = 1 - unsusualSquare
			_ = nextInt()
		case 3:
			// unsusualSquare := 0
			// for i:=0; i<n; i++ {
			// 	for j:=0; j<n; j++ {
			// 		unsusualSquare += (a[i][j] * a[j][i]) % 2
			// 	}
			// }
			// print(unsusualSquare%2)
			// print(unsusualSquare)
			result = append(result, uint8(unsusualSquare + '0'))
		}
	}
	// println()
	println(string(result))
}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

package main

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

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

func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt()

	a := make([][]int, n)
	var result []uint8

	for row:=0; row<n; row++ {
		a[row] = make([]int, n)
		for col:=0; col<n; col++ {
			a[row][col] = nextInt()
		}
	}

	unsusualSquare := 0

	for i:=0; i<n; i++ {
		unsusualSquare += a[i][i]
	}

	unsusualSquare %= 2

	numberOfQueries := nextInt()

	for query:=0; query<numberOfQueries; query++ {
		typeOfQuery := nextInt()

		// switch typeOfQuery {

		// case 1,2 :
		// 	unsusualSquare = 1 - unsusualSquare
		// 	_ = nextInt()
		// case 3:
		// 	// print(unsusualSquare)
		// 	result = append(result, uint8(unsusualSquare + '0'))
		// }

		if typeOfQuery == 3 {
			// result = append(result, uint8(unsusualSquare + '0'))
			result = append(result, []uint8(strconv.Itoa(unsusualSquare))...)
		} else {
			unsusualSquare = 1 - unsusualSquare
			_ = nextInt()
		}
	}
	println(string(result))
}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

package main

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

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

func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt()

	// a := make([][]int, n)
	var result []uint8
	a, unsusualSquare := 0, 0

	for row:=0; row<n; row++ {
		// a[row] = make([]int, n)
		for col:=0; col<n; col++ {
			// a[row][col] = nextInt()
			a = nextInt()
			if row == col {
				unsusualSquare += a
			}
		}
	}

	// for i:=0; i<n; i++ {
	// 	unsusualSquare += a[i][i]
	// }

	unsusualSquare %= 2

	numberOfQueries := nextInt()

	for query:=0; query<numberOfQueries; query++ {
		typeOfQuery := nextInt()

		// switch typeOfQuery {

		// case 1,2 :
		// 	unsusualSquare = 1 - unsusualSquare
		// 	_ = nextInt()
		// case 3:
		// 	// print(unsusualSquare)
		// 	result = append(result, uint8(unsusualSquare + '0'))
		// }

		if typeOfQuery == 3 {
			// result = append(result, uint8(unsusualSquare + '0'))
			result = append(result, []uint8(strconv.Itoa(unsusualSquare))...)
		} else {
			unsusualSquare = 1 - unsusualSquare
			_ = nextInt()
		}
	}
	println(string(result))
	// println()
}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

package main

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

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

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt()

	a := make([][]int, n)

	for row:=0; row<n; row++ {
		a[row] = make([]int, n)
		for col:=0; col<n; col++ {
			a[row][col] = nextInt()
		}
	}

	unsusualSquare := 0

	for i:=0; i<n; i++ {
		unsusualSquare += a[i][i]
	}

	unsusualSquare %= 2

	numberOfQueries := nextInt()

	for query:=0; query<numberOfQueries; query++ {
		typeOfQuery := nextInt()

		switch typeOfQuery {
		// case 1:
		// 	// row := nextInt() - 1
		// 	// for i:=0; i<n; i++ {
		// 	// 	a[row][i] = 1 - a[row][i]
		// 	// }
		// case 2:
			// col := nextInt() - 1
			// for i:=0; i<n; i++ {
			// 	a[i][col] = 1 - a[i][col]
			// }
		case 1,2 :
			unsusualSquare = 1 - unsusualSquare
			_ = nextInt()
		case 3:
			// unsusualSquare := 0
			// for i:=0; i<n; i++ {
			// 	for j:=0; j<n; j++ {
			// 		unsusualSquare += (a[i][j] * a[j][i]) % 2
			// 	}
			// }
			// print(unsusualSquare%2)
			print(unsusualSquare)
		}
	}
	println()
}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    writer := bufio.NewWriter(os.Stdout)
    var n,q int
    fmt.Scan(&n)
    ans := 0
    for i := 0; i < n; i++ {
        for j := 0; j < n; j++ {
            scanner.Scan()
            if i == j {
                a, _ := strconv.Atoi(scanner.Text())
                ans ^= a
            }
        }
    }
    fmt.Scan(&q)
    for ; q > 0; q-- {
        scanner.Scan()
        t, _ := strconv.Atoi(scanner.Text())
        if t == 3 {
            writer.WriteString(strconv.Itoa(ans))
        } else {
            scanner.Scan()
            ans ^= 1
        }
    }
    writer.WriteRune('\n')
    writer.Flush()
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    writer := bufio.NewWriter(os.Stdout)
    var n,q int
    fmt.Scan(&n)
    ans := 0
    for i := 0; i < n; i++ {
        for j := 0; j < n; j++ {
            scanner.Scan()
            if i == j {
                a, _ := strconv.Atoi(scanner.Text())
                ans ^= a
            }
        }
    }
    fmt.Scan(&q)
    for ; q > 0; q-- {
        scanner.Scan()
        t, _ := strconv.Atoi(scanner.Text())
        if t == 3 {
            a := strconv.Itoa(ans)
            if a != "" {
                writer.WriteString(a)
            }
        } else {
            scanner.Scan()
            ans ^= 1
        }
    }
    writer.WriteRune('\n')
    writer.Flush()
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    writer := bufio.NewWriter(os.Stdout)
    var n,q int
    fmt.Scan(&n)
    ans := 0
    for i := 0; i < n; i++ {
        for j := 0; j < n; j++ {
            scanner.Scan()
            if i == j {
                a, _ := strconv.Atoi(scanner.Text())
                ans ^= a
            }
        }
    }
    fmt.Scan(&q)
    for ; q > 0; q-- {
        for scanner.Scan() { if (scanner.Text() == "1") || (scanner.Text() == "2") || (scanner.Text() == "3") { break } }
        t, _ := strconv.Atoi(scanner.Text())
        if t == 3 {
            writer.WriteString(strconv.Itoa(ans))
        } else {
            scanner.Scan()
            ans ^= 1
        }
    }
    writer.WriteRune('\n')
    writer.Flush()
}