package main

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

var union []int

func initUnion(n int) {
	union = make([]int, n)
	for i := 0; i < n; i++ {
		union[i] = i
	}
}

func queryUnion(x int) int {
	for {
		if union[x] == x {
			return x
		} else {
			u := queryUnion(union[x])
			union[x] = u
			return u
		}
	}
}

func combineUnion(x int, y int) {
	ux := queryUnion(x)
	uy := queryUnion(y)
	if ux != uy {
		union[uy] = ux
	}
}

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

	var n, m int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	if n == 1 {
		if m == 0 {
			fmt.Printf("YES\n1\n1 1")
			return
		} else if m == 1 {
			fmt.Printf("YES\n0")
			return
		} else {
			fmt.Printf("NO")
			return
		}
	}
	initUnion(n)

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

	for i := 0; i < n; i++ {
		edge[i] = make([]int, 0, 2)
	}
	for i := 0; i < m; i++ {
		var vx, vy int
		fmt.Fscanf(reader, "%d %d\n", &vx, &vy)
		vx--
		vy--
		if vx == vy {
			fmt.Printf("NO")
			return
		}
		edge[vx] = append(edge[vx], vy)
		edge[vy] = append(edge[vy], vx)
		if len(edge[vx]) > 2 {
			fmt.Printf("NO")
			return
		}
		if len(edge[vy]) > 2 {
			fmt.Printf("NO")
			return
		}
		combineUnion(vx, vy)
	}
	ansvx := make([]int, 0, 50)
	ansvy := make([]int, 0, 50)
	for i := 0; i < n; i++ {
		for j := 0; j < n && len(edge[i]) < 2; j++ {
			if i == j {
				continue
			}
			if len(edge[j]) < 2 && ((m < n-1 && queryUnion(i) != queryUnion(j)) || m == n-1) {
				if i < j {
					ansvx = append(ansvx, i)
					ansvy = append(ansvy, j)
				} else {
					ansvx = append(ansvx, j)
					ansvy = append(ansvy, i)
				}
				combineUnion(i, j)
				edge[i] = append(edge[i], j)
				edge[j] = append(edge[j], i)
				m++
			}
		}
	}

	if m != n {
		fmt.Printf("NO")
		return
	}

	for i := 1; i < n; i++ {
		if queryUnion(0) != queryUnion(i) {
			fmt.Printf("NO")
			return
		}
	}

	fmt.Printf("YES\n%d\n", len(ansvx))
	for i := 0; i < len(ansvx); i++ {
		fmt.Printf("%d %d\n", ansvx[i]+1, ansvy[i]+1)
	}

}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	n, m := readTwoNums(reader)
	E := make([][]int, m)
	for i := 0; i < m; i++ {
		E[i] = readNNums(reader, 2)
	}
	cnt, res := solve(n, m, E)

	if cnt < 0 {
		fmt.Println("NO")
		return
	}
	var buf bytes.Buffer
	buf.WriteString("YES\n")
	buf.WriteString(fmt.Sprintf("%d\n", cnt))
	for i := 0; i < len(res); i++ {
		buf.WriteString(fmt.Sprintf("%d %d\n", res[i][0], res[i][1]))
	}
	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') {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

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

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

	return i
}

func solve(n, m int, E [][]int) (int, [][]int) {
	if m > n {
		return -1, nil
	}

	if n == 1 {
		if m == 0 {
			return 1, [][]int{{1, 1}}
		}
		return 0, nil
	}

	degree := make([]int, n)

	uf := NewUFSet(n)

	for i := 0; i < m; i++ {
		u, v := E[i][0], E[i][1]
		u--
		v--
		degree[u]++
		if degree[u] > 2 {
			return -1, nil
		}

		degree[v]++
		if degree[v] > 2 {
			return -1, nil
		}
		uf.Union(u, v)
	}
	var sameComp = true
	var tot int
	compDegree := make([]int, n)
	for i := 0; i < n && sameComp; i++ {
		sameComp = uf.Find(i) == uf.Find(0)
		tot += degree[i]
		compDegree[uf.Find(i)] += degree[i]
	}

	if sameComp && tot == 2*n {
		return 0, nil
	}

	for i := 0; i < n; i++ {
		p := uf.Find(i)
		if uf.cnt[p]*2 == compDegree[p] {
			return -1, nil
		}
	}

	res := make([][]int, 0, n-m)

	for i := 0; i < n && uf.size > 1; {
		if degree[i] == 2 {
			i++
			continue
		}
		for j := i + 1; j < n; j++ {
			if degree[j] == 2 || uf.Find(i) == uf.Find(j) {
				continue
			}
			degree[i]++
			degree[j]++

			uf.Union(i, j)

			res = append(res, []int{i + 1, j + 1})
			break
		}
	}

	var first, second = -1, -1
	for i := 0; i < n; i++ {
		if degree[i] == 1 {
			if first < 0 {
				first = i
			}
			second = i
		}
	}
	res = append(res, []int{first + 1, second + 1})

	return len(res), res
}

type Pair struct {
	first, second int
}

type Pairs []Pair

func (ps Pairs) Len() int {
	return len(ps)
}

func (ps Pairs) Less(i, j int) bool {
	return ps[i].first < ps[j].first || ps[i].first == ps[j].first && ps[i].second < ps[j].second
}

func (ps Pairs) Swap(i, j int) {
	ps[i], ps[j] = ps[j], ps[i]
}

type UFSet struct {
	arr  []int
	cnt  []int
	size int
}

func NewUFSet(n int) UFSet {
	arr := make([]int, n)
	cnt := make([]int, n)

	for i := 0; i < n; i++ {
		arr[i] = i
		cnt[i] = 1
	}

	return UFSet{arr, cnt, n}
}

func (uf *UFSet) Find(x int) int {
	if uf.arr[x] != x {
		uf.arr[x] = uf.Find(uf.arr[x])
	}
	return uf.arr[x]
}

func (uf *UFSet) Union(a, b int) bool {
	pa := uf.Find(a)
	pb := uf.Find(b)
	if pa == pb {
		return false
	}

	if uf.cnt[pa] < uf.cnt[pb] {
		pa, pb = pb, pa
	}
	uf.cnt[pa] += uf.cnt[pb]
	uf.arr[pb] = pa
	uf.size--
	return true
}

package main

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

var union []int

func initUnion(n int) {
	union = make([]int, n)
	for i := 0; i < n; i++ {
		union[i] = i
	}
}

func queryUnion(x int) int {
	for {
		if union[x] == x {
			return x
		} else {
			u := queryUnion(union[x])
			union[x] = u
			return u
		}
	}
}

func combineUnion(x int, y int) {
	ux := queryUnion(x)
	uy := queryUnion(y)
	if ux != uy {
		union[uy] = ux
	}
}

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

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

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

	for i := 0; i < n; i++ {
		edge[i] = make([]int, 0, 2)
	}
	for i := 0; i < m; i++ {
		var vx, vy int
		fmt.Fscanf(reader, "%d %d\n", &vx, &vy)
		vx--
		vy--
		edge[vx] = append(edge[vx], vy)
		edge[vy] = append(edge[vy], vx)
		if len(edge[vx]) > 2 {
			fmt.Printf("NO")
			return
		}
		if len(edge[vy]) > 2 {
			fmt.Printf("NO")
			return
		}
		combineUnion(vx, vy)
	}
	ansvx := make([]int, 0, 50)
	ansvy := make([]int, 0, 50)
	for i := 0; i < n; i++ {
		for j := 0; j < n && len(edge[i]) < 2; j++ {
			if i == j {
				continue
			}
			if len(edge[j]) < 2 && ((m < n-1 && queryUnion(i) != queryUnion(j)) || m == n-1) {
				if i < j {
					ansvx = append(ansvx, i)
					ansvy = append(ansvy, j)
				} else {
					ansvx = append(ansvx, j)
					ansvy = append(ansvy, i)
				}
				combineUnion(i, j)
				edge[i] = append(edge[i], j)
				edge[j] = append(edge[j], i)
				m++
			}
		}
	}

	if m != n {
		fmt.Printf("NO")
		return
	}

	for i := 1; i < n; i++ {
		if queryUnion(0) != queryUnion(i) {
			fmt.Printf("NO")
			return
		}
	}

	fmt.Printf("YES\n%d\n", len(ansvx))
	for i := 0; i < len(ansvx); i++ {
		fmt.Printf("%d %d\n", ansvx[i]+1, ansvy[i]+1)
	}

}

package main

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

var union []int

func initUnion(n int) {
	union = make([]int, n)
	for i := 0; i < n; i++ {
		union[i] = i
	}
}

func queryUnion(x int) int {
	for {
		if union[x] == x {
			return x
		} else {
			u := queryUnion(union[x])
			union[x] = u
			return u
		}
	}
}

func combineUnion(x int, y int) {
	ux := queryUnion(x)
	uy := queryUnion(y)
	if ux != uy {
		union[uy] = ux
	}
}

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

	var n, m int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	if n == 1 {
		if m == 0 {
			fmt.Printf("YES\n1\n1 1")
			return
		} else if m == 1 {
			fmt.Printf("YES\n0")
		} else {
			fmt.Printf("NO")
		}
	}
	initUnion(n)

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

	for i := 0; i < n; i++ {
		edge[i] = make([]int, 0, 2)
	}
	for i := 0; i < m; i++ {
		var vx, vy int
		fmt.Fscanf(reader, "%d %d\n", &vx, &vy)
		vx--
		vy--
		if vx == vy {
			fmt.Printf("NO")
			return
		}
		edge[vx] = append(edge[vx], vy)
		edge[vy] = append(edge[vy], vx)
		if len(edge[vx]) > 2 {
			fmt.Printf("NO")
			return
		}
		if len(edge[vy]) > 2 {
			fmt.Printf("NO")
			return
		}
		combineUnion(vx, vy)
	}
	ansvx := make([]int, 0, 50)
	ansvy := make([]int, 0, 50)
	for i := 0; i < n; i++ {
		for j := 0; j < n && len(edge[i]) < 2; j++ {
			if i == j {
				continue
			}
			if len(edge[j]) < 2 && ((m < n-1 && queryUnion(i) != queryUnion(j)) || m == n-1) {
				if i < j {
					ansvx = append(ansvx, i)
					ansvy = append(ansvy, j)
				} else {
					ansvx = append(ansvx, j)
					ansvy = append(ansvy, i)
				}
				combineUnion(i, j)
				edge[i] = append(edge[i], j)
				edge[j] = append(edge[j], i)
				m++
			}
		}
	}

	if m != n {
		fmt.Printf("NO")
		return
	}

	for i := 1; i < n; i++ {
		if queryUnion(0) != queryUnion(i) {
			fmt.Printf("NO")
			return
		}
	}

	fmt.Printf("YES\n%d\n", len(ansvx))
	for i := 0; i < len(ansvx); i++ {
		fmt.Printf("%d %d\n", ansvx[i]+1, ansvy[i]+1)
	}

}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	n, m := readTwoNums(reader)
	E := make([][]int, m)
	for i := 0; i < m; i++ {
		E[i] = readNNums(reader, 2)
	}
	cnt, res := solve(n, m, E)

	if cnt < 0 {
		fmt.Println("NO")
		return
	}
	var buf bytes.Buffer
	buf.WriteString("YES\n")
	buf.WriteString(fmt.Sprintf("%d\n", cnt))
	for i := 0; i < len(res); i++ {
		buf.WriteString(fmt.Sprintf("%d %d\n", res[i][0], res[i][1]))
	}
	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') {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

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

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

	return i
}

