Pasha loves to send strictly positive integers to his friends. Pasha cares about security, therefore when he wants to send an integer $$$n$$$, he encrypts it in the following way: he picks three integers $$$a$$$, $$$b$$$ and $$$c$$$ such that $$$l \leq a,b,c \leq r$$$, and then he computes the encrypted value $$$m = n \cdot a + b - c$$$.Unfortunately, an adversary intercepted the values $$$l$$$, $$$r$$$ and $$$m$$$. Is it possible to recover the original values of $$$a$$$, $$$b$$$ and $$$c$$$ from this information? More formally, you are asked to find any values of $$$a$$$, $$$b$$$ and $$$c$$$ such that  $$$a$$$, $$$b$$$ and $$$c$$$ are integers,  $$$l \leq a, b, c \leq r$$$,  there exists a strictly positive integer $$$n$$$, such that $$$n \cdot a + b - c = m$$$.

The first line contains the only integer $$$t$$$ ($$$1 \leq t \leq 20$$$) — the number of test cases. The following $$$t$$$ lines describe one test case each. Each test case consists of three integers $$$l$$$, $$$r$$$ and $$$m$$$ ($$$1 \leq l \leq r \leq 500\,000$$$, $$$1 \leq m \leq 10^{10}$$$). The numbers are such that the answer to the problem exists.

For each test case output three integers $$$a$$$, $$$b$$$ and $$$c$$$ such that, $$$l \leq a, b, c \leq r$$$ and there exists a strictly positive integer $$$n$$$ such that $$$n \cdot a + b - c = m$$$. It is guaranteed that there is at least one possible solution, and you can output any possible combination if there are multiple solutions.

NoteIn the first example $$$n = 3$$$ is possible, then $$$n \cdot 4 + 6 - 5 = 13 = m$$$. Other possible solutions include: $$$a = 4$$$, $$$b = 5$$$, $$$c = 4$$$ (when $$$n = 3$$$); $$$a = 5$$$, $$$b = 4$$$, $$$c = 6$$$ (when $$$n = 3$$$); $$$a = 6$$$, $$$b = 6$$$, $$$c = 5$$$ (when $$$n = 2$$$); $$$a = 6$$$, $$$b = 5$$$, $$$c = 4$$$ (when $$$n = 2$$$).In the second example the only possible case is $$$n = 1$$$: in this case $$$n \cdot 2 + 2 - 3 = 1 = m$$$. Note that, $$$n = 0$$$ is not possible, since in that case $$$n$$$ is not a strictly positive integer.

package main

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

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

	tc := readNum(reader)

	for tc > 0 {
		tc--
		s, _ := reader.ReadBytes('\n')
		var l, r int
		var m uint64
		pos := readInt(s, 0, &l)
		pos = readInt(s, pos+1, &r)
		readUint64(s, pos+1, &m)
		a, b, c := solve(l, r, int64(m))
		fmt.Printf("%d %d %d\n", a, b, c)
	}
}

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(l, r int, m int64) (a int, b int, c int) {
	for a = l; a <= r; a++ {
		N := (m + int64(r-l)) / int64(a)
		if N > 0 {
			//find a n
			x := m - N*int64(a)
			// x = b - c
			if x == 0 {
				b = l
				c = l
				return
			}
			if x > 0 && x <= int64(r-l) {
				b = int(x) + l
				c = l
				return
			}

			if x < 0 && x >= int64(l-r) {
				b = int(x) + r
				c = r
				return
			}
		}
	}

	return
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	buffer := make([]byte, 1024*1024)
	scanner.Buffer(buffer, 3*1024*1024)
	scanner.Split(bufio.ScanWords)

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

	var t, l, r, m, a, b, c uint64

	for t = input(); t > 0; t-- {
		l = input()
		r = input()
		m = input()

		diff := r - l

		var p, q int

		for i := l; i <= r; i++ {
			if m%i <= diff {
				p = int(i)
				q = int(m % i)
				break
			} else if i-m%i <= diff {
				p = int(i)
				q = -int(i - m%i)
			}
		}
		a = uint64(p)
		if m/a == 0 {
			a = l
			b = l
			c = l + a - m
		} else if q < 0 {
			b = l
			c = l - uint64(q)
		} else {
			b = r
			c = r - uint64(q)
		}

		fmt.Println(a, b, c)
	}
}

package main

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

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < cases; i++ {
		var l, r, m int64
		line := readLine(reader)
		strs := strings.Split(string(line), " ")
		l, _ = strconv.ParseInt(strs[0], 10, 64)
		r, _ = strconv.ParseInt(strs[1], 10, 64)
		m, _ = strconv.ParseInt(strs[2], 10, 64)
		leftMax := r - l
		var a, b, c int64
		for i := l; i <= r; i++ {
			left := m % i
			if m < i {
				left = m - i
			}
			// fmt.Println(l, r, i, left)
			if left <= leftMax && left >= 0 {
				c, b = l, left+l
				a = i
				break
			}
			if left < 0 {
				a = i
				c, b = r, r + left
				break
			}
			if left+leftMax >= i {
				a = i
				c, b = r, r-(i-left)
				break
			}
		}
		fmt.Println(a, b, c)
	}
}

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
}

package main

import "fmt"

func solve(l, r, m int64) []int64 {
	// given l r m, find abc
	// n > 0
	// m = n * a + b -c
	//	m = n*a + x
	// m-x = n * a && (m-x) % a == 0

	// m is positive
	// n * a > b - c
	for a := l; a <= r; a++ {
		md1 := m % a
		// either md1
		if (m-md1 != 0) && md1 <= r-l {
			return []int64{a, l + md1, l}
		}

		// a + md1
		md2 := a - md1
		if md2 <= r-l {
			return []int64{a, l, l + md2}
		}
	}
	// should not hit
	return []int64{}
}

func main() {
	var TC int
	fmt.Scanf("%d\n", &TC)

	for TC != 0 {
		var l, r, m int64
		fmt.Scanf("%d %d %d\n", &l, &r, &m)
		ans := solve(l, r, m)
		fmt.Printf("%d %d %d\n", ans[0], ans[1], ans[2])
		TC--
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1379B(in io.Reader, out io.Writer) {
	var t, l, r, m int64
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &l, &r, &m)
		ml, mr := m+l-r, m+r-l
		for a := l; a <= r; a++ {
			if na := mr - mr%a; na >= ml {
				if na < m {
					Fprintln(out, a, r, r+na-m)
				} else {
					Fprintln(out, a, l, l+na-m)
				}
				break
			}
		}
	}
}

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

package main

import (
	. "fmt"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	var t, l, r, m int64
	for Scan(&t); t > 0; t-- {
		Scan(&l, &r, &m)
		ml, mr := m+l-r, m+r-l
		for a := l; a <= r; a++ {
			if na := mr - mr%a; na >= ml {
				if na < m {
					Println(a, r, r+na-m)
				} else {
					Println(a, l, l+na-m)
				}
				break
			}
		}
	}
}

package main

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

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

	tc := readNum(reader)

	for tc > 0 {
		tc--
		s, _ := reader.ReadBytes('\n')
		var l, r int
		var m uint64
		pos := readInt(s, 0, &l)
		pos = readInt(s, pos+1, &r)
		readUint64(s, pos+1, &m)
		a, b, c := solve(l, r, int64(m))
		fmt.Printf("%d %d %d\n", a, b, c)
	}
}

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(l, r int, m int64) (a int, b int, c int) {
	for a = l; a <= r; a++ {
		N := (m + int64(r-l)) / int64(a)
		if N > 0 {
			//find a n
			x := m - N*int64(a)
			// x = b - c
			if x == 0 {
				b = l
				c = l
				return
			}
			if x > 0 && x <= int64(r-l) {
				b = int(x) + l
				c = l
				return
			}

			if x < 0 && x >= int64(l-r) {
				b = int(x) + l
				c = l
				return
			}
		}
	}

	return
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	buffer := make([]byte, 1024*1024)
	scanner.Buffer(buffer, 3*1024*1024)
	scanner.Split(bufio.ScanWords)

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

	var t, l, r, m, a, b, c uint64

	for t = input(); t > 0; t-- {
		l = input()
		r = input()
		m = input()

		diff := r - l

		var p, q int

		for i := l; i <= r; i++ {
			if m%i <= diff {
				p = int(i)
				q = int(m % i)
				break
			} else if i-m%i <= diff {
				p = int(i)
				q = -int(i - m%i)
			}
		}
		a = uint64(p)
		if m/a == 0 {
			b = l
			c = l + a - 1
		} else if q < 0 {
			b = l
			c = l - uint64(q)
		} else {
			b = r
			c = r - uint64(q)
		}

		fmt.Println(a, b, c)
	}
}