func solve(n, m int, E [][]int) (int, [][]int) {
	degree := make([]int, n)

	uf := NewUFSet(n)

	for i := 0; i < m; i++ {
		u, v := E[i][0], E[i][1]
		u--
		v--
		degree[u]++
		degree[v]++
		uf.Union(u, v)
	}

	G := make(map[int][]int)

	for i := 0; i < n; i++ {
		p := uf.Find(i)
		if _, found := G[p]; !found {
			G[p] = make([]int, 0, n)
		}
		G[p] = append(G[p], i)
	}
	cand := make([]int, 0, len(G))
	for p, v := range G {
		var first, second = -1, -1
		var allTwo = true
		for _, i := range v {
			if degree[i] > 2 {
				return -1, nil
			}
			if degree[i] == 1 {
				allTwo = false
				if first < 0 {
					first = i
				} else if second < 0 {
					second = i
				}
			}

		}
		if allTwo {
			continue
		}

		if len(v) == 1 {
			cand = append(cand, p)
			cand = append(cand, p)
		} else {
			cand = append(cand, first)
			cand = append(cand, second)
		}

	}

	sort.Ints(cand)

	res := make([][]int, 0, len(G))

	for i := 0; i < len(cand); i += 2 {
		res = append(res, []int{cand[i] + 1, cand[i+1] + 1})
	}

	return len(res), res
}

type UFSet struct {
	arr []int
	cnt []int
}

func NewUFSet(n int) UFSet {
	arr := make([]int, n)
	cnt := make([]int, n)

	for i := 0; i < n; i++ {
		arr[i] = i
		cnt[i] = 1
	}

	return UFSet{arr, cnt}
}

func (uf *UFSet) Find(x int) int {
	if uf.arr[x] != x {
		uf.arr[x] = uf.Find(uf.arr[x])
	}
	return uf.arr[x]
}

func (uf *UFSet) Union(a, b int) bool {
	pa := uf.Find(a)
	pb := uf.Find(b)
	if pa == pb {
		return false
	}

	if uf.cnt[pa] < uf.cnt[pb] {
		pa, pb = pb, pa
	}
	uf.cnt[pa] += uf.cnt[pb]
	uf.arr[pb] = pa
	return true
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	n, m := readTwoNums(reader)
	E := make([][]int, m)
	for i := 0; i < m; i++ {
		E[i] = readNNums(reader, 2)
	}
	cnt, res := solve(n, m, E)

	if cnt < 0 {
		fmt.Println("NO")
		return
	}
	var buf bytes.Buffer
	buf.WriteString("YES\n")
	buf.WriteString(fmt.Sprintf("%d\n", cnt))
	for i := 0; i < len(res); i++ {
		buf.WriteString(fmt.Sprintf("%d %d\n", res[i][0], res[i][1]))
	}
	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') {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

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

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

	return i
}

func solve(n, m int, E [][]int) (int, [][]int) {
	degree := make([]int, n)

	uf := NewUFSet(n)

	for i := 0; i < m; i++ {
		u, v := E[i][0], E[i][1]
		u--
		v--
		degree[u]++
		degree[v]++
		uf.Union(u, v)
	}

	G := make(map[int][]int)

	for i := 0; i < n; i++ {
		p := uf.Find(i)
		if _, found := G[p]; !found {
			G[p] = make([]int, 0, n)
		}
		G[p] = append(G[p], i)
	}
	cand := make([]int, 0, len(G))
	for _, v := range G {
		var first, second = -1, -1
		var allTwo = true
		for _, i := range v {
			if degree[i] > 2 {
				return -1, nil
			}
			if degree[i] == 1 {
				allTwo = false
				if first < 0 {
					first = i
				}
				if second < 0 {
					second = i
				}
			}

		}
		if allTwo {
			continue
		}

		cand = append(cand, first)
		cand = append(cand, second)
	}

	sort.Ints(cand)

	res := make([][]int, 0, len(G))

	for i := 0; i < len(cand); i += 2 {
		res = append(res, []int{cand[i] + 1, cand[i+1] + 1})
	}

	return len(res), res
}

type UFSet struct {
	arr []int
	cnt []int
}

func NewUFSet(n int) UFSet {
	arr := make([]int, n)
	cnt := make([]int, n)

	for i := 0; i < n; i++ {
		arr[i] = i
		cnt[i] = 1
	}

	return UFSet{arr, cnt}
}

func (uf *UFSet) Find(x int) int {
	if uf.arr[x] != x {
		uf.arr[x] = uf.Find(uf.arr[x])
	}
	return uf.arr[x]
}

func (uf *UFSet) Union(a, b int) bool {
	pa := uf.Find(a)
	pb := uf.Find(b)
	if pa == pb {
		return false
	}

	if uf.cnt[pa] < uf.cnt[pb] {
		pa, pb = pb, pa
	}
	uf.cnt[pa] += uf.cnt[pb]
	uf.arr[pb] = pa
	return true
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	n, m := readTwoNums(reader)
	E := make([][]int, m)
	for i := 0; i < m; i++ {
		E[i] = readNNums(reader, 2)
	}
	cnt, res := solve(n, m, E)

	if cnt < 0 {
		fmt.Println("NO")
		return
	}
	var buf bytes.Buffer
	buf.WriteString("YES\n")
	buf.WriteString(fmt.Sprintf("%d\n", cnt))
	for i := 0; i < len(res); i++ {
		buf.WriteString(fmt.Sprintf("%d %d\n", res[i][0], res[i][1]))
	}
	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') {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

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

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

	return i
}

func solve(n, m int, E [][]int) (int, [][]int) {
	degree := make([]int, n)

	uf := NewUFSet(n)

	for i := 0; i < m; i++ {
		u, v := E[i][0], E[i][1]
		u--
		v--
		degree[u]++
		degree[v]++
		uf.Union(u, v)
	}

	G := make(map[int][]int)

	for i := 0; i < n; i++ {
		p := uf.Find(i)
		if _, found := G[p]; !found {
			G[p] = make([]int, 0, n)
		}
		G[p] = append(G[p], i)
	}
	cand := make([]int, 0, len(G))
	for p, v := range G {
		// all equals to 1, or all equals 2, or only one node
		if len(v) == 1 {
			// p need to be connected twice
			cand = append(cand, p)
			cand = append(cand, p)
			continue
		}
		var first, second = -1, -1
		var allTwo = true
		for _, i := range v {
			if degree[i] > 2 {
				return -1, nil
			}
			if degree[i] == 1 {
				allTwo = false
				if first < 0 {
					first = i
				} else if second < 0 {
					second = i
				}
			}

		}
		if allTwo {
			continue
		}

		cand = append(cand, first)
		cand = append(cand, second)
	}

	sort.Ints(cand)

	res := make([][]int, 0, len(G))

	for i := 0; i < len(cand); i += 2 {
		res = append(res, []int{cand[i] + 1, cand[i+1] + 1})
	}

	return len(res), res
}

type UFSet struct {
	arr []int
	cnt []int
}

func NewUFSet(n int) UFSet {
	arr := make([]int, n)
	cnt := make([]int, n)

	for i := 0; i < n; i++ {
		arr[i] = i
		cnt[i] = 1
	}

	return UFSet{arr, cnt}
}

func (uf *UFSet) Find(x int) int {
	if uf.arr[x] != x {
		uf.arr[x] = uf.Find(uf.arr[x])
	}
	return uf.arr[x]
}

func (uf *UFSet) Union(a, b int) bool {
	pa := uf.Find(a)
	pb := uf.Find(b)
	if pa == pb {
		return false
	}

	if uf.cnt[pa] < uf.cnt[pb] {
		pa, pb = pb, pa
	}
	uf.cnt[pa] += uf.cnt[pb]
	uf.arr[pb] = pa
	return true
}


package main

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

type minheap []int

func (h minheap) Len() int { return len(h) }

func (h minheap) Less(i, j int) bool { return h[i] < h[j] }

func (h minheap) Swap(i, j int) { h[i], h[j] = h[j], h[i] }

func (h *minheap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *minheap) Pop() interface{} {
	n := len(*h)
	x := (*h)[n-1]
	*h = (*h)[0 : n-1]

	return x
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

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

	n, m := in(), in()

	g := make([][]int, n)
	vis := make([]bool, n)

	var u, v int

	for i := 0; i < m; i++ {
		u = in()
		u--
		v = in()
		v--

		if g[u] == nil {
			g[u] = make([]int, 0)
		}

		g[u] = append(g[u], v)

		if g[v] == nil {
			g[v] = make([]int, 0)
		}

		g[v] = append(g[v], u)
	}

	cnt := 0
	h := new(minheap)
	heap.Push(h, 0)

	for cnt < n {
		x := heap.Pop(h).(int)
		fmt.Print(x+1, " ")

		vis[x] = true

		for i := range g[x] {
			if !vis[g[x][i]] {
				heap.Push(h, g[x][i])
				vis[g[x][i]] = true
			}
		}
		cnt++
	}

	fmt.Println()
}

package main

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

var (
	mapp  [][]int
	visit []bool
	mheap []int
	hp    int
)

func addEdge(u, v int) {
	if len(mapp[u]) == 0 {
		mapp[u] = make([]int, 0)
	}
	mapp[u] = append(mapp[u], v)
}
func addD(u int) {
	hp++
	mheap[hp] = u
	p := hp
	fp := p / 2
	for fp > 0 {
		if mheap[fp] > mheap[p] {
			tmp := mheap[fp]
			mheap[fp] = mheap[p]
			mheap[p] = tmp
		} else {
			break
		}
		p = fp
		fp = p / 2
	}
	//fmt.Printf("%d head %d: %v\n",u,hp,mheap)
}
func popD() int {
	if hp <=0{
		return 0
	}
	res := mheap[1]
	mheap[1] = mheap[hp]
	hp--
	root := 1
	for root < hp {
		lc := root * 2
		rc := lc + 1
		if (lc > hp || mheap[root] <= mheap[lc]) && (rc > hp || mheap[root] <= mheap[rc]) {
			break
		}else if lc <= hp && mheap[root] >= mheap[lc] && (rc > hp || mheap[lc] <= mheap[rc]) {
			tmp := mheap[root]
			mheap[root] = mheap[lc]
			mheap[lc] = tmp
			root = lc
		} else if rc <= hp && mheap[root] >= mheap[rc] && (lc > hp || mheap[lc] >= mheap[rc]) {
			tmp := mheap[root]
			mheap[root] = mheap[rc]
			mheap[rc] = tmp
			root = rc
		}else{
			break
		}
	}
//	fmt.Printf("pop %d head pop %d: %v\n",res,hp,mheap)
	return res
}
func solveD() {

	for {
		root := popD()
		if root <= 0 {
			break
		}
		fmt.Printf("%d ", root)
		for _, v := range mapp[root] {
			if visit[v] == false {
				addD(v)
				visit[v] = true
			}
		}

	}
	fmt.Printf("\n")
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var n, m int
	fmt.Fscanf(buf, "%d %d\n", &n, &m)
	mapp = make([][]int, n+1)
	mheap = make([]int,n+2)
	visit= make([]bool,n+1)
	hp = 0
	addD(1)
	visit[1] = true
	for i := 0; i < m; i++ {
		var x, y int
		fmt.Fscanf(buf, "%d %d\n", &x, &y)
		addEdge(x, y)
		addEdge(y, x)
	}
	solveD()
}

package main

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

type intHeap []int

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

func (h *intHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *intHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, m int
	fmt.Fscan(r, &n, &m)
	edges := make(map[int]map[int]struct{}, 2*m)
	for i := 0; i < m; i++ {
		var a, b int
		fmt.Fscan(r, &a, &b)
		if edges[a] == nil {
			edges[a] = make(map[int]struct{})
		}
		if edges[b] == nil {
			edges[b] = make(map[int]struct{})
		}
		edges[a][b] = struct{}{}
		edges[b][a] = struct{}{}
	}
	ans := make([]int, 0, n)
	visit := make(map[int]struct{}, n)
	inHeap := make(map[int]struct{}, n)
	var h intHeap
	heap.Push(&h, 1)
	for len(h) > 0 {
		to := heap.Pop(&h).(int)
		ans = append(ans, to)
		visit[to] = struct{}{}
		for dst := range edges[to] {
			if _, ok := visit[dst]; ok {
				continue
			}
			if _, ok := inHeap[dst]; ok {
				continue
			}
			inHeap[dst] = struct{}{}
			heap.Push(&h, dst)
		}
	}
	for i := 0; i < n; i++ {
		if i != 0 {
			fmt.Print(" ")
		}
		fmt.Printf("%d", ans[i])
	}
}

package main

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

var (
	mapp  [][]int
	visit []bool
	mheap []int
	hp    int
)

func addEdge(u, v int) {
	if len(mapp[u]) == 0 {
		mapp[u] = make([]int, 0)
	}
	mapp[u] = append(mapp[u], v)
}
func addD(u int) {
	hp++
	mheap[hp] = u
	maxx := hp
	p := maxx
	fp := p / 2
	for fp > 0 {
		if mheap[fp] > mheap[p] {
			tmp := mheap[fp]
			mheap[fp] = mheap[p]
			mheap[p] = tmp
		} else {
			break
		}
		p = fp
		fp = p / 2
	}
	//fmt.Printf("%d head %d: %v\n",u,hp,mheap)
}
func popD() int {
	if hp <=0{
		return 0
	}
	res := mheap[1]
	mheap[1] = mheap[hp]
	hp--
	root := 1
	for root < hp {
		lc := root * 2
		rc := lc + 1
		if (lc > hp || mheap[root] <= mheap[lc]) && (rc > hp || mheap[root] <= mheap[rc]) {
			break
		}

		if lc <= hp && mheap[root] >= mheap[lc] && (rc > hp || mheap[lc] <= mheap[rc]) {
			tmp := mheap[root]
			mheap[root] = mheap[lc]
			mheap[lc] = tmp
			root = lc
		}else {
	//	if rc <= hp && mheap[root] >= mheap[rc] && (lc > hp || mheap[lc] >= mheap[rc]) {
			tmp := mheap[root]
			mheap[root] = mheap[rc]
			mheap[rc] = tmp
			root = rc
		}
	}
//	fmt.Printf("pop %d head pop %d: %v\n",res,hp,mheap)
	return res
}
func solveD() {

	for {
		root := popD()
		if root <= 0 {
			return
		}
		fmt.Printf("%d ", root)
		for _, v := range mapp[root] {
			if visit[v] == false {
				addD(v)
				visit[v] = true
			}
		}

	}
	fmt.Printf("\n")
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var n, m int
	fmt.Fscanf(buf, "%d %d\n", &n, &m)
	mapp = make([][]int, n+1)
	mheap = make([]int,n+2)
	visit= make([]bool,n+1)
	hp = 0
	addD(1)
	visit[1] = true
	for i := 0; i < m; i++ {
		var x, y int
		fmt.Fscanf(buf, "%d %d\n", &x, &y)
		addEdge(x, y)
		addEdge(y, x)
	}
	solveD()
}

package main

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

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

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

// An IntHeap is a min-heap of ints.
type IntHeap []int

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

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func main() {
	defer writer.Flush()
	var n, m, t, f int
	scanf("%d %d\n", &n, &m)
	ed := make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		ed[i] = []int{}
	}
	for i := 0; i < m; i++ {
		scanf("%d %d\n", &f, &t)
		ed[f] = append(ed[f], t)
		ed[t] = append(ed[t], f)
	}

	vis := make(map[int]bool)

	hp := &IntHeap{}
	heap.Push(hp, 1)
	vis[1] = true

	for i := 0; i < n; i++ {
		t = heap.Pop(hp).(int)
		printf("%d ", t)

		for j := 0; j < len(ed[t]); j++ {
			if !vis[ed[t][j]] {
				heap.Push(hp, ed[t][j])
				vis[ed[t][j]] = true
			}
		}
	}
}

package main

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

var (
	mapp  [][]int
	visit []bool
	mheap []int
	hp    int
)

func addEdge(u, v int) {
	if len(mapp[u]) == 0 {
		mapp[u] = make([]int, 0)
	}
	mapp[u] = append(mapp[u], v)
}
func addD(u int) {
	hp++
	mheap[hp] = u
	maxx := hp
	p := maxx
	fp := p / 2
	for fp > 0 {
		if mheap[fp] > mheap[p] {
			tmp := mheap[fp]
			mheap[fp] = mheap[p]
			mheap[p] = tmp
		} else {
			break
		}
		p = fp
		fp = p / 2
	}
	//fmt.Printf("%d head %d: %v\n",u,hp,mheap)
}
func popD() int {
	if hp <=0{
		return 0
	}
	res := mheap[1]
	mheap[1] = mheap[hp]
	hp--
	root := 1
	for root < hp {
		lc := root * 2
		rc := lc + 1
		if (lc > hp || mheap[root] <= mheap[lc]) && (rc > hp || mheap[root] <= mheap[rc]) {
			break
		}

		if lc <= hp && mheap[root] >= mheap[lc] && (rc > hp || mheap[lc] <= mheap[rc]) {
			tmp := mheap[root]
			mheap[root] = mheap[lc]
			mheap[lc] = tmp
			root = lc
		}
		if rc <= hp && mheap[root] >= mheap[rc] && (lc > hp || mheap[lc] >= mheap[rc]) {
			tmp := mheap[root]
			mheap[root] = mheap[rc]
			mheap[rc] = tmp
			root = rc
		}
	}
//	fmt.Printf("pop %d head pop %d: %v\n",res,hp,mheap)
	return res
}
func solveD() {

	for {
		root := popD()
		if root <= 0 {
			return
		}
		fmt.Printf("%d ", root)
		for _, v := range mapp[root] {
			if visit[v] == false {
				addD(v)
				visit[v] = true
			}
		}

	}
	fmt.Printf("\n")
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var n, m int
	fmt.Fscanf(buf, "%d %d\n", &n, &m)
	mapp = make([][]int, n+1)
	mheap = make([]int,n+2)
	visit= make([]bool,n+1)
	hp = 0
	addD(1)
	visit[1] = true
	for i := 0; i < m; i++ {
		var x, y int
		fmt.Fscanf(buf, "%d %d\n", &x, &y)
		addEdge(x, y)
		addEdge(y, x)
	}
	solveD()
}

package main

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

var v []bool

func dfs(i int, g [][]int) {
	if v[i] == true {
		return
	}

	fmt.Print(i+1, " ")

	v[i] = true

	for j := range g[i] {
		dfs(g[i][j], g)
	}
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

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

	n, m := in(), in()

	g := make([][]int, n)
	v = make([]bool, n)

	var u, v int

	for i := 0; i < m; i++ {
		u = in()
		u--
		v = in()
		v--

		if g[u] == nil {
			g[u] = make([]int, 0)
		}

		g[u] = append(g[u], v)

		if g[v] == nil {
			g[v] = make([]int, 0)
		}

		g[v] = append(g[v], u)
	}

	for i := range g {
		sort.Slice(g[i], func(j, k int) bool {
			return g[i][j] < g[i][k]
		})
	}

	dfs(0, g)
	fmt.Println()
}

package main

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

type minheap []int

func (h minheap) Len() int { return len(h) }

func (h minheap) Less(i, j int) bool { return h[i] < h[j] }

func (h minheap) Swap(i, j int) { h[i], h[j] = h[j], h[i] }

func (h *minheap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *minheap) Pop() interface{} {
	n := len(*h)
	x := (*h)[n-1]
	*h = (*h)[0 : n-1]

	return x
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

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

	n, m := in(), in()

	g := make([][]int, n)
	vis := make([]bool, n)

	var u, v int

	for i := 0; i < m; i++ {
		u = in()
		u--
		v = in()
		v--

		if g[u] == nil {
			g[u] = make([]int, 0)
		}

		g[u] = append(g[u], v)

		if g[v] == nil {
			g[v] = make([]int, 0)
		}

		g[v] = append(g[v], u)
	}

	cnt := 1
	vis[0] = true

	h := new(minheap)

	for i := range g[0] {
		heap.Push(h, g[0][i])
		vis[g[0][i]] = true
	}

	fmt.Print(1, " ")

	for cnt < n {
		x := heap.Pop(h).(int)
		fmt.Print(x+1, " ")

		for i := range g[x] {
			if !vis[g[x][i]] {
				heap.Push(h, g[x][i])
				vis[g[x][i]] = true
			}
		}
		cnt++
	}

	fmt.Println()
}

package main

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

type intHeap []int

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

func (h *intHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *intHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, m int
	fmt.Fscan(r, &n, &m)
	edges := make(map[int]map[int]struct{}, 2*m)
	for i := 0; i < m; i++ {
		var a, b int
		fmt.Fscan(r, &a, &b)
		if edges[a] == nil {
			edges[a] = make(map[int]struct{})
		}
		if edges[b] == nil {
			edges[b] = make(map[int]struct{})
		}
		edges[a][b] = struct{}{}
		edges[b][a] = struct{}{}
	}
	ans := make([]int, 0, n)
	visit := make(map[int]struct{}, n)
	var h intHeap
	heap.Push(&h, 1)
	for len(h) > 0 {
		to := heap.Pop(&h).(int)
		ans = append(ans, to)
		visit[to] = struct{}{}
		for dst := range edges[to] {
			if _, ok := visit[dst]; ok {
				continue
			}
			heap.Push(&h, dst)
		}
	}
	for i := 0; i < n; i++ {
		if i != 0 {
			fmt.Print(" ")
		}
		fmt.Printf("%d", ans[i])
	}
}