package main

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

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < cases; i++ {
		var l, r, m int64
		line := readLine(reader)
		strs := strings.Split(string(line), " ")
		l, _ = strconv.ParseInt(strs[0], 10, 64)
		r, _ = strconv.ParseInt(strs[1], 10, 64)
		m, _ = strconv.ParseInt(strs[2], 10, 64)
		leftMax := r - l
		var a, b, c int64
		for i := l; i <= r; i++ {
			left := m % i
			if m < i {
				left = m - i
			}
			// fmt.Println(l, r, i, left)
			if left <= leftMax && left >= 0 {
				c, b = l, left+l
				a = i
				break
			}
			if left < 0 {
				a = i
				c, b = r, r + left
				break
			}
			if left+leftMax >= i {
				a = i
				c, b = r-(i-l), r
				break
			}
		}
		fmt.Println(a, b, c)
	}
}

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
}

package main

import "fmt"

func solve(l, r, m int) []int {
	// given l r m, find abc
	// n > 0
	// m = n * a + b -c
	// 1 <= a, b, c <= 500000

	// m is positive
	// n * a > b - c
	for a := l; a <= r; a++ {
		for b := l; b <= r; b++ {
			for c := l; c <= r; c++ {
				sum := m + c - b
				if sum%a == 0 && ((sum)/a) > 0 {
					return []int{a, b, c}
				}
			}
		}
	}
	// should not hit
	return []int{}
}

func main() {
	var TC int
	fmt.Scanf("%d\n", &TC)

	for TC != 0 {
		var l, r, m int
		fmt.Scanf("%d %d %d\n", &l, &r, &m)
		fmt.Println(solve(l, r, m))
		TC--
	}
}


Polycarp is a big lover of killing time in social networks. A page with a chatlist in his favourite network is made so that when a message is sent to some friend, his friend's chat rises to the very top of the page. The relative order of the other chats doesn't change. If there was no chat with this friend before, then a new chat is simply inserted to the top of the list.Assuming that the chat list is initially empty, given the sequence of Polycaprus' messages make a list of chats after all of his messages are processed. Assume that no friend wrote any message to Polycarpus.

The first line contains integer n (1 ≤ n ≤ 200 000) — the number of Polycarpus' messages. Next n lines enlist the message recipients in the order in which the messages were sent. The name of each participant is a non-empty sequence of lowercase English letters of length at most 10.

Print all the recipients to who Polycarp talked to in the order of chats with them, from top to bottom.

8
alina
maria
ekaterina
darya
darya
ekaterina
maria
alina

NoteIn the first test case Polycarpus first writes to friend by name "alex", and the list looks as follows:   alex Then Polycarpus writes to friend by name "ivan" and the list looks as follows:  ivan  alex Polycarpus writes the third message to friend by name "roman" and the list looks as follows:  roman  ivan  alex Polycarpus writes the fourth message to friend by name "ivan", to who he has already sent a message, so the list of chats changes as follows:  ivan  roman  alex

package main

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

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

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

func ReadString() string {
	scanner.Scan()
	ans := scanner.Text()
	return ans
}

func PrintInts(ints ...int) {
	for _, value := range ints {
		writer.WriteString(strconv.Itoa(value))
		//writer.WriteByte(' ')
	}
}

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

	var cnt int = ReadInt32()
	var order map[string]bool
	var dialogs []string

	order = make(map[string]bool)
	dialogs = make([]string, 200000)

	for c := cnt - 1; c >= 0; c = c - 1 {
		name := ReadString()
		dialogs[c] = name
	}

	for _, d := range dialogs {
		if d == "" {
			continue
		}
		if !order[d] {
			order[d] = true
			writer.WriteString(d)
			writer.WriteByte('\n')
		}
	}
}

package main

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

func main() {
	defer out.Flush()
	n := in.NextInt()
	names := make([]string, n)
	for i := range names {
		names[i] = in.NextLine()
	}
	seen := map[string]bool{}
	for i := n - 1; i >= 0; i-- {
		if !seen[names[i]] {
			seen[names[i]] = true
			fmt.Fprintln(out, names[i])
		}
	}
}

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

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

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

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

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

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

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

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


There are $$$n$$$ logs, the $$$i$$$-th log has a length of $$$a_i$$$ meters. Since chopping logs is tiring work, errorgorn and maomao90 have decided to play a game.errorgorn and maomao90 will take turns chopping the logs with errorgorn chopping first. On his turn, the player will pick a log and chop it into $$$2$$$ pieces. If the length of the chosen log is $$$x$$$, and the lengths of the resulting pieces are $$$y$$$ and $$$z$$$, then $$$y$$$ and $$$z$$$ have to be positive integers, and $$$x=y+z$$$ must hold. For example, you can chop a log of length $$$3$$$ into logs of lengths $$$2$$$ and $$$1$$$, but not into logs of lengths $$$3$$$ and $$$0$$$, $$$2$$$ and $$$2$$$, or $$$1.5$$$ and $$$1.5$$$.The player who is unable to make a chop will be the loser. Assuming that both errorgorn and maomao90 play optimally, who will be the winner?

Each test contains multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 100$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 50$$$)  — the number of logs. The second line of each test case contains $$$n$$$ integers $$$a_1,a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 50$$$)  — the lengths of the logs. Note that there is no bound on the sum of $$$n$$$ over all test cases.

For each test case, print "errorgorn" if errorgorn wins or "maomao90" if maomao90 wins. (Output without quotes).

NoteIn the first test case, errorgorn will be the winner. An optimal move is to chop the log of length $$$4$$$ into $$$2$$$ logs of length $$$2$$$. After this there will only be $$$4$$$ logs of length $$$2$$$ and $$$1$$$ log of length $$$1$$$.After this, the only move any player can do is to chop any log of length $$$2$$$ into $$$2$$$ logs of length $$$1$$$. After $$$4$$$ moves, it will be maomao90's turn and he will not be able to make a move. Therefore errorgorn will be the winner.In the second test case, errorgorn will not be able to make a move on his first turn and will immediately lose, making maomao90 the winner.

package main

import (
	"fmt"
)

func main() {

	var testcase int
	fmt.Scan(&testcase)

	for i := 0; i < testcase; i++ {
		var number int
		fmt.Scan(&number)

		a := make([]int, number)
		result := 0
		for j := 0; j < number; j++ {
			fmt.Scan(&a[j])
			result += a[j]
		}

		result -= number
		if result%2 == 0 {
			fmt.Println("maomao90")
		} else {
			fmt.Println("errorgorn")
		}
	}
}

package main

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

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

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

	for ; t > 0; t-- {
		var n int
		fmt.Fscanf(in, "%d\n", &n)
		count := 0

		for i := 0; i < n; i++ {
			var num int
			fmt.Fscanf(in, "%d", &num)
			count += num - 1
		}
		fmt.Fscanf(in, "\n")

		if count % 2 == 0 {
			fmt.Fprintln(out, "maomao90")
		} else {
			fmt.Fprintln(out, "errorgorn")
		}
	}
}

package main

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

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

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

	for ; t > 0; t-- {
		var n int
		fmt.Fscan(in, &n)
		count := 0

		for i := 0; i < n; i++ {
			num := 0
			fmt.Fscan(in, &num)
			count += num - 1
		}

		if count % 2 == 0 {
			fmt.Println("maomao90")
		} else {
			fmt.Println("errorgorn")
		}
	}
}

package main

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

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

	text, _ := reader.ReadString('\n')
	text = strings.TrimSpace(text)
	t, _ := strconv.Atoi(text)

	for i := 0; i < t; i++ {
		text, _ := reader.ReadString('\n')
		text = strings.TrimSpace(text)
		n, _ := strconv.Atoi(text)

		text, _ = reader.ReadString('\n')
		text = strings.TrimSpace(text)

		numbers := strings.Fields(text)
		sum := 0
		for j := 0; j < n; j++ {
			num, _ := strconv.Atoi(numbers[j])
			sum += num - 1
		}

		if sum % 2 == 0 {
			fmt.Println("maomao90")
		} else {
			fmt.Println("errorgorn")
		}
	}
}

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 i := 0; i < n; i++ {
			fmt.Fscan(read, &a[i])
		}

		solve()
	}
}

type pair struct {
	v int
	idx []int
}

//a b c d

//20 12 -- 4
//4  2  -- 4

func solve()  {
	var s int64

	for i := 0; i < n; i++ {
		if a[i] == 1 {
			continue
		}
		s +=int64(a[i] - 1)
	}

	if s == 0 {
		fmt.Println("maomao90")
		return
	}

	if s % 2 == 1 {
		fmt.Println("errorgorn")
	} else {
		fmt.Println("maomao90")
	}
}

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1672A
Date: 8/23/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1672/A
Problem: CF1672A
**/
func (in *CF1672A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()

		sum := 0
		for i := 0; i < n; i++ {
			sum += in.NextInt() - 1
		}

		turn := "errorgorn"

		if sum%2 == 0 {
			turn = "maomao90"
		}
		fmt.Println(turn)
	}
}

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

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

package main