// This example demonstrates an integer heap built using the heap interface.
package main

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

type intHeap []int

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

func (h *intHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *intHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, m int
	fmt.Fscan(r, &n, &m)
	edges := make(map[int][]int, 2*m)
	for i := 0; i < m; i++ {
		var a, b int
		fmt.Fscan(r, &a, &b)
		edges[a] = append(edges[a], b)
		edges[b] = append(edges[b], a)
	}
	ans := make([]int, 0, n)
	visit := make(map[int]struct{}, n)
	var h intHeap
	heap.Push(&h, 1)
	for len(h) > 0 {
		to := heap.Pop(&h).(int)
		ans = append(ans, to)
		visit[to] = struct{}{}
		for _, dst := range edges[to] {
			if _, ok := visit[dst]; ok {
				continue
			}
			heap.Push(&h, dst)
		}
	}
	for i := 0; i < n; i++ {
		if i != 0 {
			fmt.Print(" ")
		}
		fmt.Printf("%d", ans[i])
	}
}


package main

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

func main() {
	firstArrayCount := ScanInt()
	firstArray := ScanIntSlice(firstArrayCount)
	secondArrayCount := ScanInt()
	secondArray := ScanIntSlice(secondArrayCount)
	totalArrayMap := make(map[int]int, firstArrayCount+ secondArrayCount+ 1)

	for i := 0; i < firstArrayCount; i++{
		totalArrayMap[firstArray[i]] = 1
	}

	for i := 0; i < secondArrayCount; i++{
		totalArrayMap[secondArray[i]] = 1
	}
	for i := 0; i < firstArrayCount; i++{
		for j := 0; j < secondArrayCount; j++{
			if totalArrayMap[firstArray[i] + secondArray[j]] != 1{
				P(firstArray[i] , secondArray[j])
				return
			}
		}
	}

	P(totalArrayMap)

	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 ...int) (int, int) {
	minVal, maxVal := int(math.MaxInt32), int(math.MinInt32)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int) int { mn, _ := MnMx(args...); return mn }