import (
	"fmt"
)

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

	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		sum := 0
		for j := 0; j < n; j++ {
			var x int
			fmt.Scan(&x)
			sum += x - 1
		}

		if sum%2 == 0 {
			fmt.Println("maomao90")
		} else {
			fmt.Println("errorgorn")
		}
	}
}

package main

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

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

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

	var totalChop int = 0
	var log int

	for i := 0;i<n;i++{
		fmt.Fscan(in, &log)
		totalChop += log-1
	}

	if totalChop % 2 == 0 {
		fmt.Fprintln(out, "maomao90")
	} else {
		fmt.Fprintln(out, "errorgorn")
	}
}

func main() {
	defer out.Flush()

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

	for ; t > 0; t-- {
		solve()
	}
}

package main

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

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func main() {
	defer w.Flush()

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

	for ; t > 0; t-- {
		solve()
	}
}

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

	sum := 0

	for ; n > 0; n-- {
		var a int
		fmt.Fscan(r, &a)

		sum += a - 1
	}

	if sum%2 == 0 {
		fmt.Fprintln(w, "maomao90")
	} else {
		fmt.Fprintln(w, "errorgorn")
	}
}

package main

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

func solve(input []int) string {
	sum := 0
	for _, val := range input {
		sum += (val - 1)
	}
	if sum%2 == 0 {
		return "maomao90"
	}
	return "errorgorn"
}

func main() {
	input := bufio.NewReader(os.Stdin)
	t := readInt(input)
	for i := 0; i < t; i++ {
		readInt(input)
		arr := readArrInt(input)
		solution := solve(arr)
		fmt.Println(solution)
	}
}

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.TrimSpace(nStr)
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineList(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.TrimSpace(line)
	return strings.Split(line, " ")
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineList(in)
	arr := make([]int, len(numbs))
	for index, nStr := range numbs {
		val, _ := strconv.Atoi(nStr)
		arr[index] = val
	}
	return arr
}

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

func solve(reader *bufio.Reader) {
    var n int
    fmt.Fscan(reader, &n)
    sum := 0
    var num int
    for i := 0; i < n; i++ {
        fmt.Fscan(reader, &num)
        sum += num
    }
    sum -= n
    if(sum % 2 == 1) {
        fmt.Println("errorgorn")
    } else {
        fmt.Println("maomao90")
    }
}

func main() {
    reader := bufio.NewReader(os.Stdin)
    var tc int
    fmt.Fscan(reader, &tc)
    for i := 0; i < tc; i++ {
        solve(reader)
    }
}

package main

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

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

func solve(n int, a []int) string {
	c := 0
	for _, x := range a {
		c += (x - 1)
	}
	if c%2 == 1 {
		return "errorgorn"
	}
	return "maomao90"
}

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

package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)

	for ii := 0; ii < t; ii++ {
		var n int
		fmt.Fscan(in, &n)
		count := 0
		for i := 0; i < n; i++ {
			num := 0
			fmt.Fscan(in, &num)
			count += num - 1
		}
		if count&1 == 1 {
			fmt.Fprintln(out, "errorgorn")
		} else {
			fmt.Fprintln(out, "maomao90")
		}
	}
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		var tot int
		for i := 0; i < n; i++ {
			var v int
			fmt.Fscan(in, &v)

			tot += v - 1
		}

		if tot%2 != 0 {
			fmt.Fprintln(out, "errorgorn")
		} else {
			fmt.Fprintln(out, "maomao90")
		}
	}
}

package main

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

/*
1
6
5 4 1 6 4 3
---
*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n int64
	scanf("%d\n", &n)

	a := make([]int, n)

	sum := 0

	for i := range a {
		scanf("%d", &a[i])

		if a[i] > 1 {
			sum += a[i] - 1
		}
	}
	scanf("\n")

	if sum%2 == 1 {
		fmt.Fprintln(writer, "errorgorn")
	} else {
		fmt.Fprintln(writer, "maomao90")
	}
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int64) int64 {
	quot := num / div
	if num%div > 0 {
		quot++
	} else if num%div < 0 {
		quot--
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	return nums[minIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func minIdx(nums ...int) int {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return minNumIdx
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	return nums[maxIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func maxIdx(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return maxNumIdx
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

//goland:noinspection GoUnusedFunction
func factorize(num int) []int {
	factors := []int{1}

	sqrtA := int(math.Sqrt(float64(num)))

	for ftr := 2; ftr <= sqrtA; ftr++ {
		for num%ftr == 0 {
			num /= ftr
			factors = append(factors, ftr)
		}
	}

	if num > sqrtA {
		factors = append(factors, num)
	}

	return factors
}

package main

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

type Int int64

const (
	INF = 3e5 + 10
	L0  = Int(0)
	L1  = Int(1)
)

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

	var t int
	Fscan(in, &t)

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

		var n int
		Fscan(in, &n)

		cnt := 0
		for i := 0; i < n; i++ {
			var x int
			Fscan(in, &x)
			cnt += x - 1
		}

		if cnt&1 == 1 {
			Fprintln(out, "errorgorn")
		} else {
			Fprintln(out, "maomao90")

		}

	}

}

func Abs(x Int) Int {
	if x > 0 {
		return x
	}
	return -x
}

func Min(nums ...Int) Int {
	return nums[MinIdx(nums...)]
}

func MinIdx(nums ...Int) Int {
	maxNumIdx := L0
	for i, num := range nums {
		if num < nums[maxNumIdx] {
			maxNumIdx = Int(i)
		}
	}
	return maxNumIdx
}

func Max(nums ...Int) Int {
	return nums[MaxIdx(nums...)]
}

func MaxIdx(nums ...Int) Int {
	maxNumIdx := L0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = Int(i)
		}
	}
	return maxNumIdx
}

package main

import (
	"fmt"
)

func main() {

	var testcase int
	fmt.Scan(&testcase)

	for i := 0; i < testcase; i++ {
		var number int
		fmt.Scan(&number)

		a := make([]int, number)
		result := 0
		for j := 0; j < number; j++ {
			fmt.Scan(&a[j])
			result += a[j]
		}

		result -= number

		if result%2 == 0 {
			fmt.Println("errorgorn")
		} else {
			fmt.Println("maomao90")
		}
	}
}

package main

import (
	"fmt"
)

func main() {

	var testcase int
	fmt.Scan(&testcase)

	for i := 0; i < testcase; i++ {
		var number int
		fmt.Scan(&number)

		a := make([]int, number)
		result := 0
		for j := 0; j < number; j++ {
			fmt.Scan(&a[j])
			result += j
		}

		result -= number

		if result%2 == 0 {
			fmt.Println("errorgorn")
		} else {
			fmt.Println("maomao90")
		}
	}
}

package main

import (
	"fmt"
)

func main() {

	var testcase int
	fmt.Scan(&testcase)

	for i := 0; i < testcase; i++ {
		var number int
		fmt.Scan(&number)

		a := make([]int, number)
		result := 0
		for j := 0; j < number; j++ {
			fmt.Scan(&a[j])
			result += j
		}

		result -= number

		if result%2 == 0 {
			fmt.Println("errorgorn")
		} else {
			fmt.Println("maoma90")
		}
	}
}

package main

import (
	"fmt"
)

func main() {

	var testcase int
	fmt.Scan(&testcase)

	for i := 0; i < testcase; i++ {
		var number int
		fmt.Scan(&number)

		// fmt.Println(reflect.TypeOf(inputReader))
		a := make([]int, number)
		result := 0
		for j := 0; j < number; j++ {
			fmt.Scan(&a[j])
			result += j
		}

		result -= number

		if result%2 == 0 {
			println("errorgorn")
		} else {
			println("maoma90")
		}
	}
}

package main

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

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

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

	for ; t > 0; t-- {
		var n int
		fmt.Fscanf(in, "%d\n", &n)
		count := 0

		for i := 0; i < n; i++ {
			var num int
			fmt.Fscanf(in, "%d", &num)
			count += num - 1
		}

		if count % 2 == 0 {
			fmt.Println("maomao90")
		} else {
			fmt.Println("errorgorn")
		}
	}
}

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 i := 0; i < n; i++ {
			fmt.Fscan(read, &a[i])
		}

		solve()
	}
}

type pair struct {
	v int
	idx []int
}

//a b c d

//20 12 -- 4
//4  2  -- 4

func solve()  {
	var s int64

	for i := 0; i < n; i++ {
		if a[i] == 1 {
			continue
		}
		s +=int64(a[i])
	}

	if s== 0 {
		fmt.Println("maomao90")
		return
	}

	if s % 2 == 1 {
		fmt.Println("maomao90")
	} else {
		fmt.Println("errorgorn")
	}
}

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 i := 0; i < n; i++ {
			fmt.Fscan(read, &a[i])
		}

		solve()
	}
}

type pair struct {
	v int
	idx []int
}

//a b c d

//20 12 -- 4
//4  2  -- 4

func solve()  {
	var s int64

	for i := 0; i < n; i++ {
		if a[i] == 1 {
			continue
		}
		s +=int64(a[i])
	}

	if s % 2 == 1 {
		fmt.Println("maomao90")
	} else {
		fmt.Println("errorgorn")
	}
}

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1672A
Date: 8/23/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1672/A
Problem: CF1672A
**/
func (in *CF1672A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			arr[i] = in.NextInt()
		}

		turn := "errorgorn"
		i := 0
		for {
			ws := true
			for ; i < n; i++ {
				if arr[i] > 1 {
					aux := arr[i] / 2
					arr = append(arr, arr[i]-aux)
					arr[i] = aux
					if turn == "errorgorn" {
						turn = "maomao90"
					} else {
						turn = "errorgorn"
					}
					ws = false
				}
			}
			if ws {
				break
			}
		}

		if turn == "errorgorn" {
			turn = "maomao90"
		} else {
			turn = "errorgorn"
		}

		fmt.Println(turn)
	}
}

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

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


Nikolay lives in a two-storied house. There are $$$n$$$ rooms on each floor, arranged in a row and numbered from one from left to right. So each room can be represented by the number of the floor and the number of the room on this floor (room number is an integer between $$$1$$$ and $$$n$$$). If Nikolay is currently in some room, he can move to any of the neighbouring rooms (if they exist). Rooms with numbers $$$i$$$ and $$$i+1$$$ on each floor are neighbouring, for all $$$1 \leq i \leq n - 1$$$. There may also be staircases that connect two rooms from different floors having the same numbers. If there is a staircase connecting the room $$$x$$$ on the first floor and the room $$$x$$$ on the second floor, then Nikolay can use it to move from one room to another.     The picture illustrates a house with $$$n = 4$$$. There is a staircase between the room $$$2$$$ on the first floor and the room $$$2$$$ on the second floor, and another staircase between the room $$$4$$$ on the first floor and the room $$$4$$$ on the second floor. The arrows denote possible directions in which Nikolay can move. The picture corresponds to the string "0101" in the input.  Nikolay wants to move through some rooms in his house. To do this, he firstly chooses any room where he starts. Then Nikolay moves between rooms according to the aforementioned rules. Nikolay never visits the same room twice (he won't enter a room where he has already been). Calculate the maximum number of rooms Nikolay can visit during his tour, if:  he can start in any room on any floor of his choice,  and he won't visit the same room twice.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then test cases follow. Each test case consists of two lines. The first line contains one integer $$$n$$$ $$$(1 \le n \le 1\,000)$$$ — the number of rooms on each floor. The second line contains one string consisting of $$$n$$$ characters, each character is either a '0' or a '1'. If the $$$i$$$-th character is a '1', then there is a staircase between the room $$$i$$$ on the first floor and the room $$$i$$$ on the second floor. If the $$$i$$$-th character is a '0', then there is no staircase between the room $$$i$$$ on the first floor and the room $$$i$$$ on the second floor. In hacks it is allowed to use only one test case in the input, so $$$t = 1$$$ should be satisfied.

For each test case print one integer — the maximum number of rooms Nikolay can visit during his tour, if he can start in any room on any floor, and he won't visit the same room twice.

NoteIn the first test case Nikolay may start in the first room of the first floor. Then he moves to the second room on the first floor, and then — to the third room on the first floor. Then he uses a staircase to get to the third room on the second floor. Then he goes to the fourth room on the second floor, and then — to the fifth room on the second floor. So, Nikolay visits $$$6$$$ rooms.There are no staircases in the second test case, so Nikolay can only visit all rooms on the same floor (if he starts in the leftmost or in the rightmost room).In the third test case it is possible to visit all rooms: first floor, first room $$$\rightarrow$$$ second floor, first room $$$\rightarrow$$$ second floor, second room $$$\rightarrow$$$ first floor, second room $$$\rightarrow$$$ first floor, third room $$$\rightarrow$$$ second floor, third room $$$\rightarrow$$$ second floor, fourth room $$$\rightarrow$$$ first floor, fourth room $$$\rightarrow$$$ first floor, fifth room $$$\rightarrow$$$ second floor, fifth room.In the fourth test case it is also possible to visit all rooms: second floor, third room $$$\rightarrow$$$ second floor, second room $$$\rightarrow$$$ second floor, first room $$$\rightarrow$$$ first floor, first room $$$\rightarrow$$$ first floor, second room $$$\rightarrow$$$ first floor, third room.

package main

import (
	"fmt"
	"os"
	"strconv"
)
func max (a int, b int) int {
	if(a > b){
		return a
	}
	return b
}
func min (a int, b int) int {
	if(a > b){
		return b
	}
	return a
}
func main() {
	var n int
	fmt.Fscan(os.Stdin, &n)
	for i := 0; i < n; i++ {
		a := 0
		fmt.Fscan(os.Stdin, &a)
		var s string
		fmt.Fscan(os.Stdin, &s)
		mx := -1
		mn := 2000
		for j := 0; j < len(s); j ++{
			if(s[j]=='1') {
				mx = max(mx, j)
				mn = min(mn, j)
			}
		}
		ans := (max(((mx+1)*2), (a-mn)*2))
		if(mx == -1) {
			ans = a
		}
		ss := strconv.Itoa(ans)
		fmt.Printf(ss + "\n")
	}
}

package main

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

/* solution */

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

func solveOne() {
	n := readInt()
	s := read()
	l, r := -1, -1
	for i := 0; i < n; i++ {
		if s[i] == '1' {
			r = i
			if l == -1 {
				l = i
			}
		}
	}

	if r == -1 {
		printInt(n)
		return
	}

	var d int
	if l < n-r-1 {
		d = l
	} else {
		d = n - r - 1
	}

	printInt(n*2 - d*2)

}

/* stubs */

func main() {

	var f *os.File
	if runtime.GOROOT() == "C:\\Soft\\Go" {
		f, _ = os.Open("input.txt")
		defer f.Close()
	} else {
		f = os.Stdin
	}

	writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	reader = bufio.NewScanner(f)

	const maxCapacity = 1024 * 1024
	buf := make([]byte, maxCapacity)
	reader.Buffer(buf, maxCapacity)

	reader.Split(bufio.ScanLines)

	solve()

}

var reader *bufio.Scanner
var writer *bufio.Writer

func read() string {
	reader.Scan()
	return reader.Text()
}

func readInt() int {
	reader.Scan()
	ret, _ := strconv.Atoi(reader.Text())
	return ret
}

func print(s string) {
	writer.WriteString(s)
	writer.WriteString("\n")
}

func printInt(i int) {
	print(strconv.Itoa(i))
}

func printInt64(i int64) {
	print(strconv.FormatInt(i, 10))
}

func readInt64() int64 {
	reader.Scan()
	ret, _ := strconv.ParseInt(reader.Text(), 10, 64)
	return ret
}

//HOWDY! IT'S ME! A HARD BLACKISH DICK MOVE!
package main

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

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

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

//str := PrintlnInts(X...)

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

func main() {
	for t := ReadInt(); t > 0; t-- {
		n := ReadInt()
		s := ReadString()
		left := -1
		for i := 0; i < n; i++ {
			if s[i] == '1' {
				left = i
				break
			}
		}
		if left == -1 {
			fmt.Println(n)
			continue
		}
		right := -1
		for i := n - 1; i >= 0; i-- {
			if s[i] == '1' {
				right = i
				break
			}
		}
		minEdge := min(left, n-right-1)
		fmt.Println(2*n - 2*minEdge)
	}
}

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

func min(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	min := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] < min {
			min = args[i]
		}
	}
	return min
}

func max(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	max := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] > max {
			max = args[i]
		}
	}
	return max
}

func _gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return _gcd(b, a%b)
}

func gcd(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	gcd := args[0]
	for i := 1; i < len(args); i++ {
		gcd = _gcd(gcd, args[i])
	}
	return gcd
}

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

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

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

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

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

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

func readInt_64() int64 {
	return readIntNbits(64)
}

func ReadInt2_64() (int64, int64) {
	return readInt_64(), readInt_64()
}

func ReadInt3_64() (int64, int64, int64) {
	return readInt_64(), readInt_64(), readInt_64()
}

func readInt() int {
	return int(readIntNbits(32))
}

func readIntNbits(n int) int64 {
	i, err := strconv.ParseInt(ReadString(), 0, n)
	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
}

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

// PrintIntsLine returns integers string delimited by a space.
func PrintlnInts(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)
}

package main

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

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

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

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

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

	return res
}

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

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

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

// DigitSum returns digit sum of a decimal number.
// DigitSum only accept a positive integer.
func DigitSum(n int) int {
	if n < 0 {
		return -1
	}

	res := 0

	for n > 0 {
		res += n % 10
		n /= 10
	}

	return res
}