func Mx(args ...int) int { _, mx := MnMx(args...); return mx }
func LCM(a, b int) int   { return a / GCD(a, b) * b }
func GCD(a, b int) int {
	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 int) int {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

/* solution */

func solve() {

	n := readInt()
	maxA := readInt()
	for i := 1; i < n; i++ {
		a := readInt()
		if a > maxA {
			maxA = a
		}
	}

	m := readInt()
	maxB := readInt()
	for i := 1; i < m; i++ {
		b := readInt()
		if b > maxB {
			maxB = b
		}
	}

	printInt(maxA)
	printInt(maxB)

}

/* 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)
	reader.Split(bufio.ScanWords)

	solve()

}

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

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

package main

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

func main() {
	var n, m, x int64

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &n)
	ma := make(map[int64]bool)

	for i := int64(0); i < n; i++ {
		fmt.Fscanf(scr, "%d", &x)
		ma[x] = true
	}
	fmt.Fscanf(scr, "%d", &x)

	fmt.Fscanln(scr, &m)
	mb := make(map[int64]bool)

	for i := int64(0); i < m; i++ {
		fmt.Fscanf(scr, "%d", &x)
		mb[x] = true
	}

oc:
	for y := range ma {
		for x := range mb {
			if !ma[x+y] && !mb[x+y] {
				fmt.Println(y, x)
				break oc
			}
		}
	}

}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	n, a, b := 0, 0, 0
	str := ""
	fmt.Scanf("%d\n", &n)
	fmt.Scanln(&str)
	a, _ = strconv.Atoi(str)
	for i := 1; i < n; i++ {
		tmp := 0
		fmt.Scanf("%d", &tmp)
		if tmp > a {
			a = tmp
		}
	}
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		tmp := 0
		fmt.Scanf("%d", &tmp)
		if tmp > b {
			b = tmp
		}
	}
	fmt.Println(a, b)
}

package main

import ("fmt")

func Max(n int) (max int) {
    var tmp int
    for i:=0; i < n; i++ {
        fmt.Scan(&tmp)
        if tmp > max {
            max = tmp
        }
    }
    return
}

func main() {
    var n int
    fmt.Scan(&n)
    a := Max(n)
    fmt.Scan(&n)
    b := Max(n)
    fmt.Print(a, b)
}

package main

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

func main() {
	var n, a int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n)
	max1 := 0
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a)
		if max1 < a {
			max1 = a
		}
	}
	fmt.Fscan(in, &n)
	max2 := 0
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a)
		if max2 < a {
			max2 = a
		}
	}
	fmt.Println(max1, max2)
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n)
	var m []int = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&m[i])
	}
	sort.Ints(m)
	fmt.Scan(&k)
	var m2 []int = make([]int, k)
	for i := 0; i < k; i++ {
		fmt.Scan(&m2[i])
	}
	sort.Ints(m2)
	fmt.Println(m[n-1], m2[k-1])
}

package main

import "fmt"

func max() (maxA int) {
	var n, buf int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&buf)
		if buf > maxA {
			maxA = buf
		}
	}
	return maxA
}

func main() {
	fmt.Println(max(), max())
}

package main

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

var in = bufio.NewScanner(os.Stdin)

func nextInt() int {
	in.Scan()
	r := 0
	for _, c := range in.Bytes() {
		r *= 10
		r += int(c - '0')
	}
	return r
}

func main() {
	in.Split(bufio.ScanWords)
	ra, rb := 0, 0
	for n := nextInt(); n > 0; n-- {
		if a := nextInt(); ra < a {
			ra = a
		}
	}
	for m := nextInt(); m > 0; m-- {
		if b := nextInt(); rb < b {
			rb = b
		}
	}
	fmt.Println(ra, rb)
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"math/rand"
	"os"
)

const INF  = 1000000001

type Pair struct {
	first, second int
}

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 abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func sort(arr []int) []int {
	if len(arr) < 2 {
		return arr
	}
	left := 0
	right := len(arr) - 1
	pivot := rand.Int() % len(arr)

	arr[pivot], arr[right] = arr[right], arr[pivot]

	for i := 0; i < len(arr); i++ {
		if arr[i] < arr[right] {
			arr[i], arr[left] = arr[left], arr[i]
			left++
		}
	}

	arr[left], arr[right] = arr[right], arr[left]

	sort(arr[:left])
	sort(arr[left+1:])
	return arr
}

func solution(reader io.Reader, writer io.Writer) {
	var n, m int

	h := make(map[int]bool)

	fmt.Fscanf(reader, "%d\n", &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &a[i])
		h[a[i]] = true
	}

	fmt.Fscanf(reader, "\n%d\n", &m)
	b := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Fscanf(reader, "%d", &b[i])
		h[b[i]] = true
	}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			_, ok := h[a[i] + b[j]]
			if !ok {
				fmt.Fprintf(writer, "%d %d\n", a[i], b[j])
				return
			}
		}
	}

}

func main() {

	//stdin, err := os.Open("file.in")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdin.Close()
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	//stdout, err := os.Create("file.out")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdout.Close()
	stdout := os.Stdout
	writer := bufio.NewWriterSize(stdout, 1024*1024)
	defer writer.Flush()

	solution(reader, writer)
}

package main

import "fmt"

func solve(n, m int, a, b []int) (x, y int) {
	mark := make([]bool, 401)
	for i := 0; i < n; i++ {
		mark[a[i]] = true
	}
	for j := 0; j < m; j++ {
		mark[b[j]] = true
	}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if !mark[a[i]+b[j]] {
				return a[i], b[j]
			}
		}
	}
	return 0, 0
}

func main() {
	var n, m int
	var a, b []int
	fmt.Scan(&n)
	a = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	fmt.Scan(&m)
	b = make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&b[i])
	}
	var x, y = solve(n, m, a, b)
	fmt.Printf("%d %d\n", x, y)
}

package main

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

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

	var n, m, temp int
	fmt.Fscanf(reader, "%d\n", &n)
	a := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &temp)
		a[i] = temp
	}
	fmt.Fscanf(reader, "\n")
	fmt.Fscanf(reader, "%d\n", &m)
	b := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Fscanf(reader, "%d", &temp)
		b[i] = temp
	}
	sort.Ints(a)
	sort.Ints(b)
	fmt.Fscanf(reader, "\n")
	fmt.Fprintf(writer, "%d %d\n", a[len(a)-1], b[len(b)-1])
}

package main

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

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

	var n, m, temp, aMax, bMax int
	aMax = 0
	bMax = 0
	fmt.Fscanf(reader, "%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &temp)
		if temp > aMax {
			aMax = temp
		}
	}
	fmt.Fscanf(reader, "\n")
	fmt.Fscanf(reader, "%d\n", &m)
	for i := 0; i < m; i++ {
		fmt.Fscanf(reader, "%d", &temp)
		if temp > bMax {
			bMax = temp
		}
	}
	fmt.Fscanf(reader, "\n")
	fmt.Fprintf(writer, "%d %d\n", aMax, bMax)
}

// Author: sighduck
// URL: https://codeforces.com/contest/1206/problem/A

package main

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

type Solution struct {
	maxA int
	maxB int
}

func max(arr []int) int {
	maxElem := arr[0]
	for i := 1; i < len(arr); i++ {
		if arr[i] > maxElem {
			maxElem = arr[i]
		}
	}
	return maxElem
}

func Solve(A []int, B []int) Solution {
	return Solution{maxA: max(A), maxB: max(B)}
}

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

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

	var m int
	fmt.Fscan(reader, &m)
	B := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Fscan(reader, &B[i])
	}

	solution := Solve(A, B)
	fmt.Fprintf(writer, "%d %d\n", solution.maxA, solution.maxB)
}

package main

import (
	"fmt"
  "math/rand"
)

func main() {

  var n int
  var verif int = 1
  var lA int
  var lB int
  var m int
  var randomA int
  var randomB int
  var SUM int
  var A [150]int
  var B [150]int
	fmt.Scan(&n)
	for i := 0; i <= n-1; i++{
		fmt.Scan(&A[i])
	}
  fmt.Scan(&m)
  for i := 0; i <= m-1; i++{
		fmt.Scan(&B[i])
	}
  for verif==1 {
    lA=0
    lB=0
    randomA=rand.Intn(n)
    randomB=rand.Intn(m)
    SUM = A[randomA]+B[randomB]
    for SUM!=A[lA] && lA<n {
            lA++
    }
    for SUM!=B[lB] && lB<m {
            lB++
    }
    if (lA==n) && (lB==m) && (A[n-1]!=SUM) && (B[m-1]!=SUM) {
      verif = 0

    }
}
    fmt.Printf("%d %d\n", A[randomA] , B[randomB])
}

package main

import "fmt"

func Max(x1, x2 int) int {
	if x1 < x2 {
		return x2
	} else {
		return x1
	}
}

func main() {
	var n, m int
	fmt.Scan(&n)
	maxA := 0
	for i := 0; i < n; i++ {
		var x int
		fmt.Scan(&x)
		maxA = Max(x, maxA)
	}
	fmt.Scan(&m)
	maxB := 0
	for i := 0; i < m; i++ {
		var x int
		fmt.Scan(&x)
		maxB = Max(x, maxB)
	}
	fmt.Printf("%v %v\n", maxA, maxB)
}

package main

import "fmt"

func main(){
	var n int
	fmt.Scan(&n)
	a := make([]int,n)
	readN(a,0,n)
	fmt.Scan(&n)
	b := make([]int,n)
	readN(b,0,n)
	fmt.Println(max(a),max(b))
}

func max(a []int)int{
	m:= a[0]
	for i:=0;i<len(a);i++{
		if a[i]>m{
			m = a[i]
		}
	}
	return m
}

func readN(a []int,i ,n int){
	if n==0{
		return
	}
	if m,err := scan(&a[i]);m!=1{
		panic(err)
	}
	readN(a,i+1,n-1)
}

func scan(i *int)(int,error){
	return fmt.Scan(i)
}

//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 _max(a []int) int {
	ret := a[0]
	for i := 1; i < len(a); i++ {
		if a[i] > ret {
			ret = a[i]
		}
	}
	return ret
}

func main() {
	n := ReadInt()
	a := ReadIntSlice(n)
	m := ReadInt()
	b := ReadIntSlice(m)
	fmt.Println(_max(a), _max(b))
}

/*********** 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 readInt64() int64 {
	return readIntNbits(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"
	"fmt"
	"os"
	"sort"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var an int
	fmt.Fscan(r, &an)
	a := make([]int, an)
	for i := 0; i < an; i++ {
		fmt.Fscan(r, &a[i])
	}
	var bn int
	fmt.Fscan(r, &bn)
	b := make([]int, bn)
	for i := 0; i < bn; i++ {
		fmt.Fscan(r, &b[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(b)))
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	fmt.Printf("%d %d", a[0], b[0])

}

package main

import "fmt"

func main() {
    var n,m int
	var a,b,mark [401]int

	fmt.Scan(&n)
	for i:=0 ; i<n; i++ {
	    fmt.Scan(&a[i])
	    mark[a[i]] = 1
	}

	fmt.Scan(&m)
	for i:=0 ; i<m; i++ {
	    fmt.Scan(&b[i])
	    mark[b[i]] = 1
	}

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

	    for j:=0; j<m; j++ {

	        var val = a[i] + b[j]

	        if mark[val]!=1 {
	            fmt.Println(a[i], b[j])
	            return
	        }
	    }
	}

}

package main

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

func main() {
	var n, m, x int64

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &n)
	ma := make(map[int64]bool)

	for i := int64(0); i < n; i++ {
		fmt.Fscanf(scr, "%d", &x)
		ma[x] = true
	}
	fmt.Fscanf(scr, "%d", &x)

	fmt.Fscanln(scr, &m)
	mb := make(map[int64]bool)

	for i := int64(0); i < m; i++ {
		fmt.Fscanf(scr, "%d", &x)
		mb[x] = true
	}

oc:
	for y := range ma {
		for x := range mb {
			if !ma[x+y] || !mb[x+y] {
				fmt.Println(y, x)
				break oc
			}
		}
	}

}

package main

import (
	"fmt"
  "math/rand"
)

func main() {

  var n int
  var verif int = 1
  var lA int= 0
  var lB int= 0
  var m int
  var randomA int
  var randomB int
  var SUM int
  var A [100]int
  var B [100]int
	fmt.Scan(&n)
	for i := 0; i <= n-1; i++{
		fmt.Scan(&A[i])
	}
  fmt.Scan(&m)
  for i := 0; i <= m-1; i++{
		fmt.Scan(&B[i])
	}
  for verif==1 {
    randomA=rand.Intn(n)
    randomB=rand.Intn(m)
    SUM = A[randomA]+B[randomB]
    for SUM!=A[lA] && lA<n {
      lA++
    }
    for SUM!=B[lB] && lB<m {
      lB++
    }
    if (lA!=n-1) && (lB!=m-1) {
      verif = 0
    }
}
    fmt.Printf("%d %d\n", A[randomA] , B[randomB])
}

package main

import (
	"fmt"
  "math/rand"
)

func main() {

  var n int
  var verif int = 1
  var lA int= 0
  var lB int= 0
  var m int
  var randomA int
  var randomB int
  var SUM int
  var A [200]int
  var B [200]int
	fmt.Scan(&n)
	for i := 0; i <= n-1; i++{
		fmt.Scan(&A[i])
	}
  fmt.Scan(&m)
  for i := 0; i <= m-1; i++{
		fmt.Scan(&B[i])
	}
  for verif==1 {
    randomA=rand.Intn(n)
    randomB=rand.Intn(m)
    SUM = A[randomA]+B[randomB]

    for SUM!=A[lA] && lA<n {
      lA++
    }
    for SUM!=B[lB] && lB<m {
      lB++
    }
    if (lA==n) && (lB==m) && (A[n-1]!=SUM) && (B[m-1]!=SUM) {
      verif = 0

    }
}
    fmt.Printf("%d %d\n", A[randomA] , B[randomB])
}

package main

import (
	"fmt"
  "math/rand"
)

func main() {

  var n int
  var verif int = 1
  var lA int= 0
  var lB int= 0
  var m int
  var randomA int
  var randomB int
  var SUM int
  var A [150]int
  var B [150]int
	fmt.Scan(&n)
	for i := 0; i <= n-1; i++{
		fmt.Scan(&A[i])
	}
  fmt.Scan(&m)
  for i := 0; i <= m-1; i++{
		fmt.Scan(&B[i])
	}
  for verif==1 {
    randomA=rand.Intn(n)
    randomB=rand.Intn(m)
    SUM = A[randomA]+B[randomB]
    for SUM!=A[lA] && lA<n {
      lA++
    }
    for SUM!=B[lB] && lB<m {
      lB++
    }
    if (lA==n) && (lB==m) && (A[n-1]!=SUM) && (B[m-1]!=SUM) {
      verif = 0

    }
}
    fmt.Printf("%d %d\n", A[randomA] , B[randomB])
}

package main

import "fmt"

func main() {
    var n,m int
	var a,b,mark [401]int

	fmt.Scan(&n)
	for i:=0 ; i<n; i++ {
	    fmt.Scan(&a[i])
	    mark[a[i]] = 1
	}

	fmt.Scan(&m)
	for i:=0 ; i<m; i++ {
	    fmt.Scan(&b[i])
	    mark[b[i]] = 1
	}

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

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

	        var val = a[i] + b[j]

	        if mark[val]!=1 {
	            fmt.Println(a[i], b[j])
	            return
	        }
	    }
	}

}

package main

import "fmt"

func main() {
	n, a, b, tmp := 0, 0, 0, 0
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		if tmp > a {
			a = tmp
		}
	}
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		if tmp > b {
			b = tmp
		}
	}
	fmt.Println(a, b)
}

package main

import "fmt"

func main() {
	n, a, b, tmp := 0, 0, 0, 0
	fmt.Scanf("%d/n", &n)
	fmt.Scanf("%d", &a)
	for i := 1; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		if tmp > a {
			a = tmp
		}
	}
	fmt.Scanf("%d/n", &n)
	fmt.Scanf("%d", &b)
	for i := 1; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		if tmp > b {
			b = tmp
		}
	}
	fmt.Println(a, b)
}

package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	n, a, b := 0, 0, 0
	str := ""
	fmt.Scanf("%d\n", &n)
	fmt.Scanln(&str)
	for _, s := range strings.Split(str, " ") {
		tmp, _ := strconv.Atoi(s)
		if tmp > a {
			a = tmp
		}
	}
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		tmp := 0
		fmt.Scanf("%d", &tmp)
		if tmp > b {
			b = tmp
		}
	}
	fmt.Println(a, b)
}

package main

import "fmt"

func main() {
	n, a, b, tmp := 0, 0, 0, 0
	fmt.Scanf("%d", &n)
	fmt.Scanf("%d", &a)
	for i := 1; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		if tmp > a {
			a = tmp
		}
	}
	fmt.Scanf("%d", &n)
	fmt.Scanf("%d", &b)
	for i := 1; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		if tmp > b {
			b = tmp
		}
	}
	fmt.Println(a, b)
}

package main

import "fmt"

func main() {
	n, a, b, tmp := 0, 0, 0, 0
	fmt.Scanf("%d/n", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		if tmp > a {
			a = tmp
		}
	}
	fmt.Scanf("%d/n", &n)
	fmt.Scanf("%d", &b)
	for i := 1; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		if tmp > b {
			b = tmp
		}
	}
	fmt.Println(a, b)
}

package main

import "fmt"

func main() {
	n, a, b, tmp := 0, 0, 0, 0
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		if tmp > a {
			a = tmp
		}
	}
	fmt.Scanf("\n%d\n", &n)
	fmt.Printf("n = %d\n", n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		if tmp > b {
			b = tmp
		}
	}
	fmt.Println(a, b)
}

package main

import "fmt"

func main() {
	n, a, b, tmp := 0, 0, 0, 0
	fmt.Scanf("%d", &n)
	fmt.Printf("n = %d\n", n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		if tmp > a {
			a = tmp
		}
	}
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		if tmp > b {
			b = tmp
		}
	}
	fmt.Println(a, b)
}

package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	n, a, b := 0, 0, 0
	str := ""
	fmt.Scanf("%d\n", &n)
	fmt.Scanln(&str)
	for _, s := range strings.Split(str, " ") {
		tmp, _ := strconv.Atoi(s)
		if tmp > a {
			a = tmp
		}
	}
	fmt.Scanf("%d\n", &n)
	fmt.Scanln(&str)
	fmt.Println(str)
	for _, s := range strings.Split(str, " ") {
		tmp, _ := strconv.Atoi(s)
		if tmp > b {
			b = tmp
		}
	}
	fmt.Println(a, b)
}

package main

import "fmt"

func main() {
	n, a, b, tmp := 0, 0, 0, 0
	fmt.Scanf("%d", &n)
	fmt.Printf("n = %d\n", n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		fmt.Printf("tmp = %d a = %d\n", tmp, a)
		if tmp > a {
			a = tmp
		}
		fmt.Printf("a = %d\n", a)
	}
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		if tmp > b {
			b = tmp
		}
	}
	fmt.Println(a, b)
}

package main

import "fmt"

func main() {
	n, a, b, tmp := 0, 0, 0, 0
	fmt.Scanf("%d\n", &n)
	fmt.Printf("n = %d\n", n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		fmt.Printf("tmp = %d a = %d\n", tmp, a)
		if tmp > a {
			a = tmp
		}
		fmt.Printf("a = %d\n", a)
	}
	fmt.Scanf("%d", &n)
	fmt.Printf("n = %d\n", n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		if tmp > b {
			b = tmp
		}
	}
	fmt.Println(a, b)
}

package main

import "fmt"

func main() {
	n, a, b, tmp := 0, 0, 0, 0
	fmt.Scanf("%d", &n)
	fmt.Printf("n = %d\n", n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		fmt.Printf("tmp = %d a = %d\n", tmp, a)
		if tmp > a {
			a = tmp
		}
		fmt.Printf("a = %d\n", a)
	}
	fmt.Scanf("%d", &n)
	fmt.Printf("n = %d\n", n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		if tmp > b {
			b = tmp
		}
	}
	fmt.Println(a, b)
}

package main

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

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

	var n, m, temp int
	fmt.Fscanf(reader, "%d\n", &n)
	a := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &temp)
		a[i] = temp
	}
	fmt.Fscanf(reader, "\n")
	fmt.Fscanf(reader, "%d\n", &m)
	b := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Fscanf(reader, "%d", &temp)
		b[i] = temp
	}
	sort.Ints(a)
	sort.Ints(b)
	fmt.Fscanf(reader, "\n")
	fmt.Fprintf(writer, "%d %d\n", a[len(a)-1], b[len(a)-1])
}


package main

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

///////// red black tree //////////////

type Comparator func(a, b interface{}) int

type color bool

const (
	black, red color = true, false
)

type RBTree struct {
	Root       *RBNode
	size       int
	Comparator Comparator
}

type RBNode struct {
	Key    interface{}
	Value  interface{}
	color  color
	Left   *RBNode
	Right  *RBNode
	Parent *RBNode
}

func NewRBTree(comparator Comparator) *RBTree {
	return &RBTree{Comparator: comparator}
}

func (tree *RBTree) Put(key interface{}, value interface{}) {
	var insertedRBNode *RBNode
	if tree.Root == nil {
		tree.Comparator(key, key)
		tree.Root = &RBNode{Key: key, Value: value, color: red}
		insertedRBNode = tree.Root
	} else {
		node := tree.Root
		loop := true
		for loop {
			compare := tree.Comparator(key, node.Key)
			switch {
			case compare == 0:
				node.Key = key
				node.Value = value
				return
			case compare < 0:
				if node.Left == nil {
					node.Left = &RBNode{Key: key, Value: value, color: red}
					insertedRBNode = node.Left
					loop = false
				} else {
					node = node.Left
				}
			case compare > 0:
				if node.Right == nil {
					node.Right = &RBNode{Key: key, Value: value, color: red}
					insertedRBNode = node.Right
					loop = false
				} else {
					node = node.Right
				}
			}
		}
		insertedRBNode.Parent = node
	}
	tree.insertCase1(insertedRBNode)
	tree.size++
}

func (tree *RBTree) Begin() *RBNode {
	if tree.Root == nil {
		return nil
	}

	node := tree.Root
	for node.Left != nil {
		node = node.Left
	}
	return node
}

func (tree *RBTree) Last() *RBNode {
	if tree.Root == nil {
		return nil
	}

	node := tree.Root
	for node.Right != nil {
		node = node.Right
	}
	return node
}

func (tree *RBTree) Get(key interface{}) (value interface{}, found bool) {
	node := tree.lookup(key)
	if node != nil {
		return node.Value, true
	}
	return nil, false
}

func (tree *RBTree) GetRBNode(key interface{}) *RBNode {
	return tree.lookup(key)
}

func (tree *RBTree) Remove(key interface{}) {
	var child *RBNode
	node := tree.lookup(key)
	if node == nil {
		return
	}
	if node.Left != nil && node.Right != nil {
		pred := node.Left.maximumRBNode()
		node.Key = pred.Key
		node.Value = pred.Value
		node = pred
	}
	if node.Left == nil || node.Right == nil {
		if node.Right == nil {
			child = node.Left
		} else {
			child = node.Right
		}
		if node.color == black {
			node.color = nodeColor(child)
			tree.deleteCase1(node)
		}
		tree.replaceRBNode(node, child)
		if node.Parent == nil && child != nil {
			child.color = black
		}
	}
	tree.size--
}

func (tree *RBTree) Empty() bool {
	return tree.size == 0
}

func (tree *RBTree) Size() int {
	return tree.size
}

func (node *RBNode) Size() int {
	if node == nil {
		return 0
	}
	size := 1
	if node.Left != nil {
		size += node.Left.Size()
	}
	if node.Right != nil {
		size += node.Right.Size()
	}
	return size
}

func (tree *RBTree) Keys() []interface{} {
	keys := []interface{}{}
	var dfs func(node *RBNode)
	dfs = func(node *RBNode) {
		if node == nil {
			return
		}
		dfs(node.Left)
		keys = append(keys, node.Key)
		dfs(node.Right)
	}

	dfs(tree.Root)
	return keys
}

func (tree *RBTree) Values() []interface{} {
	values := []interface{}{}
	var dfs func(node *RBNode)
	dfs = func(node *RBNode) {
		if node == nil {
			return
		}
		dfs(node.Left)
		values = append(values, node.Value)
		dfs(node.Right)
	}

	dfs(tree.Root)
	return values
}

func (tree *RBTree) Left() *RBNode {
	var parent *RBNode
	current := tree.Root
	for current != nil {
		parent = current
		current = current.Left
	}
	return parent
}

func (tree *RBTree) Right() *RBNode {
	var parent *RBNode
	current := tree.Root
	for current != nil {
		parent = current
		current = current.Right
	}
	return parent
}

func (tree *RBTree) Floor(key interface{}) (floor *RBNode, found bool) {
	found = false
	node := tree.Root
	for node != nil {
		compare := tree.Comparator(key, node.Key)
		switch {
		case compare == 0:
			return node, true
		case compare < 0:
			node = node.Left
		case compare > 0:
			floor, found = node, true
			node = node.Right
		}
	}
	if found {
		return floor, true
	}
	return nil, false
}

func (tree *RBTree) Ceiling(key interface{}) (ceiling *RBNode, found bool) {
	found = false
	node := tree.Root
	for node != nil {
		compare := tree.Comparator(key, node.Key)
		switch {
		case compare == 0:
			return node, true
		case compare < 0:
			ceiling, found = node, true
			node = node.Left
		case compare > 0:
			node = node.Right
		}
	}
	if found {
		return ceiling, true
	}
	return nil, false
}

func (tree *RBTree) Clear() {
	tree.Root = nil
	tree.size = 0
}

func (tree *RBTree) String() string {
	str := "RedBlackRBTree\n"
	if !tree.Empty() {
		output(tree.Root, "", true, &str)
	}
	return str
}

func (node *RBNode) String() string {
	return fmt.Sprintf("%v", node.Key)
}

func output(node *RBNode, prefix string, isTail bool, str *string) {
	if node.Right != nil {
		newPrefix := prefix
		if isTail {
			newPrefix += "│   "
		} else {
			newPrefix += "    "
		}
		output(node.Right, newPrefix, false, str)
	}
	*str += prefix
	if isTail {
		*str += "└── "
	} else {
		*str += "┌── "
	}
	*str += node.String() + "\n"
	if node.Left != nil {
		newPrefix := prefix
		if isTail {
			newPrefix += "    "
		} else {
			newPrefix += "│   "
		}
		output(node.Left, newPrefix, true, str)
	}
}

func (tree *RBTree) lookup(key interface{}) *RBNode {
	node := tree.Root
	for node != nil {
		compare := tree.Comparator(key, node.Key)
		switch {
		case compare == 0:
			return node
		case compare < 0:
			node = node.Left
		case compare > 0:
			node = node.Right
		}
	}
	return nil
}

func (node *RBNode) grandparent() *RBNode {
	if node != nil && node.Parent != nil {
		return node.Parent.Parent
	}
	return nil
}

func (node *RBNode) uncle() *RBNode {
	if node == nil || node.Parent == nil || node.Parent.Parent == nil {
		return nil
	}
	return node.Parent.sibling()
}

func (node *RBNode) sibling() *RBNode {
	if node == nil || node.Parent == nil {
		return nil
	}
	if node == node.Parent.Left {
		return node.Parent.Right
	}
	return node.Parent.Left
}

func (tree *RBTree) rotateLeft(node *RBNode) {
	right := node.Right
	tree.replaceRBNode(node, right)
	node.Right = right.Left
	if right.Left != nil {
		right.Left.Parent = node
	}
	right.Left = node
	node.Parent = right
}

func (tree *RBTree) rotateRight(node *RBNode) {
	left := node.Left
	tree.replaceRBNode(node, left)
	node.Left = left.Right
	if left.Right != nil {
		left.Right.Parent = node
	}
	left.Right = node
	node.Parent = left
}

func (tree *RBTree) replaceRBNode(old *RBNode, new *RBNode) {
	if old.Parent == nil {
		tree.Root = new
	} else {
		if old == old.Parent.Left {
			old.Parent.Left = new
		} else {
			old.Parent.Right = new
		}
	}
	if new != nil {
		new.Parent = old.Parent
	}
}

func (tree *RBTree) insertCase1(node *RBNode) {
	if node.Parent == nil {
		node.color = black
	} else {
		tree.insertCase2(node)
	}
}

func (tree *RBTree) insertCase2(node *RBNode) {
	if nodeColor(node.Parent) == black {
		return
	}
	tree.insertCase3(node)
}

func (tree *RBTree) insertCase3(node *RBNode) {
	uncle := node.uncle()
	if nodeColor(uncle) == red {
		node.Parent.color = black
		uncle.color = black
		node.grandparent().color = red
		tree.insertCase1(node.grandparent())
	} else {
		tree.insertCase4(node)
	}
}

func (tree *RBTree) insertCase4(node *RBNode) {
	grandparent := node.grandparent()
	if node == node.Parent.Right && node.Parent == grandparent.Left {
		tree.rotateLeft(node.Parent)
		node = node.Left
	} else if node == node.Parent.Left && node.Parent == grandparent.Right {
		tree.rotateRight(node.Parent)
		node = node.Right
	}
	tree.insertCase5(node)
}

func (tree *RBTree) insertCase5(node *RBNode) {
	node.Parent.color = black
	grandparent := node.grandparent()
	grandparent.color = red
	if node == node.Parent.Left && node.Parent == grandparent.Left {
		tree.rotateRight(grandparent)
	} else if node == node.Parent.Right && node.Parent == grandparent.Right {
		tree.rotateLeft(grandparent)
	}
}

func (node *RBNode) maximumRBNode() *RBNode {
	if node == nil {
		return nil
	}
	for node.Right != nil {
		node = node.Right
	}
	return node
}

func (tree *RBTree) deleteCase1(node *RBNode) {
	if node.Parent == nil {
		return
	}
	tree.deleteCase2(node)
}

func (tree *RBTree) deleteCase2(node *RBNode) {
	sibling := node.sibling()
	if nodeColor(sibling) == red {
		node.Parent.color = red
		sibling.color = black
		if node == node.Parent.Left {
			tree.rotateLeft(node.Parent)
		} else {
			tree.rotateRight(node.Parent)
		}
	}
	tree.deleteCase3(node)
}

func (tree *RBTree) deleteCase3(node *RBNode) {
	sibling := node.sibling()
	if nodeColor(node.Parent) == black &&
		nodeColor(sibling) == black &&
		nodeColor(sibling.Left) == black &&
		nodeColor(sibling.Right) == black {
		sibling.color = red
		tree.deleteCase1(node.Parent)
	} else {
		tree.deleteCase4(node)
	}
}

func (tree *RBTree) deleteCase4(node *RBNode) {
	sibling := node.sibling()
	if nodeColor(node.Parent) == red &&
		nodeColor(sibling) == black &&
		nodeColor(sibling.Left) == black &&
		nodeColor(sibling.Right) == black {
		sibling.color = red
		node.Parent.color = black
	} else {
		tree.deleteCase5(node)
	}
}

func (tree *RBTree) deleteCase5(node *RBNode) {
	sibling := node.sibling()
	if node == node.Parent.Left &&
		nodeColor(sibling) == black &&
		nodeColor(sibling.Left) == red &&
		nodeColor(sibling.Right) == black {
		sibling.color = red
		sibling.Left.color = black
		tree.rotateRight(sibling)
	} else if node == node.Parent.Right &&
		nodeColor(sibling) == black &&
		nodeColor(sibling.Right) == red &&
		nodeColor(sibling.Left) == black {
		sibling.color = red
		sibling.Right.color = black
		tree.rotateLeft(sibling)
	}
	tree.deleteCase6(node)
}

func (tree *RBTree) deleteCase6(node *RBNode) {
	sibling := node.sibling()
	sibling.color = nodeColor(node.Parent)
	node.Parent.color = black
	if node == node.Parent.Left && nodeColor(sibling.Right) == red {
		sibling.Right.color = black
		tree.rotateLeft(node.Parent)
	} else if nodeColor(sibling.Left) == red {
		sibling.Left.color = black
		tree.rotateRight(node.Parent)
	}
}

func nodeColor(node *RBNode) color {
	if node == nil {
		return black
	}
	return node.color
}

///////// priority queue ///////////

type PriorityQueue struct {
	Data       []interface{}
	Comparator func(a, b interface{}) int
}

func NewPriorityQueue(comparator func(a, b interface{}) int) *PriorityQueue {
	res := &PriorityQueue{
		Data:       []interface{}{},
		Comparator: comparator,
	}
	heap.Init(res)
	return res
}

func (pq *PriorityQueue) Len() int {
	return len(pq.Data)
}

func (pq *PriorityQueue) Less(i, j int) bool {
	return pq.Comparator(pq.Data[i], pq.Data[j]) < 0
}

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

func (pq *PriorityQueue) Push(a interface{}) {
	pq.Data = append(pq.Data, a)
}

func (pq *PriorityQueue) Pop() interface{} {
	n := len(pq.Data)
	res := pq.Data[n-1]
	pq.Data = pq.Data[0 : n-1]
	return res
}

func (pq *PriorityQueue) Put(a interface{}) {
	heap.Push(pq, a)
}

func (pq *PriorityQueue) Get() interface{} {
	return heap.Pop(pq)
}

////////////////////////////////////

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

var T, N int

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

	fmt.Fscan(in, &T)

	for tt := 1; tt <= T; tt++ {
		fmt.Fscan(in, &N)
		var a int
		var n0, n1 int
		for i := 0; i < N; i++ {
			fmt.Fscan(in, &a)
			if a%2 == 0 {
				n0++
			} else {
				n1++
			}
		}

		fmt.Println(min(n0, n1))
	}

}

package main

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

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

	var tc int
	Fscan(in, &tc)

	for _t := 0; _t < tc; _t++ {
		var n int
		Fscan(in, &n)

		var numOfEven, numOfOdd, ans int

		for i := 0; i < n; i++ {
			var temp int
			Fscan(in, &temp)

			if temp%2 == 0 {
				numOfEven++
			} else {
				numOfOdd++
			}
		}
		ans = numOfEven
		if numOfOdd > numOfEven {
			ans = numOfOdd
		}
		Fprintln(out, n-ans)
	}
}

*/

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

	var tc int
	Fscan(in, &tc)

	for _t := 0; _t < tc; _t++ {
		var n int
		Fscan(in, &n)

		num := make([]int, n, n)
		parityCounter := make(map[int]int)
		for i := 0; i < n; i++ {
			Fscan(in, &num[i])
			parityCounter[num[i]%2]++
		}
		var ans = parityCounter[0]
		if parityCounter[1] > ans {
			ans = parityCounter[1]
		}
		Fprintln(out, n-ans)
	}
}