// DigitNumOfDecimal returns digits number of n.
// n is non negative number.
func DigitNumOfDecimal(n int) int {
	res := 0

	for n > 0 {
		n /= 10
		res++
	}

	return res
}

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

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

	return s
}

// Kiriage returns Ceil(a/b)
// a >= 0, b > 0
func Kiriage(a, b int) int {
	return (a + (b - 1)) / b
}

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

	if e == 0 {
		return 1
	}

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

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

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

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

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

	return a
}

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

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

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

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

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

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

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

	return string(res)
}

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

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

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

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

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

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

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var t int

func main() {
	t = ReadInt()

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

		allZero := true
		for i := 0; i < n; i++ {
			if S[i] == '1' {
				allZero = false
				break
			}
		}
		if allZero {
			fmt.Println(n)
			continue
		}

		if S[0] == '1' || S[n-1] == '1' {
			fmt.Println(2 * n)
			continue
		}

		minIdx, maxIdx := 0, n-1
		for j := 0; j < n; j++ {
			if S[j] == '1' {
				minIdx = j
				break
			}
		}
		for j := n - 1; j >= 0; j-- {
			if S[j] == '1' {
				maxIdx = j
				break
			}
		}

		res := Max(2*(maxIdx+1), 2*(n-(minIdx)))
		fmt.Println(res)
	}
}

// MODはとったか？
// 遷移だけじゃなくて最後の最後でちゃんと取れよ？

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

package main

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

func solve(reader io.Reader, writer io.Writer) {
	max := func(a, b int) int {
		if a >= b {
			return a
		}
		return b
	}

	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var q int
	for Fscan(in, &q); q > 0; q-- {
		var n int
		var s string
		Fscan(in, &n, &s)
		l1, r1 := -1, -1
		for i, c := range s {
			if c == '1' {
				l1 = i
				break
			}
		}
		for i := n - 1; i >= 0; i-- {
			if s[i] == '1' {
				r1 = i
				break
			}
		}
		if l1 == -1 && r1 == -1 {
			Fprintln(out, n)
		} else {
			Fprintln(out, 2*max(r1+1, n-l1))
		}
	}
}

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

package main

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

type point struct {
	x, y int
}

var ans int64

const (
	mod = int(1e9 + 7)
)

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

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscanf(in, "%d\n", &t)
	for ii := 0; ii < t; ii++ {
		n := 0
		fmt.Fscanf(in, "%d\n", &n)
		s := ""
		fmt.Fscanf(in, "%s\n", &s)
		ans := n
		for i := 0; i < n; i++ {
			if s[i] == '1' {
				if (i+1)*2 > ans {
					ans = (i + 1) * 2
				}
				if (n-i)*2 > ans {
					ans = (n - i) * 2
				}
			}
		}
		fmt.Fprintf(out, "%d\n", ans)
	}
	return
}

func help(i int, n int, total int, t []int, g []int, cur int, c1, c2, c3 int, remaining int) {
	//fmt.Println(i, cur)
	if i == n {
		if cur == total {
			cal(c1, c2, c3)
		}
		return
	}
	if cur > total {
		return
	}
	if cur+remaining < total {
		return
	}
	switch g[i] {
	case 1:
		help(i+1, n, total, t, g, cur+t[i], c1+1, c2, c3, remaining-t[i])
	case 2:
		help(i+1, n, total, t, g, cur+t[i], c1, c2+1, c3, remaining-t[i])
	case 3:
		help(i+1, n, total, t, g, cur+t[i], c1, c2, c3+1, remaining-t[i])
	}
	help(i+1, n, total, t, g, cur, c1, c2, c3, remaining-t[i])
}

func cal(c1, c2, c3 int) {
	a := []int{c1, c2, c3}
	sort.Ints(a)
	tmp := int64(try(c1, c2, c3, 0))
	tmp %= int64(mod)
	for i := 1; i <= c1; i++ {
		tmp *= int64(i)
		tmp %= int64(mod)
	}
	for i := 1; i <= c2; i++ {
		tmp *= int64(i)
		tmp %= int64(mod)
	}
	for i := 1; i <= c3; i++ {
		tmp *= int64(i)
		tmp %= int64(mod)
	}
	ans += tmp
	ans %= int64(mod)
}

func try(a, b, c int, last int) int64 {
	if a == 0 && b == 0 && c == 0 {
		return 1
	}
	if a < 0 || b < 0 || c < 0 {
		return 0
	}
	if last == 0 {
		return try(a-1, b, c, 1) + try(a, b-1, c, 2) + try(a, b, c-1, 3)
	}
	if last == 1 {
		return try(a, b-1, c, 2) + try(a, b, c-1, 3)
	}
	if last == 2 {
		return try(a-1, b, c, 1) + try(a, b, c-1, 3)
	}
	return try(a-1, b, c, 1) + try(a, b-1, c, 2)
}

package main

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

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

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

	var t, n int
	fmt.Fscanln(in, &t)

	for i := 0; i < t; i++ {
		fmt.Fscanln(in, &n)
		//fmt.Println("N:", n)

		k := -1
		for j := 0; j < n; j++ {
			s, _ := in.ReadByte()
			//fmt.Println("S:", s)

			if s == '1' {
				current := min(j, n - 1 - j)
				if k == -1 {
					k = current
				}
				k = min(k, current)
			}
		}
		fmt.Fscanln(in)

		if k == -1 {
			fmt.Println(n)
		} else {
			fmt.Println(2 * (n - k))
		}
	}
}

package main

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

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

	return y
}

func main() {

	reader := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscanf(reader, "%d\n", &t)

	var n, ans int
	var s string

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

		ans = n

		for i := 0; i < n; i++ {
			if s[i] == '1' {
				ans = min(ans, min(i-0, n-1-i))
			}
		}

		if ans == n {
			fmt.Printf("%d\n", n)
		} else {
			fmt.Printf("%d\n", 2*(n-ans))
		}
	}
}

package main

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

func main() {
	var n int
	fmt.Fscan(os.Stdin, &n)
	for i := 0; i < n; i++ {
		var a int
		cnt := 0
		fmt.Fscan(os.Stdin, &a)
		var s string
		fmt.Fscan(os.Stdin, &s)
		for j := 0; j < len(s); j++ {
			if s[j] == '1' {
				cnt++
			}
		}
		if(s[len(s)-1] == '1') || (s[0] == '1'){
			cnt = a
		}
		var ans = strconv.Itoa(cnt+a)
		fmt.Printf(ans)
	}
}

package main

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

func main() {
	var n int
	fmt.Fscan(os.Stdin, &n)
	for i := 0; i < n; i++ {
		var a int
		cnt := 0
		fmt.Fscan(os.Stdin, &a)
		var s string
		fmt.Fscan(os.Stdin, &s)
		for j := 0; j < len(s); j++ {
			if s[j] == '1' {
				cnt++
			}
		}
		if(s[len(s)-1] == '1') || (s[0] == '1'){
			cnt = a
		}
		var ans = strconv.Itoa(cnt+a)
		fmt.Printf(ans)
		fmt.Printf("\n")
	}
}

package main

import (
	"fmt"
	"os"
	"strconv"
)
func max (a int, b int) int {
	if(a > b){
		return a
	}
	return b
}
func min (a int, b int) int {
	if(a > b){
		return b
	}
	return a
}
func main() {
	var n int
	fmt.Fscan(os.Stdin, &n)
	for i := 0; i < n; i++ {
		a := 0
		fmt.Fscan(os.Stdin, &a)
		var s string
		fmt.Fscan(os.Stdin, &s)
		mx := -1
		mn := 2000
		for j := 0; j < len(s); j ++{
			if(s[j]=='1') {
				mx = max(mx, j)
				mn = min(mn, j)
			}
		}
		ans := (max(((mx+1)*2), (a-mn)*2))
		if(mn == -1) {
			ans = a
		}
		ss := strconv.Itoa(ans)
		fmt.Printf(ss + "\n")
	}
}

package main

import (
	"fmt"
	"os"
	"strconv"
)
func max (a int, b int) int {
	if(a > b){
		return a
	}
	return b
}
func min (a int, b int) int {
	if(a > b){
		return b
	}
	return a
}
func main() {
	var n int
	fmt.Fscan(os.Stdin, &n)
	for i := 0; i < n; i++ {
		a := 0
		fmt.Fscan(os.Stdin, &a)
		var s string
		fmt.Fscan(os.Stdin, &s)
		mx := 0
		mn := 2000
		for j := 0; j < len(s); j ++{
			if(s[j]=='1') {
				mx = max(mx, j)
				mn = min(mn, j)
			}
		}
		ans := (max(((mx+1)*2), (a-mn)*2))
		ans = max(ans, a)
		ss := strconv.Itoa(ans)
		fmt.Printf(ss + "\n")
	}
}

package main

import (
	"fmt"
	"os"
	"strconv"
)
func max (a int, b int) int {
	if(a > b){
		return a
	}
	return b
}
func min (a int, b int) int {
	if(a > b){
		return b
	}
	return a
}
func main() {
	var n int
	fmt.Fscan(os.Stdin, &n)
	for i := 0; i < n; i++ {
		a := 0
		fmt.Fscan(os.Stdin, &a)
		var s string
		fmt.Fscan(os.Stdin, &s)
		mx := 0
		mn := 2000
		for j := 0; j < len(s); j ++{
			if(s[j]=='1') {
				mx = max(mx, j)
				mn = min(mn, j)
			}
		}
		ans := strconv.Itoa(max(((mx+1)*2), (a-mn)*2))
		fmt.Printf(ans + "\n")
	}
}


Alice and Bob play a game. Alice has $$$n$$$ cards, the $$$i$$$-th of them has the integer $$$a_i$$$ written on it. Bob has $$$m$$$ cards, the $$$j$$$-th of them has the integer $$$b_j$$$ written on it.On the first turn of the game, the first player chooses one of his/her cards and puts it on the table (plays it). On the second turn, the second player chooses one of his/her cards such that the integer on it is greater than the integer on the card played on the first turn, and plays it. On the third turn, the first player chooses one of his/her cards such that the integer on it is greater than the integer on the card played on the second turn, and plays it, and so on — the players take turns, and each player has to choose one of his/her cards with greater integer than the card played by the other player on the last turn.If some player cannot make a turn, he/she loses.For example, if Alice has $$$4$$$ cards with numbers $$$[10, 5, 3, 8]$$$, and Bob has $$$3$$$ cards with numbers $$$[6, 11, 6]$$$, the game may go as follows:  Alice can choose any of her cards. She chooses the card with integer $$$5$$$ and plays it.  Bob can choose any of his cards with number greater than $$$5$$$. He chooses a card with integer $$$6$$$ and plays it.  Alice can choose any of her cards with number greater than $$$6$$$. She chooses the card with integer $$$10$$$ and plays it.  Bob can choose any of his cards with number greater than $$$10$$$. He chooses a card with integer $$$11$$$ and plays it.  Alice can choose any of her cards with number greater than $$$11$$$, but she has no such cards, so she loses. Both Alice and Bob play optimally (if a player is able to win the game no matter how the other player plays, the former player will definitely win the game).You have to answer two questions:  who wins if Alice is the first player?  who wins if Bob is the first player?

The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case consists of four lines. The first line of a test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the number of cards Alice has. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 50$$$) — the numbers written on the cards that Alice has. The third line contains one integer $$$m$$$ ($$$1 \le m \le 50$$$) — the number of Bob's cards. The fourth line contains $$$m$$$ integers $$$b_1, b_2, \dots, b_m$$$ ($$$1 \le b_i \le 50$$$) — the numbers on Bob's cards.

For each test case, print two lines. The first line should be Alice if Alice wins when she is the first player; otherwise, the first line should be Bob. The second line should contain the name of the winner if Bob is the first player, in the same format.

NoteLet's consider the first test case of the example.Alice has one card with integer $$$6$$$, Bob has two cards with numbers $$$[6, 8]$$$.If Alice is the first player, she has to play the card with number $$$6$$$. Bob then has to play the card with number $$$8$$$. Alice has no cards left, so she loses.If Bob is the first player, then no matter which of his cards he chooses on the first turn, Alice won't be able to play her card on the second turn, so she will lose.

package main

import (
	"fmt"
	"sort"
)

func main() {
	var t, n, m int

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

		fmt.Scan(&m)
		bob := readSlice(m)

		w1, w2 := solveA(alice, bob)
		fmt.Println(w1)
		fmt.Println(w2)
	}
}

func readSlice(n int) []int {
	nums := make([]int, n)
	for j := 0; j < n; j++ {
		fmt.Scan(&nums[j])
	}
	return nums
}

func solveA(alice, bob []int) (string, string) {
	sort.Ints(alice)
	sort.Ints(bob)

	la := len(alice)
	lb := len(bob)

	if alice[la-1] < bob[lb-1] {
		return "Bob", "Bob"
	}
	if alice[la-1] > bob[lb-1] {
		return "Alice", "Alice"
	}
	return "Alice", "Bob"
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		var alice,ta,bob,tb int
		for j:=0;j<n;j++{
			var x int
			fmt.Fscan(in,&x)
			if x > alice || j ==0 {
				alice=x
				ta=1
				continue
			}
			if alice == x {
				ta++
			}
		}
		fmt.Fscan(in,&n)
		for j:=0;j<n;j++{
			var x int
			fmt.Fscan(in,&x)
			if x > bob || j ==0 {
				bob=x
				tb=1
				continue
			}
			if bob == x {
				tb++
			}
		}
		if alice>bob {
			fmt.Fprintln(out,"Alice")
			fmt.Fprintln(out,"Alice")
		} else if bob > alice {
			fmt.Fprintln(out,"Bob")
			fmt.Fprintln(out,"Bob")
		} else {
			fmt.Fprintln(out,"Alice")
			fmt.Fprintln(out,"Bob")
		}
	}
}

package main

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

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

func CF1691A(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var T int64
	fmt.Fscan(r, &T)
	for ; T > 0; T-- {
		var a, aMax, b, bMax int64
		var val int64
		fmt.Fscan(r, &a)
		for i := int64(0); i < a; i++ {
			fmt.Fscan(r, &val)
			aMax = max(val, aMax)
		}
		fmt.Fscan(r, &b)
		for i := int64(0); i < b; i++ {
			fmt.Fscan(r, &val)
			bMax = max(val, bMax)
		}
		if aMax > bMax {
			fmt.Fprintln(w, "Alice")
			fmt.Fprintln(w, "Alice")
		} else if aMax == bMax {
			fmt.Fprintln(w, "Alice")
			fmt.Fprintln(w, "Bob")
		} else {
			fmt.Fprintln(w, "Bob")
			fmt.Fprintln(w, "Bob")
		}
	}

}

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1681A
Date: 25/05/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1681/A
Problem: CF1681A
**/
func (in *CF1681A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		nums := make([]int, 51)
		for i := 0; i < n; i++ {
			nums[in.NextInt()]++
		}
		m := in.NextInt()

		b := make([]int, 51)
		for i := 0; i < m; i++ {
			b[in.NextInt()]++
		}

		x := false
		y := false
		for i := 50; i >= 0; i-- {
			if b[i] > 0 && nums[i] > 0 {
				x = true
				y = false
				break
			}
			if b[i] > 0 && nums[i] == 0 {
				y = false
				x = false
				break
			}

			if b[i] == 0 && nums[i] > 0 {
				y = true
				x = true
				break
			}
		}

		if x {
			fmt.Println("Alice")
		} else {
			fmt.Println("Bob")
		}

		if y {
			fmt.Println("Alice")
		} else {
			fmt.Println("Bob")
		}
	}
}

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

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

package main

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

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

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

	var T int
	var n int
	var m int
	var x int

	chk := func(a, b []int) bool {
		return a[len(a)-1] >= b[len(b)-1]
		//fa := false
		////for i := 0; i < len(a) && i < len(b); i++ {
		////	if a[len(a)-1-i] > b[len(b)-1-i] {
		////		fa = true
		////		break
		////	} else if a[len(a)-1-i] < b[len(b)-1-i] {
		////		break
		////	}
		////}
		//return fa
	}

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a, b := []int{}, []int{}
		for i := 0; i < n; i++ {
			Fscan(in, &x)
			a = append(a, x)
		}
		Fscan(in, &m)
		for i := 0; i < m; i++ {
			Fscan(in, &x)
			b = append(b, x)
		}
		sort.Ints(a)
		sort.Ints(b)

		if chk(a, b) {
			Fprintln(out, "Alice")
		} else {
			Fprintln(out, "Bob")
		}
		if !chk(b, a) {
			Fprintln(out, "Alice")
		} else {
			Fprintln(out, "Bob")
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var T,N,M,A,B,maxA,maxB int
	fmt.Fscan(in, &T)
	//list := make([]int,N+1)
	for i := 0;i < T;i++{
		fmt.Fscan(in, &N)
		for j := 0;j < N;j++{
			fmt.Fscan(in, &A)
			if maxA < A {
				maxA = A
			}
		}
		fmt.Fscan(in, &M)
		for j := 0;j < M;j++{
			fmt.Fscan(in, &B)
			if maxB < B {
				maxB = B
			}
		}
		if maxA < maxB{
			fmt.Println("Bob")
			fmt.Println("Bob")
		}else if maxA > maxB {
			fmt.Println("Alice")
			fmt.Println("Alice")
		}else{
			fmt.Println("Alice")
			fmt.Println("Bob")
		}
		maxA = 0
		maxB = 0
	}
}