package main

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

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

	var tc int
	Fscan(in, &tc)

	for _t := 0; _t < tc; _t++ {
		var n int
		Fscan(in, &n)

		var numOfEven, numOfOdd, ans int

		for i := 0; i < n; i++ {
			var temp int
			Fscan(in, &temp)

			if temp%2 == 0 {
				numOfEven++
			} else {
				numOfOdd++
			}
		}
		ans = numOfEven
		if numOfOdd > numOfEven {
			ans = numOfOdd
		}
		Fprintln(out, n-ans)
	}
}

package main

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

var fin = bufio.NewReader(os.Stdin)
var fout = bufio.NewWriter(os.Stdout)

func solve(){
    var n int
    fmt.Fscan(fin,&n)
    cnt1:=0
    cnt2:=0
    nums := make([]int,n)
    for i:=0;i<n;i++{
        fmt.Fscan(fin,&nums[i])
    }
    for _,v := range nums {
        if v%2 ==0 {
            cnt2++
        } else {
            cnt1++
        }
    }
    ans:=0
    if cnt1 > cnt2 {
        ans = n - cnt1
    } else {
        ans = n - cnt2
    }
    fmt.Fprintln(fout,ans)
}

func main(){
    defer fout.Flush()
    var t int
    fmt.Fscan(fin,&t)
    for ;t>0;t--{
        solve()
    }
}