package main

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

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func slove() {
	var n, m int
	fmt.Fscan(r, &n)
	nums1 := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums1[i])
	}
	fmt.Fscan(r, &m)
	nums2 := make([]int, m)
	for i:=0;i<m;i++ {
		fmt.Fscan(r, &nums2[i])
	}
	sort.Ints(nums1)
	sort.Ints(nums2)
	if nums1[n-1] > nums2[m-1] {
		fmt.Fprintln(w, "Alice")
		fmt.Fprintln(w, "Alice")
	} else if nums1[n-1] < nums2[m-1] {
		fmt.Fprintln(w, "Bob")
		fmt.Fprintln(w, "Bob")
	} else {
		fmt.Fprintln(w, "Alice")
		fmt.Fprintln(w, "Bob")
	}
}

func main() {
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

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

type Int int64

const (
	INF = 3e5 + 10
	L0  = Int(0)
	L1  = Int(1)
)

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

	var T int
	Fscan(in, &T)

	for tt := 0; tt < T; tt++ {
		var n, m, x int
		Fscan(in, &n)

		ma := 0
		for i := 0; i < n; i++ {
			Fscan(in, &x)
			if x > ma {
				ma = x
			}
		}

		Fscan(in, &m)

		mb := 0
		for i := 0; i < m; i++ {
			Fscan(in, &x)
			if x > mb {
				mb = x
			}
		}

		if ma >= mb {
			Fprintln(out, "Alice")
		} else {
			Fprintln(out, "Bob")
		}
		if mb >= ma {
			Fprintln(out, "Bob")
		} else {
			Fprintln(out, "Alice")
		}

	}

}

func MakeGrid(h, w int) [][]Int {
	index := make([][]Int, h)
	data := make([]Int, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

func Abs(x Int) Int {
	if x > 0 {
		return x
	}
	return -x
}

func Min(nums ...Int) Int {
	return nums[MinIdx(nums...)]
}

func MinIdx(nums ...Int) Int {
	maxNumIdx := L0
	for i, num := range nums {
		if num < nums[maxNumIdx] {
			maxNumIdx = Int(i)
		}
	}
	return maxNumIdx
}

func Max(nums ...Int) Int {
	return nums[MaxIdx(nums...)]
}

func MaxIdx(nums ...Int) Int {
	maxNumIdx := L0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = Int(i)
		}
	}
	return maxNumIdx
}

var (
	mod  Int
	fmod func(Int) Int = doNothing
)

// SetMod sets the mod. It must be called first.
func SetMod(newMod Int) {
	mod = newMod
	fmod = dynamicMod
}

func dynamicMod(m Int) Int {
	m %= mod
	if m < 0 {
		return m + mod
	}
	return m
}

func doNothing(m Int) Int {
	return m
}

// Mod returns m % mod.
func (m Int) Mod() Int {
	return fmod(m)
}

// Inv returns modular multiplicative inverse
func (m Int) Inv() Int {
	return m.Pow(Int(0).Sub(2))
}

// Pow returns m^n
func (m Int) Pow(n Int) Int {
	p := Int(1)
	for n > 0 {
		if n&1 == 1 {
			p.MulAs(m)
		}
		m.MulAs(m)
		n >>= 1
	}
	return p
}

// Add returns m+x
func (m Int) Add(x Int) Int {
	return (m + x).Mod()
}

// Sub returns m-x
func (m Int) Sub(x Int) Int {
	return (m - x).Mod()
}

// Mul returns m*x
func (m Int) Mul(x Int) Int {
	return (m * x).Mod()
}

// Div returns m/x
func (m Int) Div(x Int) Int {
	return m.Mul(x.Inv())
}

// AddAs assigns *m + x to *m and returns m
func (m *Int) AddAs(x Int) *Int {
	*m = m.Add(x)
	return m
}

// SubAs assigns *m - x to *m and returns m
func (m *Int) SubAs(x Int) *Int {
	*m = m.Sub(x)
	return m
}

// MulAs assigns *m * x to *m and returns m
func (m *Int) MulAs(x Int) *Int {
	*m = m.Mul(x)
	return m
}

// DivAs assigns *m / x to *m and returns m
func (m *Int) DivAs(x Int) *Int {
	*m = m.Div(x)
	return m
}

func (m *Int) MaxAs(x ...Int) *Int {
	*m = Max(append(x, *m)...)
	return m
}

func (m *Int) MinAs(x ...Int) *Int {
	*m = Min(append(x, *m)...)
	return m
}

type Void struct{}

var void Void

type HashSet struct {
	ma map[Int]Void
}

func NewHashSet() *HashSet {
	return &HashSet{
		ma: make(map[Int]Void),
	}
}

func (s *HashSet) add(x Int) bool {
	_, exists := s.ma[x]
	if !exists {
		s.ma[x] = void
		return true
	} else {
		return false
	}
}

func (s *HashSet) del(x Int) {
	delete(s.ma, x)
}

func (s *HashSet) exist(x Int) bool {
	_, exists := s.ma[x]
	return exists
}

// An Item is something we manage in a priority queue.
type Item struct {
	value    Int // The value of the item; arbitrary.
	priority Int // The priority of the item in the queue.
	indices  Int
	// The index is needed by update and is maintained by the heap.Interface methods.
	index int // The index of the item in the heap.
}

// A PriorityQueue implements heap.Interface and holds Items.
type PriorityQueue []*Item

func NewItem(value, priority Int) *Item {
	return &Item{
		value:    value,
		priority: priority,
		index:    -1,
	}

}

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