package main

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

var fin = bufio.NewReader(os.Stdin)
var fout = bufio.NewWriter(os.Stdout)

func solve(){
    var n int
    fmt.Fscan(fin,&n)
    cnt1:=0
    cnt2:=0
    for i:=0;i<n;i++{
        var x int
        fmt.Fscan(fin,&x)
        if x%2==0 {
            cnt2++
        } else {
            cnt1++
        }
    }
    ans:=0
    if cnt1 > cnt2 {
        ans = n - cnt1
    } else {
        ans = n - cnt2
    }
    fmt.Fprintln(fout,ans)
}

func main(){
    defer fout.Flush()
    var t int
    fmt.Fscan(fin,&t)
    for ;t>0;t--{
        solve()
    }
}

package main

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

var fin = bufio.NewReader(os.Stdin)
var fout = bufio.NewWriter(os.Stdout)

func main(){
    defer fout.Flush()
    var t int
    fmt.Fscan(fin,&t)
    for ;t>0;t--{
        var n int
        fmt.Fscan(fin,&n)
        cnt1:=0
        cnt2:=0
        for i:=0;i<n;i++{
            var x int
            fmt.Fscan(fin,&x)
            if x%2==0 {
                cnt2++
            } else {
                cnt1++
            }
        }
        ans:=0
        if cnt1 > cnt2 {
            ans = n - cnt1
        } else {
            ans = n - cnt2
        }
        fmt.Fprintln(fout,ans)
    }
}

package main

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

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

	var testCases int
	Fscan(in, &testCases)

	for c := 0; c < testCases; c++ {
		var n int
		Fscan(in, &n)

		nums := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &nums[i])
		}

		Fprintln(out, solve(nums))
	}

}

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

func solve(nums []int) int {
	oddCount := 0
	evenCount := 0

	for i := 0; i < len(nums); i++ {
		if isEven(nums[i]) {
			evenCount++
		} else {
			oddCount++
		}
	}

	return min(oddCount, evenCount)
}

func isEven(n int) bool {
	return n%2 == 0
}

package main

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

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

func (in *CF1691A) 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 *CF1691A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1691A
Date: 4/06/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1691/A
Problem: CF1691A
**/
func (in *CF1691A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		arr := make([]int, n)
		even := 0
		for i := 0; i < n; i++ {
			arr[i] = in.NextInt()
			if arr[i]%2 == 0 {
				even++
			}
		}

		ans := 0
		if even < n-even {
			ans = even
		}else {
			ans = n -even
		}

		fmt.Println(ans)

	}
}

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

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

package main

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

var (
	_r = bufio.NewReader(os.Stdin)
	_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)
	a := make([]int, 2)
	for i := 0; i < n; i++ {
		var x int
		fmt.Fscan(_r, &x)
		a[x%2]++
	}
	fmt.Fprintln(_w, min(a[0], a[1]))
}
func min(x, y int) int {
	if x <= y {
		return x
	}
	return y
}

package main
import (
	"bufio"
	"fmt"
	"os"
)
var fin = bufio.NewReader(os.Stdin)
var fout = bufio.NewWriter(os.Stdout)
func main() {
	defer fout.Flush()
	t := 0
	fmt.Fscan(fin, &t)
	for tt := 0; tt < t; tt++ {
		n := 0
		fmt.Fscan(fin, &n)
		c := [2]int{}
		for i := 0; i < n; i++ {
			x := 0
			fmt.Fscan(fin, &x)
			c[x % 2] += 1
		}
		if c[0] < c[1] {
			fmt.Fprintln(fout, c[0])
		} else {
			fmt.Fprintln(fout, c[1])
		}
	}
}

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)
		odds:=0
		evens:=0
		for j:=0;j<n;j++{
			var x int
			fmt.Fscan(in,&x)
			if x%2 == 0 {
				evens++
			} else {
				odds++
			}
		}
		if evens > odds {
			fmt.Fprintln(out,odds)
		} else {
			fmt.Fprintln(out,evens)
		}
	}
}

package main

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

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

func solve(n int, a []int) int {
	var odd int
	for _, x := range a {
		odd += x % 2
	}
	if odd > n-odd {
		return n - odd
	}
	return odd
}

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"
	"strconv"
	"strings"
)

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

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

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

func main() {
	in := bufio.NewReader(os.Stdin)
	t := readInt(in)
	for ; t > 0; t-- {
		n := readInt(in)
		arr := readArrInt(in)
		var oddCnt, evenCnt int
		for i := 0; i < n; i++ {
			if arr[i]&1 == 1 {
				oddCnt++
			} else {
				evenCnt++
			}
		}
		if oddCnt == 0 || evenCnt == 0 {
			fmt.Println(0)
		} else if oddCnt < evenCnt {
			fmt.Println(oddCnt)
		} else {
			fmt.Println(evenCnt)
		}
	}
}