func (pq PriorityQueue) Less(i, j int) bool {
	// We want Pop to give us the highest, not lowest, priority so we use greater than here.
	return pq[i].priority < pq[j].priority
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

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

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

// update modifies the priority and value of an Item in the queue.
func (pq *PriorityQueue) update(item *Item, value Int, priority Int) {
	item.value = value
	item.priority = priority
	heap.Fix(pq, item.index)
}

type SegTree struct {
	st []Segment
}

type Segment struct {
	l, r, val, add, minIndex Int
}

func newSegTree(n Int) SegTree {
	segTree := SegTree{make([]Segment, n<<2)}
	segTree.Build(1, 1, n)
	return segTree
}

func (segTree SegTree) Build(x, l, r Int) {
	segTree.st[x].l = l
	segTree.st[x].r = r
	if l == r {
		segTree.st[x].minIndex = l
		return
	}
	mid := (l + r) >> 1
	segTree.Build(x<<1, l, mid)
	segTree.Build(x<<1|1, mid+1, r)
}

func (segTree SegTree) push(x Int) {
	if segTree.st[x].add != 0 {
		segTree.modifyOne(x<<1, segTree.st[x].add)
		segTree.modifyOne(x<<1|1, segTree.st[x].add)
		segTree.st[x].add = 0
	}
}

func (segTree SegTree) update(x Int) {
	if segTree.st[x<<1].val < segTree.st[x<<1|1].val {
		segTree.st[x].val = segTree.st[x<<1].val
		segTree.st[x].minIndex = segTree.st[x<<1].minIndex
	} else {
		segTree.st[x].val = segTree.st[x<<1|1].val
		segTree.st[x].minIndex = segTree.st[x<<1|1].minIndex
	}
}

func (segTree SegTree) modifyOne(x, add Int) {
	segTree.st[x].val += add
	if segTree.st[x].l != segTree.st[x].r {
		segTree.st[x].add += add
	}
}

func (segTree SegTree) Modify(x, l, r, add Int) {
	if segTree.st[x].l >= l && segTree.st[x].r <= r {
		segTree.modifyOne(x, add)
		return
	}
	segTree.push(x)
	mid := (segTree.st[x].l + segTree.st[x].r) >> 1
	if mid >= l {
		segTree.Modify(x<<1, l, r, add)
	}
	if mid < r {
		segTree.Modify(x<<1|1, l, r, add)
	}
	segTree.update(x)
}

func updateRes(cRes, cIndex, res, index Int) (Int, Int) {
	if cRes > res {
		return res, index
	}
	return cRes, cIndex
}

func (segTree SegTree) Query(x, l, r Int) (Int, Int) {
	res := Int(math.MaxInt64)
	resInd := -L1
	if segTree.st[x].l >= l && segTree.st[x].r <= r {
		res, resInd = updateRes(res, resInd, segTree.st[x].val, segTree.st[x].minIndex)
		return res, resInd
	}
	mid := (segTree.st[x].l + segTree.st[x].r) >> 1
	if mid >= l {
		sonRes, sonInd := segTree.Query(x<<1, l, r)
		res, resInd = updateRes(res, resInd, sonRes, sonInd)
	}
	if mid < r {
		sonRes, sonInd := segTree.Query(x<<1|1, l, r)
		res, resInd = updateRes(res, resInd, sonRes, sonInd)
	}
	return res, resInd
}

type Graph struct {
	nodeSize Int
	edges    []Edge
	head     []Int
	dis      []Int
	vis      []bool
	nCnt     Int
	ans      []Int
}

type Edge struct {
	u, v, c, indices, next Int
}

func NewGraph(nodeSize Int) *Graph {
	return &Graph{
		nodeSize: nodeSize,
		edges:    make([]Edge, (2e5+10)<<2),
		head:     make([]Int, nodeSize+100),
		dis:      make([]Int, nodeSize+100),
		vis:      make([]bool, nodeSize+100),
		nCnt:     L1,
		ans:      make([]Int, nodeSize),
	}
}

func (g *Graph) addEdge(u Int, v Int, cost Int, indices Int) {
	g.nCnt++
	g.edges[g.nCnt] = Edge{u, v, cost, indices, g.head[u]}
	g.head[u] = g.nCnt
}

func (g *Graph) Dijkstra(begin Int) {
	for i := L1; i <= g.nodeSize; i++ {
		g.dis[i] = math.MaxInt64
	}
	pq := make(PriorityQueue, 0)
	heap.Init(&pq)

	g.dis[begin] = 0
	heap.Push(&pq, &Item{begin, 0, -1, -1})

	id := L0

	for len(pq) > 0 {
		it := heap.Pop(&pq).(*Item)
		u := it.value
		if g.vis[u] {
			continue
		}
		g.vis[u] = true

		if it.indices != -1 && id < g.nodeSize-1 {
			g.ans[id] = it.indices
			id++
		}

		for i := g.head[u]; i != 0; i = g.edges[i].next {
			v := g.edges[i].v
			if g.dis[v] > g.dis[u]+g.edges[i].c {
				g.dis[v] = g.dis[u] + g.edges[i].c

				heap.Push(&pq, &Item{v, g.dis[v], g.edges[i].indices, -1})
			}
		}
	}
}

package main

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

func Solve() {
	n := ri()
	var a, b []int
	for i := 0; i < n; i++ {
		a = append(a, ri())
	}
	m := ri()
	for i := 0; i < m; i++ {
		b = append(b, ri())
	}
	ma, mb := max(a...), max(b...)
	if ma == mb {
		println("Alice\nBob")
	} else if ma > mb {
		println("Alice\nAlice")
	} else {
		println("Bob\nBob")
	}
}

func main() {
	T := 0 // 如果是单组样例，请讲 T := 0 改为 T := 1
	in, out = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	if T == 0 {
		scan(&T)
	}
	for t := 0; t < T; t++ {
		Solve()
	}
	out.Flush()
}

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

// ri 将直接读入并返回一个 int
func ri() (x int) {
	scan(&x)
	return x
}

//rs 将直接读入并返回一个 string
func rs() (s string) {
	scan(&s)
	return s
}

//scan 用法与 fmt.scan() 相似，可以传入多个变量的地址进行读入操作
func scan(a ...interface{}) { Fscan(in, a...) }

//print 用法与 fmt.print() 相似，可以传入多个变量进行输出。注意，这个函数不会换行，多个变量之间有空格
func print(a ...interface{}) { Fprint(out, a...) }

//println 用法与 fmt.println() 相似，可以传入多个变量进行输出。这个函数会换行，多个变量之间有空格
func println(a ...interface{}) { Fprintln(out, a...) }

//min 可以传入多个 int 变量，求出这些变量的最小值
func min(a ...int) int {
	ans := a[0]
	for i := 1; i < len(a); i++ {
		if a[i] < ans {
			ans = a[i]
		}
	}
	return ans
}

//max 可以传入多个 int 变量，求出这些变量的最大值
func max(a ...int) int {
	ans := a[0]
	for i := 1; i < len(a); i++ {
		if a[i] > ans {
			ans = a[i]
		}
	}
	return ans
}

//sum 可以传入多个 int 变量，求出这些变量的总和，并返回总和。
//你可以使用 ... 运算符打散数组，使得 sum 函数可以求出数组的和。
func sum(a ...int) int {
	ans := 0
	for _, x := range a {
		ans += x
	}
	return ans
}

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	_, _ = fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	_, _ = fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	_, _ = fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	_, _ = fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) Println(v ...interface{}) {
	_, _ = fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	_, _ = fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	_, _ = fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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

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

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

func main() {
	io := NewIO(os.Stdin, os.Stdout)
	for t := io.ReadInt(); t > 0; t-- {
		n := io.ReadInt()
		a := io.ReadIntSlice(n)
		m := io.ReadInt()
		b := io.ReadIntSlice(m)

		mxa := 0
		for _, v := range a {
			mxa = max(mxa, v)
		}

		mxb := 0
		for _, v := range b {
			mxb = max(mxb, v)
		}

		if mxa > mxb {
			fmt.Println("Alice")
			fmt.Println("Alice")
		} else if mxb > mxa {
			fmt.Println("Bob")
			fmt.Println("Bob")
		} else {
			fmt.Println("Alice")
			fmt.Println("Bob")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var t, n, m int

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

		fmt.Scanf("%d\n", &m)
		bob := readSlice(m)

		w1, w2 := solveA(alice, bob)
		fmt.Println(w1)
		fmt.Println(w2)
	}
}

func readSlice(n int) []int {
	nums := make([]int, n)
	for j := 0; j < n; j++ {
		fmt.Scanf("%d\n", &nums[j])
	}
	return nums
}

func solveA(alice, bob []int) (string, string) {
	sort.Ints(alice)
	sort.Ints(bob)

	la := len(alice)
	lb := len(bob)

	if alice[la-1] < bob[lb-1] {
		return "Bob", "Bob"
	}
	if alice[la-1] > bob[lb-1] {
		return "Alice", "Alice"
	}
	return "Alice", "Bob"
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		var alice,ta,bob,tb int
		for j:=0;j<n;j++{
			var x int
			fmt.Fscan(in,&x)
			if x > alice || j ==0 {
				alice=x
				ta=1
				continue
			}
			if alice == x {
				ta++
			}
		}
		fmt.Fscan(in,&n)
		for j:=0;j<n;j++{
			var x int
			fmt.Fscan(in,&x)
			if x > bob || j ==0 {
				bob=x
				tb=1
				continue
			}
			if bob == x {
				tb++
			}
		}
		if alice>bob || (alice==bob && ta>tb) {
			fmt.Fprintln(out,"Alice")
			fmt.Fprintln(out,"Alice")
		} else if bob > alice || (bob==alice && tb>ta){
			fmt.Fprintln(out,"Bob")
			fmt.Fprintln(out,"Bob")
		} else {
			fmt.Fprintln(out,"Alice")
			fmt.Fprintln(out,"Bob")
		}
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		var alice,ta,bob,tb int
		for j:=0;j<n;j++{
			var x int
			fmt.Fscan(in,&x)
			if x > alice || j ==0 {
				alice=x
				ta=1
				continue
			}
			if alice == x {
				ta++
			}
		}
		fmt.Fscan(in,&n)
		for j:=0;j<n;j++{
			var x int
			fmt.Fscan(in,&x)
			if x > bob || j ==0 {
				bob=x
				tb=1
				continue
			}
			if bob == x {
				tb++
			}
		}
		if alice > bob {
			fmt.Fprintln(out,"Alice")
			fmt.Fprintln(out,"Alice")
		} else if bob > alice {
			fmt.Fprintln(out,"Bob")
			fmt.Fprintln(out,"Bob")
		} else {
			if ta > tb {
				fmt.Fprintln(out,"Alice")
				fmt.Fprintln(out,"Alice")
			} else if tb > ta {
				fmt.Fprintln(out,"Bob")
				fmt.Fprintln(out,"Bob")
			} else {
				fmt.Fprintln(out,"Alice")
				fmt.Fprintln(out,"Bob")
			}
		}
	}
}

package main

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

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

func CF1691B(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var T int64
	fmt.Fscan(r, &T)
	for ; T > 0; T-- {
		var n, m int64
		fmt.Fscan(r, &n)
		a := make([]int64, n)
		for i := int64(0); i < n; i++ {
			fmt.Fscan(r, &a[i])
		}
		val, total := 0, 0
		fmt.Fscan(r, &m)
		for i := int64(0); i < m; i++ {
			fmt.Fscan(r, &val)
			total += val
			total %= len(a)
		}
		fmt.Fprintln(w, a[total%len(a)])
	}
}

package main

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

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

func CF1691A(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var T int64
	fmt.Fscan(r, &T)
	for ; T > 0; T-- {
		var a, aMax, b, bMax int64
		var val int64
		fmt.Fscan(r, &a)
		for i := int64(0); i < a; i++ {
			fmt.Fscan(r, &val)
			aMax = max(a, aMax)
		}
		fmt.Fscan(r, &b)
		for i := int64(0); i < b; i++ {
			fmt.Fscan(r, &val)
			bMax = max(b, bMax)
		}
		if aMax > bMax {
			fmt.Fprintln(w, "Alice")
			fmt.Fprintln(w, "Alice")
		} else if aMax == bMax {
			fmt.Fprintln(w, "Alice")
			fmt.Fprintln(w, "Bob")
		} else {
			fmt.Fprintln(w, "Bob")
			fmt.Fprintln(w, "Bob")
		}
	}

}

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