package main

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

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

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

func solve() {
	var n,x int
	scan(&n)
	odd := 0
	for i := 0; i < n; i++ {
		scan(&x)
		if x & 1 != 0 {
			odd += 1
		}
	}
	printf("%d\n", int(math.Min(float64(odd), float64(n - odd))))
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int     { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }
func gi2() (int,int) { return gi(),gi() }
func gi3() (int,int,int) { return gi(),gi(),gi() }
func gi4() (int,int,int,int) { return gi(),gi(),gi(),gi() }
func gis(n int) []int  { res := make([]int,n); for i:=0;i<n;i++ { res[i] = gi() }; return res }
func gf() float64 { f,e := strconv.ParseFloat(gs(),64); if e != nil {panic(e)}; return f }
func gbs() []byte { return []byte(gs()) }
func gfs(n int) []float64  { res := make([]float64,n); for i:=0;i<n;i++ { res[i] = gf() }; return res }
func gss(n int) []string  { res := make([]string,n); for i:=0;i<n;i++ { res[i] = gs() }; return res }
func ia(m int) []int { return make([]int,m) }
func iai(m int,v int) []int { a := make([]int,m); for i:=0;i<m;i++ { a[i] = v }; return a }
func twodi(n int,m int,v int) [][]int {
	r := make([][]int,n); for i:=0;i<n;i++ { x := make([]int,m); for j:=0;j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill2(m int) ([]int,[]int) { a,b := ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i] = gi(),gi()}; return a,b }
func fill3(m int) ([]int,[]int,[]int) { a,b,c := ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i] = gi(),gi(),gi()}; return a,b,c }
func fill4(m int) ([]int,[]int,[]int,[]int) { a,b,c,d := ia(m),ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i],d[i] = gi(),gi(),gi(),gi()}; return a,b,c,d }
func abs(a int) int { if a < 0 { return -a }; return a }
func rev(a []int) { i,j := 0,len(a)-1; for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max(a,b int) int { if a > b { return a }; return b }
func min(a,b int) int { if a > b { return b }; return a }
func tern(cond bool, a int, b int) int { if cond { return a }; return b }
func terns(cond bool, a string, b string) string { if cond { return a }; return b }
func maxarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr(a []int) int { ans := 0; for _,aa := range(a) { ans += aa }; return ans }
func zeroarr(a []int) { for i:=0; i<len(a); i++ { a[i] = 0 } }
func powmod(a,e,mod int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint(a,e int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd(a,b int) int { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended(a,b int) (int,int,int) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv(a,m int) (int,bool) { g,x,_ := gcdExtended(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func makefact(n int,mod int) ([]int,[]int) {
	fact,factinv := make([]int,n+1),make([]int,n+1)
	fact[0] = 1; for i:=1;i<=n;i++ { fact[i] = fact[i-1] * i % mod }
	factinv[n] = powmod(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * (i+1) % mod }
	return fact,factinv
}
func vecintstring(a []int) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.Itoa(a) }; return strings.Join(astr," ") }
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	T := gi()
	for tt:=1;tt<=T;tt++ {
		N := gi(); A := gis(N)
		nume,numo := 0,0
		for _,a := range A { if a % 2 == 0 { nume++ } else { numo++ } }
		ans := min(nume,numo)
		fmt.Fprintln(wrtr,ans)
	}
}

package main

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

var t, m, n int

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

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

	t, _ = strconv.Atoi(next())
	for i := 0; i < t; i++ {
		n, _ = strconv.Atoi(next())

		var even, odd int
		for i := 0; i < n; i++ {
			ai, _ := strconv.Atoi(next())
			if ai%2 == 0 {
				even++
			} else {
				odd++
			}
		}
		fmt.Println(math.Min(float64(even), float64(odd)))
	}
}

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, x int
		Fscan(in, &n)
		cnt := L0
		count := L0
		for i := 0; i < n; i++ {
			Fscan(in, &x)
			if x%2 == 0 {
				cnt++
			} else {
				count++
			}
		}
		Fprintln(out, Min(cnt, count))

	}

}

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

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

func slove() {
	var n int
	fmt.Fscan(r, &n)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	cnt := 0
	for i := range nums {
		if nums[i] % 2 == 0 {
			cnt++
		}
	}
	fmt.Fprintln(w, min(cnt, n-cnt))
}
func min(a, b int) int {if a < b {return a} else {return b}}
func main() {
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

import "fmt"

func main() {
	var tc int
	fmt.Scanf("%d", &tc)

	for _t := 0; _t < tc; _t++ {
		var n int
		fmt.Scanf("%d", &n)
		var ans, numberOfEven, numberOfOdd int

		for i := 0; i < n; i++ {
			var temp int
			fmt.Scanf("%d", &temp)
			if temp%2 == 0 {
				numberOfEven++
			} else {
				numberOfOdd++
			}

			ans = numberOfEven

		}
		if numberOfEven < numberOfOdd {
			ans = numberOfOdd
		}

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

package main

import "fmt"

func main() {
	var tc int
	fmt.Scanf("%d", &tc)

	for _t := 0; _t < tc; _t++ {
		var n int
		fmt.Scanf("%d", &n)
		var numberOfEven, numberOfOdd int

		var ans int
		for i := 0; i < n; i++ {
			var temp int
			fmt.Scanf("%d", &temp)
			if temp%2 == 0 {
				numberOfEven++
			} else {
				numberOfOdd++
			}

			ans = numberOfEven

		}
		if numberOfEven < numberOfOdd {
			ans = numberOfOdd
		}

		fmt.Println(n - ans)
	}
}

package main

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

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

	var testCases int
	Fscan(in, &testCases)

	for c := 0; c < testCases; c++ {
		var n int
		Fscan(in, &n)

		nums := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &nums[i])
		}

		Fprintln(out, solve(nums))
	}

}

// func solve(nums []int) int {
// 	count1 := 0

// 	cur := 0
// 	for i := 1; i < len(nums); i++ {
// 		if (nums[cur]+nums[i])%2 == 0 {
// 			cur = i
// 			continue
// 		}
// 		count1++
// 	}

// 	count2 := 0

// 	cur = len(nums) - 1
// 	for i := cur - 1; i >= 0; i-- {
// 		if (nums[cur]+nums[i])%2 == 0 {
// 			cur = i
// 			continue
// 		}
// 		count2++
// 	}

// 	return min(count1, count2)
// }

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

func solve(nums []int) int {
	oddEvenPairCounts := int(0)

	for i := 1; i < len(nums); i++ {
		if isEven(nums[i-1]) != isEven(nums[i]) {
			oddEvenPairCounts++
		}
	}

	if isEven(oddEvenPairCounts) {
		return oddEvenPairCounts / 2
	}
	return (oddEvenPairCounts / 2) + 1
}

func isEven(n int) bool {
	return n%2 == 0
}

package main

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

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

	var testCases int
	Fscan(in, &testCases)

	for c := 0; c < testCases; c++ {
		var n int
		Fscan(in, &n)

		nums := make([]int64, n)
		for i := 0; i < n; i++ {
			Fscan(in, &nums[i])
		}

		Fprintln(out, solve(nums))
	}

}

// func solve(nums []int64) int {
// 	count1 := 0

// 	cur := 0
// 	for i := 1; i < len(nums); i++ {
// 		if (nums[cur]+nums[i])%2 == 0 {
// 			cur = i
// 			continue
// 		}
// 		count1++
// 	}

// 	count2 := 0

// 	cur = len(nums) - 1
// 	for i := cur - 1; i >= 0; i-- {
// 		if (nums[cur]+nums[i])%2 == 0 {
// 			cur = i
// 			continue
// 		}
// 		count2++
// 	}

// 	return min(count1, count2)
// }

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

func solve(nums []int64) int {
	oddEvenPairCounts := 0

	for i := 1; i < len(nums); i++ {
		if isEven(nums[i-1]) != isEven(nums[i]) {
			oddEvenPairCounts++
		}
	}

	return oddEvenPairCounts / 2
}

func isEven(n int64) bool {
	return n%2 == 0
}

package main

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

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

	var testCases int
	Fscan(in, &testCases)

	for c := 0; c < testCases; c++ {
		var n int
		Fscan(in, &n)

		nums := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &nums[i])
		}

		Fprintln(out, solve(nums))
	}

}

func solve(nums []int) int {
	count1 := 0

	cur := 0
	for i := 1; i < len(nums); i++ {
		if (nums[cur]+nums[i])%2 == 0 {
			cur = i
			continue
		}
		count1++
	}

	count2 := 0

	cur = len(nums) - 1
	for i := cur - 1; i >= 0; i-- {
		if (nums[cur]+nums[i])%2 == 0 {
			cur = i
			continue
		}
		count2++
	}

	return min(count1, count2)
}

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

package main

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

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

func (in *CF1691A) 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 *CF1691A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1691A
Date: 4/06/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1691/A
Problem: CF1691A
**/
func (in *CF1691A) 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()
		}

		sum := arr[0]
		ans := 0
		for i := 1; i < n; i++ {
			if (sum+arr[i])%2 != 0 {
				ans++
			} else {
				sum = arr[i]
			}
		}

		v2 := 1
		sum = arr[1]
		for i := 2; i < n; i++ {
			if (sum+arr[i])%2 != 0 {
				v2++
			} else {
				sum = arr[i]
			}
		}
		if v2 < ans {
			ans = v2
		}

		fmt.Println(ans)

	}
}

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

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

package main

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

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

func (in *CF1691A) 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 *CF1691A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1691A
Date: 4/06/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1691/A
Problem: CF1691A
**/
func (in *CF1691A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		sum := 0
		ans := 0
		for i := 0; i < n; i++ {
			val := in.NextInt()
			if i == 0 {
				sum = val
			} else {
				if (sum+val)%2 != 0 {
					ans++
				} else {
					sum = val
				}
			}
		}
		fmt.Println(ans)

	}
}

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

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

package main

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

var (
	_r = bufio.NewReader(os.Stdin)
	_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)
	cnt := make([]int, 2)
	for i := 0; i < n; i++ {
		var x int
		fmt.Fscan(_r, &x)
		if x%2 == 1 {
			cnt[1]++
		} else {
			cnt[0]++
		}
	}
	ans := 0
	for i := 0; i < 2; i++ {
		if cnt[i]%2 != 0 {
			ans++
		}
	}
	fmt.Fprintln(_w, ans)
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scanf("%d", &t)
	for ; t > 0; t-- {
		solve()
	}
}
func solve() {
	var n int
	fmt.Scanf("%d", &n)
	cnt := make([]int, 2)
	for i := 0; i < n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		if x%2 == 1 {
			cnt[1]++
		} else {
			cnt[0]++
		}
	}
	ans := 0
	for i := 0; i < 2; i++ {
		if cnt[i]%2 != 0 {
			ans++
		}
	}
	fmt.Println(ans)
}