package main

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

func solve() {
	n := readInt() * 2
	res := 0
	a := make([]int, n+10)
	cur := 0
	for i := 0; i < n; i++ {
		s := readInt()
		a[s]++
		if a[s] == 1 {
			cur++
			if cur > res {
				res = cur
			}
		} else {
			cur--
		}
	}
	fmt.Println(res)
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

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

// IO

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

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

type fastReader struct {
	data  []byte
	cur   int
	space []byte
}

func NewFastReader(rd io.Reader) *fastReader {
	b, err := ioutil.ReadAll(rd)
	if err != nil {
		panic(err)
	}
	fr := &fastReader{
		data: append(b, byte(0)),
		cur: 0,
		space: []byte(" \n\t\r"),
	}
	return fr
}

func (fr *fastReader) isSpace(b byte) bool {
	for _, d := range fr.space {
		if b == d {
			return true
		}
	}
	return false
}

func (fr *fastReader) asInt(b byte) int64 {
	return int64(b) - int64('0')
}

func (fr *fastReader) read() (b byte) {
	b = fr.data[fr.cur]
	fr.cur++
	return
}

func (fr *fastReader) ReadNoneSpace() byte {
	b := fr.read()
	for fr.isSpace(b) {
		b = fr.read()
	}
	return b
}

func (fr *fastReader) ReadString() string {
	bs := make([]byte, 10)
	b := fr.read()
	if !fr.isSpace(b) {
		bs = append(bs, b)
	}
	return string(bs)
}

func (fr *fastReader) getSign(b byte) (sign int64, bRet byte) {
	if b == '-' {
		sign = -1
		bRet = fr.read()
	} else {
		sign = 1
		if b == '+' {
			bRet = fr.read()
		} else {
			bRet = b
		}
	}
	return
}

func (fr *fastReader) ReadInt() int64 {
	b := fr.ReadNoneSpace()
	sign, b := fr.getSign(b)
	ret := int64(0)
	for !fr.isSpace(b) {
		ret *= 10
		ret += fr.asInt(b)
		b = fr.read()
	}
	return ret * sign
}

func (fr *fastReader) ReaderFloat() float64 {
	b := fr.ReadNoneSpace()
	sign, b := fr.getSign(b)
	ret := float64(0.0)
	for !fr.isSpace(b) && b != '.' {
		if b == 'e' || b == 'E' {
			return ret * math.Pow10(int(fr.ReadInt()))
		}
		ret *= 10
		ret += float64(fr.asInt(b))
		b = fr.read()
	}
	if b == '.' {
		b = fr.read()
		fra := float64(1.0)
		for !fr.isSpace(b) {
			if b == 'e' || b == 'E' {
				return ret * math.Pow10(int(fr.ReadInt()))
			}
			fra /= float64(10)
			ret += float64(fr.asInt(b)) * fra
			b = fr.read()
		}
	}
	return ret * float64(sign)
}

func main() {
	reader := NewFastReader(os.Stdin)

	n := reader.ReadInt()

	var found []bool = make([]bool, n + 1)
	var ans int = 0
	var cur int = 0
	for i := 0; i < 2 * int(n); i++ {
		x := reader.ReadInt()

		if found[x] {
			cur--
		} else {
			cur++
			found[x] = true
		}

		if cur > ans {
			ans = cur
		}
	}

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

package main

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

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

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

	var found []bool = make([]bool, n + 1)
	var ans int = 0
	var cur int = 0
	for i := 0; i < 2 * n; i++ {
		var x int

		for {
			_, err := fmt.Fscanf(reader, "%d", &x)
			if err == nil {
				break
			}
		}

		if found[x] {
			cur--
		} else {
			cur++
			found[x] = true
		}

		if cur > ans {
			ans = cur
		}
	}

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

package main

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

func main() {
	var n int
	if _, err := fmt.Scanf("%d\n", &n); err != nil {
		return
	}

	table := make(map[int]bool)
	table_count := 0
	max_table_count := 0

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; i < 2*n && scanner.Scan(); i++ {
		a, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}

		if _, ok := table[a]; ok {
			delete(table, a)
			table_count -= 1
		} else {
			table[a] = true
			table_count += 1
			if table_count > max_table_count {
				max_table_count = table_count
			}
		}
	}

	fmt.Println(max_table_count)
}

package main

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

func input(in io.Reader) []string {
	reader := bufio.NewReader(in)
	line, _ := reader.ReadString('\n')
	line, _ = reader.ReadString('\n')
	arr := strings.Split(strings.TrimSpace(line), " ")
	return arr
}

func main() {
	var tmp, count, max int
	var arr [100000]bool
	arr2 := input(os.Stdin)
	for i := range arr2 {
		tmp, _ = strconv.Atoi(arr2[i])
		if !arr[tmp-1] {
			arr[tmp-1] = true
			count++
			if count > max {
				max = count
			}
		} else {
			count--
		}
	}
	fmt.Println(max)
}

package main

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

func main() {
	fmt.Println(solveQuestion(os.Stdin))
}

func solveQuestion(in io.Reader) int {
	_, socks := input(in)
	socksOut := 0
	maxSocks := 0
	isSockOut := make(map[string]bool)

	for _, sock := range *socks {
		if isSockOut[sock] {
			// If this is true
			if maxSocks < socksOut {
				maxSocks = socksOut
			}
			socksOut -= 2

		}
		socksOut += 1
		isSockOut[sock] = true

	}
	return maxSocks
}

func input(in io.Reader) (int, *[]string) {
	reader := bufio.NewReader(in)

	line, err := reader.ReadString('\n')
	if err != nil {
		panic(err)
	}
	num1, err := strconv.Atoi(strings.TrimSpace(line))
	if err != nil {
		panic(err)
	}
	line, err = reader.ReadString('\n')
	if err == io.EOF {
		err = nil
	}
	if err != nil {
		panic(err)
	}
	socks := strings.Split(strings.TrimSpace(line), " ")
	if err != nil {
		panic(err)
	}

	return num1, &socks

}

package main

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

func main() {
	fmt.Println(solveQuestion(os.Stdin))
}

func solveQuestion(in io.Reader) int {
	_, socks := input(in)
	socksOut := 0
	maxSocks := 0
	isSockOut := make(map[string]bool)

	for _, sock := range *socks {
		if isSockOut[sock] {
			// If this is true
			if maxSocks < socksOut {
				maxSocks = socksOut
			}
			socksOut -= 2
			delete(isSockOut, sock)

		} else {
			isSockOut[sock] = true
		}
		socksOut += 1

	}
	return maxSocks
}

func input(in io.Reader) (int, *[]string) {
	reader := bufio.NewReader(in)

	line, err := reader.ReadString('\n')
	if err != nil {
		panic(err)
	}
	num1, err := strconv.Atoi(strings.TrimSpace(line))
	if err != nil {
		panic(err)
	}
	line, err = reader.ReadString('\n')
	if err == io.EOF {
		err = nil
	}
	if err != nil {
		panic(err)
	}
	socks := strings.Split(strings.TrimSpace(line), " ")
	if err != nil {
		panic(err)
	}

	return num1, &socks

}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
	"math/big"
)

func main() {
	fmt.Println(solveQuestion(os.Stdin))
}

func solveQuestion(in io.Reader) int {
	_, socks := input(in)
	socksOut := 0
	maxSocks := 0
	isSockOut := Empty()

	for _, sock := range *socks {
		i, err := strconv.Atoi(sock)
		if err != nil {
			panic(err)
		}
		if isSockOut.Test(uint(i)) {
			// If this is true
			if maxSocks < socksOut {
				maxSocks = socksOut
			}
			socksOut -= 2

		} else {
			isSockOut.Set(uint(i))
		}
		socksOut += 1

	}
	return maxSocks
}

func input(in io.Reader) (int, *[]string) {
	reader := bufio.NewReader(in)

	line, err := reader.ReadString('\n')
	if err != nil {
		panic(err)
	}
	num1, err := strconv.Atoi(strings.TrimSpace(line))
	if err != nil {
		panic(err)
	}
	line, err = reader.ReadString('\n')
	if err == io.EOF {
		err = nil
	}
	if err != nil {
		panic(err)
	}
	socks := strings.Split(strings.TrimSpace(line), " ")
	if err != nil {
		panic(err)
	}

	return num1, &socks

}

type BitSet struct {
	bits big.Int
}

func (b *BitSet) Set(bit uint) *BitSet {
	b.bits.SetBit(&b.bits, int(bit), 1)
	return b
}

func (b *BitSet) Test(bit uint) bool {
	return b.bits.Bit(int(bit)) == 1
}

func Empty() *BitSet {
	return new(BitSet)
}

func (b BitSet) String() string {
	return fmt.Sprintf("%b", &b.bits)
}

package main

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

func main() {
	fmt.Println(solveQuestion(os.Stdin))
}

func solveQuestion(in io.Reader) int {
	_, socks := input(in)
	socksOut := 0
	maxSocks := 0
	isSockOut := make(map[string]bool)

	for _, sock := range *socks {
		if isSockOut[sock] {
			// If this is true
			if maxSocks < socksOut {
				maxSocks = socksOut
			}
			socksOut--
		} else {
			isSockOut[sock] = true
			socksOut++
		}
	}
	return maxSocks
}

func input(in io.Reader) (int, *[]string) {
	reader := bufio.NewReader(in)

	line, err := reader.ReadString('\n')
	if err != nil {
		panic(err)
	}
	num1, err := strconv.Atoi(strings.TrimSpace(line))
	if err != nil {
		panic(err)
	}
	line, err = reader.ReadString('\n')
	if err == io.EOF {
		err = nil
	}
	if err != nil {
		panic(err)
	}
	socks := strings.Split(line, " ")
	if err != nil {
		panic(err)
	}

	return num1, &socks

}

package main

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

func main() {
	fmt.Println(solveQuestion(os.Stdin))
}

func solveQuestion(in io.Reader) int {
	_, socks := input(in)
	socksOut := 0
	maxSocks := 0
	isSockOut := make(map[string]bool)

	fmt.Println(*socks)
	for _, sock := range *socks {
		if isSockOut[sock] {
			// If this is true
			if maxSocks < socksOut {
				maxSocks = socksOut
			}
			socksOut -= 2

		}
		socksOut += 1
		isSockOut[sock] = true

	}
	return maxSocks
}

func input(in io.Reader) (int, *[]string) {
	reader := bufio.NewReader(in)

	line, err := reader.ReadString('\n')
	if err != nil {
		panic(err)
	}
	num1, err := strconv.Atoi(strings.TrimSpace(line))
	if err != nil {
		panic(err)
	}
	line, err = reader.ReadString('\n')
	if err == io.EOF {
		err = nil
	}
	if err != nil {
		panic(err)
	}
	socks := strings.Split(strings.TrimSpace(line), " ")
	if err != nil {
		panic(err)
	}

	return num1, &socks

}

package main

import (
	"fmt"
)

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

	fmt.Printf("n=%d\n", n)

	var found map[int]bool = make(map[int]bool)

	var ans int = 0
	for i := 0; i < 2 * n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		_, exist := found[x]

		fmt.Printf("x=%d, exist=%t\n", n, exist)

		if exist {
			fmt.Printf("delete\n")
			delete(found, x)
		} else {
			fmt.Printf("set true\n")
			found[x] = true
		}

		fmt.Printf("len(found)=%d, ans=%d\n", len(found), ans)
		if len(found) > ans {
			ans = len(found)
			fmt.Printf("update ans=%d\n", ans)
		}
	}

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

package main

import (
	"fmt"
)

func notWorking() {
	var n int
	fmt.Scanf("%d", &n)

	fmt.Printf("n=%d\n", n)

	var found map[int]bool = make(map[int]bool)

	var ans int = 0
	for i := 0; i < 2 * n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		_, exist := found[x]

		fmt.Printf("x=%d, exist=%t\n", n, exist)

		if exist {
			fmt.Printf("delete\n")
			delete(found, x)
		} else {
			fmt.Printf("set true\n")
			found[x] = true
		}

		for k, v := range found {
			fmt.Printf("key[%s] value[%s]\n", k, v)
		}

		fmt.Printf("len(found)=%d, ans=%d\n", len(found), ans)
		if len(found) > ans {
			ans = len(found)
			fmt.Printf("update ans=%d\n", ans)
		}
	}

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

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

	fmt.Printf("n=%d\n", n)

	var found []bool = make([]bool, n + 1)
	var ans int = 0
	var cur int = 0
	for i := 0; i < 2 * n; i++ {
		var x int
		fmt.Scanf("%d", &x)

		fmt.Printf("x=%d\n", x)
		for j := 0; j <= n; j++ {
			fmt.Printf("found[%d]=%t\n", j, found[j])
		}

		fmt.Printf(">>> found[%d]=%t\n", x, found[x])
		if found[x] {
			fmt.Printf(">>>1 pre >>> cur=%d\n", cur)
			cur--
			fmt.Printf(">>>1 aft >>> cur=%d\n", cur)
		} else {
			fmt.Printf(">>>2 pre >>> cur=%d\n", cur)
			cur++
			fmt.Printf(">>>2 aft >>> cur=%d\n", cur)
			found[x] = true
			fmt.Printf(">>>2 found[%d]=%t\n", x, found[x])
		}

		for j := 0; j <= n; j++ {
			fmt.Printf("found[%d]=%t\n", j, found[j])
		}

		fmt.Printf("cur=%d, ans=%d\n", cur, ans)

		if cur > ans {
			ans = cur
		}

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

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

package main

import (
	"fmt"
)

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

	fmt.Printf("n=%d\n", n)

	var found map[int]bool = make(map[int]bool)

	var ans int = 0
	for i := 0; i < 2 * n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		_, exist := found[x]

		fmt.Printf("x=%d, exist=%t\n", n, exist)

		if exist {
			fmt.Printf("delete\n")
			delete(found, x)
		} else {
			fmt.Printf("set true\n")
			found[x] = true
		}

		for k, v := range found {
			fmt.Printf("key[%s] value[%s]\n", k, v)
		}

		fmt.Printf("len(found)=%d, ans=%d\n", len(found), ans)
		if len(found) > ans {
			ans = len(found)
			fmt.Printf("update ans=%d\n", ans)
		}
	}

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

package main

import (
	"fmt"
)

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

	var found map[int]bool = make(map[int]bool)

	var ans int = 0
	for i := 0; i < 2 * n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		_, exist := found[x]

		if exist {
			delete(found, x)
		} else {
			found[x] = true
		}

		if len(found) > ans {
			ans = len(found)
		}
	}

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

package main

import (
	"fmt"
)

func notWorking() {
	var n int
	fmt.Scanf("%d", &n)

	fmt.Printf("n=%d\n", n)

	var found map[int]bool = make(map[int]bool)

	var ans int = 0
	for i := 0; i < 2 * n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		_, exist := found[x]

		fmt.Printf("x=%d, exist=%t\n", n, exist)

		if exist {
			fmt.Printf("delete\n")
			delete(found, x)
		} else {
			fmt.Printf("set true\n")
			found[x] = true
		}

		for k, v := range found {
			fmt.Printf("key[%s] value[%s]\n", k, v)
		}

		fmt.Printf("len(found)=%d, ans=%d\n", len(found), ans)
		if len(found) > ans {
			ans = len(found)
			fmt.Printf("update ans=%d\n", ans)
		}
	}

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

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

	fmt.Printf("n=%d\n", n)

	var found []bool = make([]bool, n + 1)
	var ans int = 0
	var cur int = 0
	for i := 0; i < 2 * n; i++ {
		var x int

		for {
			nread, err := fmt.Scanf("%d", &x)
			fmt.Printf("nread=%d, err=%v\n", nread, err)
			if err == nil {
				break
			}
		}

		fmt.Printf("x=%d\n", x)
		for j := 0; j <= n; j++ {
			fmt.Printf("found[%d]=%t\n", j, found[j])
		}

		fmt.Printf(">>> found[%d]=%t\n", x, found[x])
		if found[x] {
			fmt.Printf(">>>1 pre >>> cur=%d\n", cur)
			cur--
			fmt.Printf(">>>1 aft >>> cur=%d\n", cur)
		} else {
			fmt.Printf(">>>2 pre >>> cur=%d\n", cur)
			cur++
			fmt.Printf(">>>2 aft >>> cur=%d\n", cur)
			found[x] = true
			fmt.Printf(">>>2 found[%d]=%t\n", x, found[x])
		}

		for j := 0; j <= n; j++ {
			fmt.Printf("found[%d]=%t\n", j, found[j])
		}

		fmt.Printf("cur=%d, ans=%d\n", cur, ans)

		if cur > ans {
			ans = cur
		}

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

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

package main

import (
	"fmt"
)

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

	var found map[int]bool = make(map[int]bool)

	var ans int = 0
	for i := 0; i < 2 * n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		_, exist := found[x]

		if exist {
			delete(found, x)
		} else {
			found[x] = true
		}

		if len(found) > ans {
			ans = len(found)
		}
	}

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

package main

import (
	"fmt"
)

func notWorking() {
	var n int
	fmt.Scanf("%d", &n)

	fmt.Printf("n=%d\n", n)

	var found map[int]bool = make(map[int]bool)

	var ans int = 0
	for i := 0; i < 2 * n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		_, exist := found[x]

		fmt.Printf("x=%d, exist=%t\n", n, exist)

		if exist {
			fmt.Printf("delete\n")
			delete(found, x)
		} else {
			fmt.Printf("set true\n")
			found[x] = true
		}

		for k, v := range found {
			fmt.Printf("key[%s] value[%s]\n", k, v)
		}

		fmt.Printf("len(found)=%d, ans=%d\n", len(found), ans)
		if len(found) > ans {
			ans = len(found)
			fmt.Printf("update ans=%d\n", ans)
		}
	}

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

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

	fmt.Printf("n=%d\n", n)

	var found []bool = make([]bool, n + 1)
	var ans int = 0
	var cur int = 0
	for i := 0; i < 2 * n; i++ {
		var x int
		nread, err := fmt.Scanf("%d", &x)
		fmt.Printf("nread=%d, err=%v\n", nread, err)

		fmt.Printf("x=%d\n", x)
		for j := 0; j <= n; j++ {
			fmt.Printf("found[%d]=%t\n", j, found[j])
		}

		fmt.Printf(">>> found[%d]=%t\n", x, found[x])
		if found[x] {
			fmt.Printf(">>>1 pre >>> cur=%d\n", cur)
			cur--
			fmt.Printf(">>>1 aft >>> cur=%d\n", cur)
		} else {
			fmt.Printf(">>>2 pre >>> cur=%d\n", cur)
			cur++
			fmt.Printf(">>>2 aft >>> cur=%d\n", cur)
			found[x] = true
			fmt.Printf(">>>2 found[%d]=%t\n", x, found[x])
		}

		for j := 0; j <= n; j++ {
			fmt.Printf("found[%d]=%t\n", j, found[j])
		}

		fmt.Printf("cur=%d, ans=%d\n", cur, ans)

		if cur > ans {
			ans = cur
		}

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

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

package main

import (
	"fmt"
)

func notWorking() {
	var n int
	fmt.Scanf("%d", &n)

	fmt.Printf("n=%d\n", n)

	var found map[int]bool = make(map[int]bool)

	var ans int = 0
	for i := 0; i < 2 * n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		_, exist := found[x]

		fmt.Printf("x=%d, exist=%t\n", n, exist)

		if exist {
			fmt.Printf("delete\n")
			delete(found, x)
		} else {
			fmt.Printf("set true\n")
			found[x] = true
		}

		for k, v := range found {
			fmt.Printf("key[%s] value[%s]\n", k, v)
		}

		fmt.Printf("len(found)=%d, ans=%d\n", len(found), ans)
		if len(found) > ans {
			ans = len(found)
			fmt.Printf("update ans=%d\n", ans)
		}
	}

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

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

	var found []bool = make([]bool, n + 1)
	var ans int = 0
	var cur int = 0
	for i := 0; i < 2 * n; i++ {
		var x int
		fmt.Scanf("%d", &x)

		if found[x] {
			cur--
		} else {
			cur++
			found[x] = true
		}

		if cur > ans {
			ans = cur
		}
	}

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

package main

import (
	"fmt"
)

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

	fmt.Printf("n=%d\n", n)

	var found map[int]bool = make(map[int]bool)

	var ans int = 0
	for i := 0; i < 2 * n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		_, exist := found[x]

		fmt.Printf("x=%d, exist=%t\n", n, exist)

		if exist {
			fmt.Printf("delete\n")
			delete(found, x)
		} else {
			fmt.Printf("set true\n")
			found[x] = true
		}

		for k, v := range found {
			fmt.Printf("key[%s] value[%s]\n", k, v)
		}

		fmt.Printf("len(found)=%d, ans=%d\n", len(found), ans)
		if len(found) > ans {
			ans = len(found)
			fmt.Printf("update ans=%d\n", ans)
		}
	}

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

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

	fmt.Printf("n=%d\n", n)

	var found []bool = make([]bool, n + 1)
	var ans int = 0
	var cur int = 0
	for i := 0; i < 2 * n; i++ {
		var x int
		nread, err := fmt.Scanf("%d", &x)
		fmt.Printf("nread=%d, err=%v\n", nread, err)

		fmt.Printf("x=%d\n", x)
		for j := 0; j <= n; j++ {
			fmt.Printf("found[%d]=%t\n", j, found[j])
		}

		fmt.Printf(">>> found[%d]=%t\n", x, found[x])
		if found[x] {
			fmt.Printf(">>>1 pre >>> cur=%d\n", cur)
			cur--
			fmt.Printf(">>>1 aft >>> cur=%d\n", cur)
		} else {
			fmt.Printf(">>>2 pre >>> cur=%d\n", cur)
			cur++
			fmt.Printf(">>>2 aft >>> cur=%d\n", cur)
			found[x] = true
			fmt.Printf(">>>2 found[%d]=%t\n", x, found[x])
		}

		for j := 0; j <= n; j++ {
			fmt.Printf("found[%d]=%t\n", j, found[j])
		}

		fmt.Printf("cur=%d, ans=%d\n", cur, ans)

		if cur > ans {
			ans = cur
		}

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

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

package main

import (
	"fmt"
)

func notWorking() {
	var n int
	fmt.Scanf("%d", &n)

	fmt.Printf("n=%d\n", n)

	var found map[int]bool = make(map[int]bool)

	var ans int = 0
	for i := 0; i < 2 * n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		_, exist := found[x]

		fmt.Printf("x=%d, exist=%t\n", n, exist)

		if exist {
			fmt.Printf("delete\n")
			delete(found, x)
		} else {
			fmt.Printf("set true\n")
			found[x] = true
		}

		for k, v := range found {
			fmt.Printf("key[%s] value[%s]\n", k, v)
		}

		fmt.Printf("len(found)=%d, ans=%d\n", len(found), ans)
		if len(found) > ans {
			ans = len(found)
			fmt.Printf("update ans=%d\n", ans)
		}
	}

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

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

	fmt.Printf("n=%d\n", n)

	var found []bool = make([]bool, n + 1)
	var ans int = 0
	var cur int = 0
	for i := 0; i < 2 * n; i++ {
		var x int
		fmt.Scanf("%d", x)

		fmt.Printf("x=%d\n", x)
		for j := 0; j <= n; j++ {
			fmt.Printf("found[%d]=%t\n", j, found[j])
		}

		fmt.Printf(">>> found[%d]=%t\n", x, found[x])
		if found[x] {
			fmt.Printf(">>>1 pre >>> cur=%d\n", cur)
			cur--
			fmt.Printf(">>>1 aft >>> cur=%d\n", cur)
		} else {
			fmt.Printf(">>>2 pre >>> cur=%d\n", cur)
			cur++
			fmt.Printf(">>>2 aft >>> cur=%d\n", cur)
			found[x] = true
			fmt.Printf(">>>2 found[%d]=%t\n", x, found[x])
		}

		for j := 0; j <= n; j++ {
			fmt.Printf("found[%d]=%t\n", j, found[j])
		}

		fmt.Printf("cur=%d, ans=%d\n", cur, ans)

		if cur > ans {
			ans = cur
		}

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

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

package main

import (
	"fmt"
)

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

	fmt.Printf("n=%d\n", n)

	var found map[int]bool = make(map[int]bool)

	var ans int = 0
	var x int
	for i := 0; i < 2 * n; i++ {
		fmt.Scanf("%d", &x)
		_, exist := found[x]

		fmt.Printf("x=%d, exist=%t\n", n, exist)

		if exist {
			fmt.Printf("delete\n")
			delete(found, x)
		} else {
			fmt.Printf("set true\n")
			found[x] = true
		}

		fmt.Printf("len(found)=%d, ans=%d\n", len(found), ans)
		if len(found) > ans {
			ans = len(found)
			fmt.Printf("update ans=%d\n", ans)
		}
	}

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

package main

import (
	"fmt"
)

func notWorking() {
	var n int
	fmt.Scanf("%d", &n)

	fmt.Printf("n=%d\n", n)

	var found map[int]bool = make(map[int]bool)

	var ans int = 0
	for i := 0; i < 2 * n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		_, exist := found[x]

		fmt.Printf("x=%d, exist=%t\n", n, exist)

		if exist {
			fmt.Printf("delete\n")
			delete(found, x)
		} else {
			fmt.Printf("set true\n")
			found[x] = true
		}

		for k, v := range found {
			fmt.Printf("key[%s] value[%s]\n", k, v)
		}

		fmt.Printf("len(found)=%d, ans=%d\n", len(found), ans)
		if len(found) > ans {
			ans = len(found)
			fmt.Printf("update ans=%d\n", ans)
		}
	}

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

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

	fmt.Printf("n=%d\n", n)

	var found []bool = make([]bool, n + 1)
	var ans int = 0
	var cur int = 0
	for i := 0; i < 2 * n; i++ {
		var x int
		fmt.Scanf("%d", &x)

		fmt.Printf("x=%d\n", x)
		for j := 0; j <= n; j++ {
			fmt.Printf("found[%d]=%t\n", j, found[j])
		}

		if found[x] {
			cur--
		} else {
			cur++
			found[x] = true
		}

		for j := 0; j <= n; j++ {
			fmt.Printf("found[%d]=%t\n", j, found[j])
		}

		fmt.Printf("cur=%d, ans=%d\n", cur, ans)

		if cur > ans {
			ans = cur
		}

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

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


package main

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

//problem D1

type problem struct {
	nums []int
	data map[int]bool
}

func (p *problem) maximum() int {
	n := len(p.nums)
	p.data = make(map[int]bool, n*n)

	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			sub := p.nums[i] - p.nums[j]
			if sub == 0 {
				continue
			}
			if sub < 0 {
				sub = 0 - sub
			}
			if _, ok := p.data[sub]; !ok {
				p.data[sub] = true
			}
		}
	}

	if len(p.data) == 0 {
		return -1
	}

	subs := make([]int, 0, len(p.data))
	for sub := range p.data {
		subs = append(subs, sub)
	}

	gcd := subs[0]

	for i := 1; gcd != 1 && i < len(subs); i++ {
		gcd = GCD(gcd, subs[i])
	}

	return gcd
}

func GCD(x, y int) int {
	if x > y {
		x, y = y, x
	}

	for x != 0 {
		x, y = y%x, x
	}
	return y
}
func main() {
	reader := bufio.NewReader(os.Stdin)
	var t, n int
	var p problem

	fmt.Fscanf(reader, "%d\n", &t)
	for ; t > 0; t-- {
		fmt.Fscanf(reader, "%d\n", &n)
		p.nums = make([]int, n)

		for i := 0; i < n; i++ {
			if i < n-1 {
				fmt.Fscanf(reader, "%d ", &p.nums[i])
			} else {
				fmt.Fscanf(reader, "%d\n", &p.nums[i])
			}
		}

		fmt.Printf("%d\n", p.maximum())
	}
}

package main

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

func main() {
	//输入输出部分
	cnt := 0
	fmt.Fscan(os.Stdin, &cnt)
	arr := make([][]int, cnt)
	ans := []int{}
	for i := 0; i < cnt; i++ {
		n := 0
		fmt.Fscan(os.Stdin, &n)
		arr[i] = make([]int, n)
		for j := 0; j < n; j++ {
			tmp := 0
			fmt.Fscan(os.Stdin, &tmp)
			arr[i][j] = tmp
		}
	}

	//算法部分
	for _, sl := range arr {
		//如果4个数相等则return -1
		//以最小的数为基准然后求所有和最小数差的最大公约数
		tmp := []int{}
		sort.Ints(sl)
		min := sl[0]
		for _, v := range sl {
			if min != v {
				tmp = append(tmp, v-min)
			}
		}
		if len(tmp) == 0 {
			ans = append(ans, -1)
			continue
		}
		for res := tmp[0]; res >= 1; res-- {
			flag := true
			for _, v := range tmp {
				if v % res != 0 {
					flag = false
				}
			}
			if flag {
				ans = append(ans, res)
				break
			}
		}
	}
	for _, v := range ans {
		fmt.Println(v)
	}
}

package main

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

func gcd(x int, y int) int {
  if x < 0 {
    x = -x
  }
  if y < 0 {
    y = -y
  }
  if x < y {
    return gcd(y, x)
  }
  if y == 0 {
    return x
  }
  return gcd(y, x%y)
}

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

  var t int
  fmt.Fscan(reader, &t)
  for ; t > 0; t-- {
    var n int
    fmt.Fscan(reader, &n)
    arr := make([]int, n)
    for i := 0; i < n; i++ {
      fmt.Fscan(reader, &arr[i])
    }
    ans := 0
    for i := 0; i < n-1; i++ {
      ans = gcd(ans, arr[i+1]-arr[i])
    }
    if ans == 0 {
      ans = -1
    }
    fmt.Fprint(writer, ans, "\n")
  }
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var t, n, h int

	_, _ = fmt.Fscan(r, &t)

	for ; t > 0; t-- {
		_, _ = fmt.Fscan(r, &n)
		var a []int

		result := -1
		for i := 0; i < n; i++ {
			_, _ = fmt.Fscan(r, &h)
			a = append(a, h)
			if i > 0 && a[i] != a[0] {
				result = 0
			}
		}

		if result == -1 {
			fmt.Println(result)
			continue
		}

		Loop: for i := 2000000; i >= 1; i-- {
			mi:= a[0] % i
			if mi < 0 {
				mi += i
			}

			for j := 1; j < n; j++ {
				mj := a[j] % i
				if mj < 0 {
					mj += i
				}

				if mj != mi {
					continue Loop
				}
			}

			fmt.Println(i)
			break
		}
	}
}

package main

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

var (
	rr = bufio.NewReader(os.Stdin)
	ww = bufio.NewWriter(os.Stdout)

	T int

	n int
	a []int
)

func unique(a []int) {
	b := a[:1]
	for _, i := range a {
		if i != b[len(b)-1] {
			b = append(b, i)
		}
	}
}

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

func main() {
	fmt.Fscan(rr, &T)
	for ; T > 0; T-- {
		fmt.Fscan(rr, &n)
		a = make([]int, n)
		for i := range a {
			fmt.Fscan(rr, &a[i])
		}
		sort.Ints(a)
		if a[0] == a[len(a)-1] {
			fmt.Fprintln(ww, -1)
			continue
		}
		unique(a)
		g := a[1] - a[0]

		for i := 2; i < len(a); i++ {
			g = gcd(g, a[i] - a[i - 1])
		}
		fmt.Fprintln(ww, g)
	}
	_ = ww.Flush()
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1593D1(in io.Reader, out io.Writer) {
	var T, n, v0, v int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &v0)
		g := 0
		for ; n > 1; n-- {
			Fscan(in, &v)
			g = gcd(g, abs(v-v0))
		}
		if g == 0 {
			g = -1
		}
		Fprintln(out, g)
	}
}

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

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

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

package main

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

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

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

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

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

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

		sort.Ints(arr)
		k := arr[n-1] - arr[0]
		if k == 0 {
			fmt.Fprintln(out, -1)
		} else {
			for i := n - 2; i >= 1; i-- {
				if arr[i] == arr[0] || k == 1 {
					break
				}

				k = gcd(arr[i]-arr[0], k)
			}

			fmt.Fprintln(out, k)
		}
	}
}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

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

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

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

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

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

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

func Union(a, b []int) []int {
	m := make(map[int]bool)

	for _, item := range a {
		m[item] = true
	}

	for _, item := range b {
		if _, ok := m[item]; !ok {
			a = append(a, item)
		}
	}
	return a
}

var t int

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

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

		ARR := make([]int, n)

		for i := 0; i < n; i++ {
			fmt.Fscan(input, &ARR[i])
		}

		sort.Ints(ARR)
		Dif := make([]int, 0)
		Dif = append(Dif, ARR[0])

		for i := 1; i < n; i++ {
			if ARR[i] != ARR[i-1] {
				Dif = append(Dif, ARR[i])
			}
		}

		if len(Dif) == 1 {
			fmt.Println(-1)
		} else {
			q := len(Dif)
			begin := int64(Dif[1] - Dif[0])
			for i := 2; i < q; i++ {
				sec := Dif[i] - Dif[i-1]
				begin = GCD(int64(begin), int64(sec))
			}
			fmt.Println(begin)
		}

	}

}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	// writer  = bufio.NewWriter(os.Stdout)
	t, n int
	x    []int
)

func lcd(x, y int) int {
	if x%y == 0 {
		return y
	}
	return lcd(y, x%y)
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		x = make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &x[i])
		}
		sort.Ints(x)
		if x[0] == x[n-1] {
			fmt.Println(-1)
			continue
		}
		var y []int
		for i := 1; i < n; i++ {
			if x[i] > x[0] {
				y = append(y, x[i]-x[0])
			}
		}
		k := y[0]
		for i := 1; i < len(y); i++ {
			k = lcd(k, y[i])
		}
		fmt.Println(k)
	}
}

package main

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

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

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

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

	var T int
	fmt.Fscanf(r, "%d\n", &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscanf(r, "%d\n", &n)
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscanf(r, "%d", &arr[i])
		}
		fmt.Fscanf(r, "\n")

		diff := false
		for i := 0; i < n; i++ {
			if arr[i] != arr[0] {
				diff = true
			}
		}

		if !diff {
			fmt.Println(-1)
			continue
		}

		x := 0
		for i := 0; i < len(arr); i++ {
			res := 0
			for j := 0; j < len(arr); j++ {
				d := abs(arr[i] - arr[j])
				res = gcd(d, res)
			}
			if res > x {
				x = res
			}
		}

		fmt.Println(x)
	}
}

package main

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

var N int

var a []int

func main() {

	r := bufio.NewReader(os.Stdin)

	var t int

	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		fmt.Fscan(r, &N)

		a = make([]int, N)

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

		ans := solve()

		fmt.Println(ans)
	}
}

func solve() int64 {
	var diff []int

	for  i := 1; i < N; i++ {
		d := abs(a[i] - a[i - 1])

		diff = append(diff, d)
	}

	allZero := true
	for i := 0; i < len(diff); i++ {
		if diff[i] == 0 {
			continue
		}
		allZero = false
		break
	}

	if allZero {
		return -1
	}

	cur := GCD(diff[1], diff[0])

	for j := 2; j < len(diff); j++ {
		cur = GCD(cur, diff[j])
	}

	return int64(cur)
}

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

func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

package main

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

//problem D1

type problem struct {
	nums []int
	data map[int]bool
}

func (p *problem) maximum() int {
	n := len(p.nums)
	p.data = make(map[int]bool, n*n)

	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			sub := p.nums[i] - p.nums[j]
			if sub == 0 {
				continue
			}
			if sub < 0 {
				sub = 0 - sub
			}
			if _, ok := p.data[sub]; !ok {
				p.data[sub] = true
			}
		}
	}

	if len(p.data) == 0 {
		return -1
	}

	subs := make([]int, 0, len(p.data))
	for sub := range p.data {
		subs = append(subs, sub)
	}

	gcd := subs[0]

	for i := 1; i < len(subs); i++ {
		gcd = GCD(gcd, subs[i])
	}

	return gcd
}

func GCD(x, y int) int {
	if x > y {
		x, y = y, x
	}

	for x != 0 {
		x, y = x%y, x
	}
	return y
}
func main() {
	reader := bufio.NewReader(os.Stdin)
	var t, n int
	var p problem

	fmt.Fscanf(reader, "%d\n", &t)
	for ; t > 0; t-- {
		fmt.Fscanf(reader, "%d\n", &n)
		p.nums = make([]int, n)

		for i := 0; i < n; i++ {
			if i < n-1 {
				fmt.Fscanf(reader, "%d ", &p.nums[i])
			} else {
				fmt.Fscanf(reader, "%d\n", &p.nums[i])
			}
		}

		fmt.Printf("%d\n", p.maximum())
	}
}

package main

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

//problem D

type problem struct {
	nums []int
	data map[int]bool
}

func (p *problem) maximum() int {
	n := len(p.nums)
	p.data = make(map[int]bool, n*n)

	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			sub := p.nums[i] - p.nums[j]
			if sub == 0 {
				continue
			}
			if sub < 0 {
				sub = 0 - sub
			}
			if _, ok := p.data[sub]; !ok {
				p.data[sub] = true
			}
		}
	}

	if len(p.data) == 0 {
		return -1
	}

	subs := make([]int, 0, len(p.data))
	for sub := range p.data {
		subs = append(subs, sub)
	}

	gcd := subs[0]

	for i := 1; i < len(subs); i++ {
		gcd = GCD(gcd, subs[i])
	}

	return gcd
}

func GCD(x, y int) int {
	if x > y {
		x, y = y, x
	}

	for x != 0 {
		x, y = x%y, x
	}
	return y
}
func main() {
	reader := bufio.NewReader(os.Stdin)
	var t, n int
	var p problem

	fmt.Fscanf(reader, "%d\n", &t)
	for ; t > 0; t-- {
		fmt.Fscanf(reader, "%d\n", &n)
		p.nums = make([]int, n)

		for i := 0; i < n; i++ {
			if i < n {
				fmt.Fscanf(reader, "%d ", &p.nums[i])
			} else {
				fmt.Fscanf(reader, "%d\n", &p.nums[i])
			}
		}

		fmt.Printf("%d\n", p.maximum())
	}
}

package main

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

//problem D1

type problem struct {
	nums []int
	data map[int]bool
}

func (p *problem) maximum() int {
	n := len(p.nums)
	p.data = make(map[int]bool, n*n)

	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			sub := p.nums[i] - p.nums[j]
			if sub == 0 {
				continue
			}
			if sub < 0 {
				sub = 0 - sub
			}
			if _, ok := p.data[sub]; !ok {
				p.data[sub] = true
			}
		}
	}

	if len(p.data) == 0 {
		return -1
	}

	subs := make([]int, 0, len(p.data))
	for sub := range p.data {
		subs = append(subs, sub)
	}

	gcd := subs[0]

	for i := 1; i < len(subs); i++ {
		gcd = GCD(gcd, subs[i])
	}

	return gcd
}

func GCD(x, y int) int {
	if x > y {
		x, y = y, x
	}

	for x != 0 {
		x, y = x%y, x
	}
	return y
}
func main() {
	reader := bufio.NewReader(os.Stdin)
	var t, n int
	var p problem

	fmt.Fscanf(reader, "%d\n", &t)
	for ; t > 0; t-- {
		fmt.Fscanf(reader, "%d\n", &n)
		p.nums = make([]int, n)

		for i := 0; i < n; i++ {
			if i < n {
				fmt.Fscanf(reader, "%d ", &p.nums[i])
			} else {
				fmt.Fscanf(reader, "%d\n", &p.nums[i])
			}
		}

		fmt.Printf("%d\n", p.maximum())
	}
}

package main

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

func main() {
	//输入输出部分
	cnt := 0
	fmt.Fscan(os.Stdin, &cnt)
	arr := make([][]int, cnt)
	for i := 0; i < cnt; i++ {
		n := 0
		fmt.Fscan(os.Stdin, &n)
		arr[i] = make([]int, n)
		for j := 0; j < n; j++ {
			tmp := 0
			fmt.Fscan(os.Stdin, &tmp)
			arr[i][j] = tmp
		}
	}
	//算法部分
	for _, sl := range arr {
		//如果4个数相等则return -1
		//以最小的数为基准然后求所有和最小数差的最大公约数
		tmp := []int{}
		sort.Ints(sl)
		min := sl[0]
		for _, v := range sl {
			tmp = append(tmp, v-min)
		}
		if tmp[len(tmp)-1] == 0 {
			fmt.Println(-1)
		} else {
			for res := tmp[0]; res >= 1; res-- {
				flag := true
				for _, v := range tmp {
					if v % res != 0 {
						flag = false
					}
				}
				if flag {
					fmt.Println(res)
					break
				}
			}
		}
	}
}

package main

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

func gcd(x int, y int) int {
  if x < 0 {
    x = -x
  }
  if y < 0 {
    y = -y
  }
  if x < y {
    return gcd(y, x)
  }
  if y == 0 {
    return x
  }
  return gcd(y, x%y)
}

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

  var t int
  fmt.Fscan(reader, &t)
  for ; t > 0; t-- {
    var n int
    fmt.Fscan(reader, &n)
    arr := make([]int, n)
    for i := 0; i < n; i++ {
      fmt.Fscan(reader, &arr[i])
    }
    ans := 0
    for i := 0; i < n-1; i++ {
      ans = gcd(ans, arr[i+1]-arr[i])
    }
    fmt.Fprint(writer, ans, "\n")
  }
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var t, n, h int

	_, _ = fmt.Fscan(r, &t)

	for ; t > 0; t-- {
		_, _ = fmt.Fscan(r, &n)
		var a []int

		result := -1
		for i := 0; i < n; i++ {
			_, _ = fmt.Fscan(r, &h)
			a = append(a, h)
			if i > 0 && a[i] != a[0] {
				result = 0
			}
		}

		if result == -1 {
			fmt.Println(result)
			continue
		}

		Loop: for i := 1000000; i >= 1; i-- {
			mi:= a[0] % i
			if mi < 0 {
				mi += i
			}

			for j := 1; j < n; j++ {
				mj := a[j] % i
				if mj < 0 {
					mj += i
				}

				if mj != mi {
					continue Loop
				}
			}

			fmt.Println(i)
			break
		}
	}
}

package main

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

const Inf = 1000

var (
	rr = bufio.NewReader(os.Stdin)
	ww = bufio.NewWriter(os.Stdout)

	T int

	n int
	a []int
)

func main() {
	fmt.Fscan(rr, &T)
	for ; T > 0; T-- {
		fmt.Fscan(rr, &n)
		a = make([]int, n)
		for i := range a {
			fmt.Fscan(rr, &a[i])
		}
		min, max := a[0], a[0]
		for _, i := range a {
			if min > i {
				min = i
			}
			if max < i {
				max = i
			}
		}
		min = max - min + 1
		ans := 1
		for i := 2; i <= min; i++ {
			mod := ((a[0] % i) + i) % i
			flag := true
			for _, j := range a {
				if ((j % i) + i) % i != mod {
					flag = false
					break
				}
			}
			if flag {
				ans = i
			}
		}
		fmt.Fprintln(ww, ans)
	}
	_ = ww.Flush()
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1593D1(in io.Reader, out io.Writer) {
	var T, n, v0, v int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &v0)
		g := 0
		for ; n > 1; n-- {
			Fscan(in, &v)
			g = gcd(g, abs(v-v0))
		}
		Fprintln(out, g)
	}
}

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

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

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


//Codeforces Round #633 (Div. 2)
//https://codeforces.com/contest/1339/problem/C

package main

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

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

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

var db bool = true
// var db bool = false

//const maxn int = 1e5

func main() {
	defer writer.Flush()

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

	for tc := 1; tc <= t; tc++ {
		scanf("%d\n", &n)
		m := make(map[int]int)
		mxc := 0
		for i := 0; i < n; i++ {
		    var v int
		    scanf("%d", &v)
		    if i != n-1 {
		        scanf(" ")
		    } else {
		        scanf("\n")
		    }

		    m[v] += 1
		    if m[v] > mxc {
		        mxc = m[v]
		    }
	    }
	    if n == 1 {
		    printf("0\n")
		    continue
		}

	    ta  := len(m)
	    tb  := mxc
	    ans := ta
	    if tb < ans {
	        ans = tb
	    }
	    if ta == tb {
	        ans--
	    }
	    printf("%v\n", ans)
	}
}

package main

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

var r__ *bufio.Reader = bufio.NewReader(os.Stdin)
var w__ *bufio.Writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{})  { fmt.Fscanf(r__, f, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(w__, f, a...) }
func fflush()                           { w__.Flush() }

func findKey(m map[int]int, val int) []int {
	res := make([]int, 0)
	for k, v := range m {
		if v == val {
			res = append(res, k)
		}
	}
	return res
}

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

func uniquesWithoutXN(m map[int]int, key int, times int) int {
	uniqCounter := 0

	for k, v := range m {
		if k == key {
			if (v - times) > 0 {
				uniqCounter++
			}
		} else {
			uniqCounter++
		}
	}
	return uniqCounter
}

func solve() {
	var n int
	scanf("%d\n", &n)
	data := make([]int, n)
	counts := make(map[int]int)
	var totalUniques int
	for i := 0; i < n; i++ {
		var tmp int
		scanf("%d", &tmp)
		data[i] = tmp

		if _, ok := counts[tmp]; ok {
			counts[tmp] = counts[tmp] + 1
		} else {
			counts[tmp] = 1
			totalUniques++
		}
	}
	scanf("\n")
	//fmt.Println("data loaded: ", data)
	//fmt.Println(counts)

	countsRvals := make([]int, 0)
	uniquenessCheck := make(map[int]bool)

	for _, v := range counts {
		if _, ok := uniquenessCheck[v]; !ok {

			countsRvals = append(countsRvals, v)
			uniquenessCheck[v] = true
		}

	}
	//fmt.Println(countsRvals)

	sort.Ints(countsRvals)

	//fmt.Println("total uniques:", totalUniques)

	maxi := 0
	for k, c := range counts {
		if c > maxi {
			for i := 0; i < (c - maxi); i++ {
				c2 := c - i
				//fmt.Println("DEBUG:", c2, uniquesWithoutXN(counts, k, c2))
				//fmt.Println("DEBUG2:", uniquesWithoutXN(counts, 1, 2))
				res := minOfTwo(c2, uniquesWithoutXN(counts, k, c2))
				if res > maxi {
					maxi = res
				}

			}

		}
	}
	printf("%d\n", maxi)
}

func main() {
	defer fflush()

	var T, i uint64
	scanf("%d\n", &T)
	for i = 0; i < T; i++ {
		solve()
	}

}

package main

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

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

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

	arr := make([]int, len(strArr))
	for i, strA := range strArr {
		arr[i], err = strconv.Atoi(strA)
		if err != nil {
			return nil, err
		}
	}

	return arr, nil
}

func main() {
	defer writer.Flush()

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

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

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

	arrA, err := scanIntArr()
	if err != nil {
		fmt.Println(err.Error())
		panic(err)
	}

	diffs := 0
	maxI := 0
	mp := map[int]int{}
	for _, a := range arrA {
		if _, ok := mp[a]; !ok {
			diffs++
		}
		mp[a]++
		if a != maxI && mp[a] > mp[maxI] {
			maxI = a
		}
	}

	var result int
	switch {
	case diffs-mp[maxI] > 0:
		result = mp[maxI]
	case diffs-mp[maxI] == 0:
		result = diffs - 1
	case diffs-mp[maxI] < 0:
		result = diffs
	}

	printf("%d\n", result)
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var T int
	fmt.Fscanf(in, "%d\n", &T)

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

		mp := make(map[int]int)
		var val, mval int
		mval = 0

		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d ", &val)
			mp[val]++
			mval = max(mval, mp[val])
		}
		fmt.Fscanf(in, "%d\n", &val)

		fmt.Println(max(min(len(mp)- 1, mval), min(len(mp), mval - 1)))
	}

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

package main

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

func main() {

	in, err := os.Open("input.txt")
	if err == nil {
		os.Stdin = in
	}

	bytes, _ = ioutil.ReadAll(bufio.NewReader(os.Stdin))
	maxV = len(bytes) - 1

	t := fastScan()

	for ; t > 0; t-- {
		n := fastScan()
		mp := make(map[int]int)
		var val, mval int
		mval = 0

		for i := 0; i < n; i++ {
			val = fastScan()
			mp[val]++
			mval = max(mval, mp[val])
		}
		fmt.Println(max(min(len(mp)-1, mval), min(len(mp), mval-1)))

	}
}

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
}

var bytes []byte
var l, maxV int

func fastScan() int {
	b := bytes[l]

	for b < 48 || b > 57 {
		l++
		b = bytes[l]
	}

	result := 0
	for 47 < b && b < 58 {
		result = (result << 3) + (result << 1) + int(b-48)

		l++
		if l > maxV {
			return result
		}
		b = bytes[l]
	}
	return result
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var T int
	fmt.Fscanf(in, "%d\n", &T)

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

		mp := make(map[int]int)
		var val, mval int
		mval = 0

		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d ", &val)
			mp[val]++
			mval = max(mval, mp[val])
		}
		fmt.Fscanf(in, "%d ", &val)

		fmt.Println(max(min(len(mp)- 1, mval), min(len(mp), mval - 1)))
	}

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

package main

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

func solve(n int, m map[int]int) int {
	max := 0

	for _, v := range m {
		if v > max {
			max = v
		}
	}

	if len(m) == max {
		return max - 1
	}

	return findMin(len(m), max)
}

func findMin(n1 int, n2 int) int {
	if n1 < n2 {
		return n1
	}

	return n2
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var t, n, a int
	fmt.Fscanf(r, "%d\n", &t)

	for tc := 0; tc < t; tc++ {
		fmt.Fscanf(r, "%d\n", &n)
		m := map[int]int{}

		for i := 0; i < n; i++ {
			fmt.Fscanf(r, "%d", &a)
			m[a]++
		}
		fmt.Fscanln(r)
		fmt.Fprintf(os.Stdout, "%d\n", solve(n, m))
	}
}

// https://serhatgiydiren.github.io

package main

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

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

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

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

func solve(test_id int) {
 defer writer.Flush()
 var n,q int
 fmt.Fscanf(reader, "%d\n", &n)
 m := make(map[int]int)
 for i := 0 ; i < n ; i++ {
  fmt.Fscanf(reader, "%d", &q)
  m[q]++
 }
 c := 0
 for _,v := range(m) {
  c = max(c , v)
 }
 res := min(c , min(len(m) , n / 2))
 if res == c && res == len(m) {
  res--
 }
 fmt.Fscanf(reader, "\n")
 fmt.Fprintf(writer, "%d\n", res)
}

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

func main() {
 solve_cases()
}

// https://serhatgiydiren.github.io

package main

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

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

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

func solve(test_id int) {
 defer writer.Flush()
 var n,q int
 fmt.Fscanf(reader, "%d\n", &n)
 m := make(map[int]int)
 for i := 0 ; i < n ; i++ {
  fmt.Fscanf(reader, "%d", &q)
  m[q]++
 }
 c := 0
 for _,v := range(m) {
  if v > c {
   c = v
  }
 }
 res := min(c , min(len(m) , n / 2))
 if res == c && res == len(m) {
  res--
 }
 fmt.Fscanf(reader, "\n")
 fmt.Fprintf(writer, "%d\n", res)
}

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

func main() {
 solve_cases()
}

package main

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

func main() {
	var truncator string
	if runtime.GOOS == "windows" {
		truncator = "\r\n"
	} else {
		truncator = "\n"
	}

	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text = strings.TrimSuffix(text, truncator)
	testcase, _ := strconv.ParseInt(text, 10, 64)

	var i int64
	numSlice := make([]int64, testcase)
	stdSlice := make([][]int64, testcase)
	calSlice := make([][]int64, testcase)
	resSlice := make([]string, testcase)
	for i = 0; i < testcase; i++ {
		text, _ = reader.ReadString('\n')
		text = strings.TrimSuffix(text, truncator)
		numSlice[i], _ = strconv.ParseInt(text, 10, 64)
		stdSlice[i] = readInt(numSlice[i], reader)
		calSlice[i] = make([]int64, numSlice[i])
		for _, v := range stdSlice[i] {
			calSlice[i][v-1]++
		}
		rep := isMax(calSlice[i])
		nzr := countNzero(calSlice[i])
		resSlice[i] = fmt.Sprintf("%d", max(min(rep, nzr-1), min(rep-1, nzr)))
	}

	result := strings.Join(resSlice, "\n")
	fmt.Printf("%s\n", result)
}

func isMax(a []int64) int64 {
	if len(a) == 1 {
		return a[0]
	}
	result := a[0]
	for _, v := range a {
		if result < v {
			result = v
		}
	}
	return result
}

func countNzero(a []int64) int64 {
	var result int64 = 0
	for _, v := range a {
		if v != 0 {
			result++
		}
	}
	return result
}

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

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

func readInt(size int64, reader *bufio.Reader) []int64 {
	text, _ := reader.ReadString('\n')
	split := strings.Fields(text)
	result := make([]int64, len(split))
	var i int64
	for i = 0; i < size; i++ {
		result[i], _ = strconv.ParseInt(split[i], 10, 64)
	}
	return result
}

package main

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

/*
4
7
4 2 4 1 4 3 4
5
2 1 5 4 3
1
1
4
1 1 1 3
*/

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

	var T int64
	var R int64
	for Fscan(in, &T); T > 0; T-- {

		target := make(map[int]int)
		for Fscan(in, &R); R > 0; R-- {
			var data int
			Fscan(in, &data)
			target[data] ++
		}

		if len(target) == 0 {
			Fprintln(out, 0)
			continue
		}

		var sumTwo int
		for _, v := range target {
			if v != 1 {
				if sumTwo < v {
					sumTwo = v
				}
			}
		}

		Fprintln(out, TTCMin(len(target), sumTwo))

	}
}

func TTCMin(len, two int) int {
	if len == 1 {
		if two == 0 {
			return 0
		}
		return 1
	}else {
		if two == 0 {
			return 1
		}
	}

	if two-len+1 > 1 {
		return len
	}

	if two-len+1 > 0 {
		return len - 1
	}

	return two
}

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

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

package main

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

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

func Solve(n int, a []int) int {
	count := make(map[int]int)
	for _, elem := range a {
		count[elem] += 1
	}
	maxCount := 0
	for _, v := range count {
		if v > maxCount {
			maxCount = v
		}
	}
	distinct := len(count) - 1
	if distinct+1 < maxCount {
		return distinct+1
	}
	return min(distinct, maxCount)
}

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

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

package main

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

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

type writerImpl struct {
	*bufio.Writer
}

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

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

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

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

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

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

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

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

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n := reader.NextInt64()
		am := map[int64]int64{}
		maxSoFar := int64(0)
		for i := int64(0); i < n; i++ {
			a := reader.NextInt64()
			am[a]++
			maxSoFar = max(maxSoFar, am[a])
		}
        if int64(len(am)) == maxSoFar {
            writer.Printf("%d\n", min(n/2, maxSoFar-1))
        } else {
            writer.Printf("%d\n", min(n/2, int64(len(am)), maxSoFar))
        }
	}
}

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

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		var n, a int
		fmt.Fscan(in, &n)
		d := make(map[int]int, n)
		max := 0
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a)
			d[a] += 1
			if max == 0 {
				max = a
			}
			if d[a] > d[max] {
				max = a
			}
		}
		first := len(d) - 1
		if first < d[max] {
			first += 1
			d[max] -= 1
		}
		if first < d[max] {
			fmt.Fprintln(out, first)
		} else {
			fmt.Fprintln(out, d[max])
		}
	}
}

package main

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

func main() {

	in := bufio.NewReader(os.Stdin)
	//in, _ := os.Open("input.txt")
	var T int
	fmt.Fscanf(in, "%d\n", &T)

	for k := 0; k < T; k++ {
		var n int
		fmt.Fscanf(in, "%d\n", &n)

		mp := make(map[int]int)
		var val, mval int
		mval = 0

		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d\n", &val)
			mp[val]++
			mval = max(mval, mp[val])
		}
		p := len(mp)
		fmt.Println(max(min(p-1, mval), min(p, mval-1)))
	}

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

package main

import (
	"fmt"
)

func main() {

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

	for k := 0; k < T; k++ {
		var n int
		fmt.Scanf("%d", &n)

		mp := make(map[int]int)
		var val, mval int
		mval = 0

		for i := 0; i < n; i++ {
			fmt.Scanf("%d", &val)
			mp[val]++
			mval = max(mval, mp[val])
		}
		p := len(mp)
		fmt.Println(max(min(p-1, mval), min(p, mval-1)))
	}

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var T int
	fmt.Fscanf(in, "%d\n", &T)

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

		mp := make(map[int]int)
		var val, mval int
		mval = 0

		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d ", &val)
			mp[val]++
			mval = max(mval, mp[val])
		}

		fmt.Println(max(min(len(mp)- 1, mval), min(len(mp), mval - 1)))
	}

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

package main

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

func solve(n int, m map[int]int) int {
	max := 0

	for _, v := range m {
		if v > max {
			max = v
		}
	}

	return findMin(findMin(max, len(m)), n/2)
}

func findMin(n1 int, n2 int) int {
	if n1 < n2 {
		return n1
	}

	return n2
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var t, n, a int
	fmt.Fscanf(r, "%d\n", &t)

	for tc := 0; tc < t; tc++ {
		fmt.Fscanf(r, "%d\n", &n)
		m := map[int]int{}

		for i := 0; i < n; i++ {
			fmt.Fscanf(r, "%d", &a)
			m[a]++
		}
		fmt.Fscanln(r)
		fmt.Fprintf(os.Stdout, "%d\n", solve(n, m))
	}
}

// https://serhatgiydiren.github.io

package main

import "fmt"

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

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

func solve(test_id int) {
 var n,q int
 fmt.Scan(&n)
 m := make(map[int]int)
 for i := 0 ; i < n ; i++ {
  fmt.Scan(&q)
  m[q]++
 }
 c := 0
 for _,v := range(m) {
  c=max(c,v)
 }
 fmt.Println(min(len(m),min(c,n/2)))
}

func solve_cases() {
 t := 1
 fmt.Scan(&t)
 for i := 0 ; i < t ; i++ {
  solve(i)
 }
}

func main() {
 solve_cases()
}

// https://serhatgiydiren.github.io

package main

import "fmt"

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

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

func solve(test_id int) {
 var n,q int
 fmt.Scan(&n)
 m := make(map[int]int)
 for i := 0 ; i < n ; i++ {
  fmt.Scan(&q)
  m[q]++
 }
 c := 0
 for _,v := range(m) {
  c=max(c,v)
 }
 res := min(c,min(len(m),n/2))
 if res == c {
  res--
 }
 fmt.Println(res)
}

func solve_cases() {
 t := 1
 fmt.Scan(&t)
 for i := 0 ; i < t ; i++ {
  solve(i)
 }
}

func main() {
 solve_cases()
}

package main

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

/*
4
7
4 2 4 1 4 3 4
5
2 1 5 4 3
1
1
4
1 1 1 3
*/

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

	var T int64
	var R int64
	for Fscan(in, &T); T > 0; T-- {

		target := make(map[int]int)
		for Fscan(in, &R); R > 0; R-- {
			var data int
			Fscan(in, &data)
			target[data] ++
		}

		if len(target) == 0 {
			Fprintln(out, 0)
			continue
		}

		var sumTwo int
		for _, v := range target {
			if v != 1 {
				if sumTwo < v {
					sumTwo = v
				}
			}
		}

		Fprintln(out, TTCMin(len(target), sumTwo))

	}
}

func TTCMin(len, two int) int {
	if len == 1 {
		return 0
	}

	if two == 0 {
		return 1
	}

	if two-len+1 > 1 {
		return len
	}

	if two-len+1 > 0 {
		return len - 1
	}

	return two
}

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

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

package main

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

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

func Solve(n int, a []int) int {
	count := make(map[int]int)
	for _, elem := range a {
		count[elem] += 1
	}
	maxCount := 0
	for _, v := range count {
		if v > maxCount {
			maxCount = v
		}
	}
	distinct := len(count) - 1
	if distinct+1 < maxCount {
		return maxCount - 1
	}
	return min(distinct, maxCount)
}

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

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

package main

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

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

type writerImpl struct {
	*bufio.Writer
}

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

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

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

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

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

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

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

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

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n := reader.NextInt64()
		am := map[int64]int64{}
		maxSoFar := int64(0)
		for i := int64(0); i < n; i++ {
			a := reader.NextInt64()
			am[a]++
			maxSoFar = max(maxSoFar, am[a])
		}
		writer.Printf("%d\n", min(n/2, maxSoFar))
	}
}

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

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

package main

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

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

type writerImpl struct {
	*bufio.Writer
}

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

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

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

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

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

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

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

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

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n := reader.NextInt64()
		am := map[int64]int64{}
		maxSoFar := int64(0)
		for i := int64(0); i < n; i++ {
			a := reader.NextInt64()
			am[a]++
			maxSoFar = max(maxSoFar, am[a])
		}
		writer.Printf("%d\n", min(n/2, int64(len(am)), maxSoFar))
	}
}

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

func min(a, b, c int64) int64 {
	if a <= b  && a <= c {
		return a
	}
    if b <= a && b <= c {
        return b
    }
	return c
}


package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	col := make([]int, n)
	row := make([]int, m)
	for j := range row {
		fmt.Scan(&row[j])
	}
	col[0] = extractMin(row)
	for i := 1; i < n; i++ {
		var v int
		fmt.Scan(&v)
		col[i] = v - row[0]
		if col[i] < 0 {
			fmt.Println("-1")
			return
		}
		for j := 1; j < m; j++ {
			fmt.Scan(&v)
			if col[i] != v-row[j] {
				fmt.Println("-1")
				return
			}
		}
	}
	base := extractMin(col)
	sum := sum(row) + sum(col)
	if n > m {
		fmt.Println(sum + base*m)
		for i := range row {
			for j := 0; j < base; j++ {
				fmt.Println("col", i+1)
			}
		}
	} else {
		fmt.Println(sum + base*n)
		for j := range col {
			for i := 0; i < base; i++ {
				fmt.Println("row", j+1)
			}
		}
	}
	for i, v := range row {
		for k := 0; k < v; k++ {
			fmt.Println("col", i+1)
		}
	}
	for j, v := range col {
		for k := 0; k < v; k++ {
			fmt.Println("row", j+1)
		}
	}
}

func extractMin(arr []int) int {
	min := arr[0]
	for _, v := range arr {
		if min > v {
			min = v
		}
	}
	for i := range arr {
		arr[i] -= min
	}
	return min
}

func sum(arr []int) int {
	res := 0
	for _, v := range arr {
		res += v
	}
	return res
}

// Codeforces My Practice
// author: Leonardone @ NEETSDKASU
package main

import "fmt"

type tup struct {
	rc bool
	p  int
}

func rows(f [][]int, ans []tup) []tup {
	for i := range f {
		min := 9999
		for j := range f[i] {
			if f[i][j] < min {
				min = f[i][j]
			}
		}
		for k := 0; k < min; k++ {
			ans = append(ans, tup{true, i + 1})
		}
		for j := range f[i] {
			f[i][j] -= min
		}
	}
	return ans
}

func cols(f [][]int, ans []tup) []tup {
	for j := range f[0] {
		min := 9999
		for i := range f {
			if f[i][j] < min {
				min = f[i][j]
			}
		}
		for k := 0; k < min; k++ {
			ans = append(ans, tup{false, j + 1})
		}
		for i := range f {
			f[i][j] -= min
		}
	}
	return ans
}

func main() {
	ans := make([]tup, 0, 10000)
	var n, m int
	fmt.Scan(&n, &m)
	f := make([][]int, n)
	for i := range f {
		f[i] = make([]int, m)
		for j := range f[i] {
			fmt.Scan(&f[i][j])
		}
	}
	if n < m {
		ans = rows(f, ans)
		ans = cols(f, ans)
	} else {
		ans = cols(f, ans)
		ans = rows(f, ans)
	}
	for _, ff := range f {
		for _, v := range ff {
			if v > 0 {
				fmt.Println(-1)
				return
			}
		}
	}
	fmt.Println(len(ans))
	for _, t := range ans {
		if t.rc {
			fmt.Println("row", t.p)
		} else {
			fmt.Println("col", t.p)
		}
	}
}

package main

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

func main() {
	sc := NewScanner()
	n, m := sc.NextInt(), sc.NextInt()
	grid := make([][]int, n)
	grid2 := make([][]int, n)

	for i := 0; i < n; i++ {
		grid[i] = sc.NextIntArray()
		grid2[i] = make([]int, m)
		for j := 0; j < m; j++ {
			grid2[i][j] = grid[i][j]
		}
	}
	ansFlag := true
	ans := make([]string, 0)
	for i := 0; i < n; i++ {
		mn := grid[i][0]
		for j := 0; j < m; j++ {
			if mn > grid[i][j] {
				mn = grid[i][j]
			}
		}

		for k := 0; k < mn; k++ {
			ans = append(ans, fmt.Sprintf("row %d", i+1))
		}
		for j := 0; j < m; j++ {
			grid[i][j] -= mn
		}
	}

	for j := 0; j < m; j++ {
		mn := grid[0][j]
		for i := 0; i < n; i++ {
			if mn > grid[i][j] {
				mn = grid[i][j]
			}
		}

		for k := 0; k < mn; k++ {
			ans = append(ans, fmt.Sprintf("col %d", j+1))
		}
		for i := 0; i < n; i++ {
			grid[i][j] -= mn
		}
	}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if 0 < grid[i][j] {
				ansFlag = false
				goto A
			}
		}
	}
A:
	ans2 := make([]string, 0)
	ans2Flag := true

	for j := 0; j < m; j++ {
		mn := grid2[0][j]
		for i := 0; i < n; i++ {
			if mn > grid2[i][j] {
				mn = grid2[i][j]
			}
		}

		for k := 0; k < mn; k++ {
			ans2 = append(ans2, fmt.Sprintf("col %d", j+1))
		}
		for i := 0; i < n; i++ {
			grid2[i][j] -= mn
		}
	}

	for i := 0; i < n; i++ {
		mn := grid2[i][0]
		for j := 0; j < m; j++ {
			if mn > grid2[i][j] {
				mn = grid2[i][j]
			}
		}

		for k := 0; k < mn; k++ {
			ans2 = append(ans2, fmt.Sprintf("row %d", i+1))
		}
		for j := 0; j < m; j++ {
			grid2[i][j] -= mn
		}
	}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if 0 < grid[i][j] {
				ans2Flag = false
				goto B
			}
		}
	}
B:
	var A []string
	if ansFlag {
		A = ans
	}
	if ans2Flag {
		if A == nil || len(A) > len(ans2) {
			A = ans2
		}
	}

	if A == nil {
		fmt.Println(-1)
		return
	}
	fmt.Println(len(A))
	for _, v := range A {
		fmt.Println(v)
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

var in = bufio.NewScanner(os.Stdin)

func readInt() int {
	if !in.Scan() {
		panic(in.Err())
	}
	res := 0
	for _, b := range in.Bytes() {
		res = res*10 + int(b-'0')
	}
	return res
}

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

	n := readInt()
	m := readInt()
	a := make([][]int, n)
	for i := range a {
		a[i] = make([]int, m)
		for j := range a[i] {
			a[i][j] = readInt()
		}
	}
	var rows, cols []int
	handleRows := func() {
		for i := range a {
			mi := 500
			for j := range a[i] {
				if x := a[i][j]; mi > x {
					mi = x
				}
			}
			for j := 0; j < mi; j++ {
				rows = append(rows, i+1)
			}
			for j := range a[i] {
				a[i][j] -= mi
			}
		}
	}
	handleCols := func() {
		for j := range a[0] {
			mi := 500
			for i := range a {
				if x := a[i][j]; mi > x {
					mi = x
				}
			}
			for i := 0; i < mi; i++ {
				cols = append(cols, j+1)
			}
			for i := range a {
				a[i][j] -= mi
			}
		}
	}
	if n < m {
		handleRows()
		handleCols()
	} else {
		handleCols()
		handleRows()
	}
	for i := range a {
		for j := range a[i] {
			if a[i][j] != 0 {
				fmt.Println(-1)
				return
			}
		}
	}
	fmt.Fprintln(out, len(rows)+len(cols))
	for _, i := range rows {
		fmt.Fprintln(out, "row", i)
	}
	for _, i := range cols {
		fmt.Fprintln(out, "col", i)
	}
}

package main

import (
	"fmt"
)

func main() {
	arr, invertDim := scan()

	rowSubstract := make([]int, len(arr))
	for i, row := range arr {
		min := min(row)
		rowSubstract[i] = min
		substract(row, rowSubstract[i])
	}

	colSubstract := arr[0]
	for _, row := range arr {
		for j, cell := range row {
			if cell != colSubstract[j] {
				fmt.Println("-1")
				return
			}
		}
	}

	fmt.Println(sum(rowSubstract) + sum(colSubstract))
	if invertDim {
		print("row", colSubstract)
		print("col", rowSubstract)
	} else {
		print("row", rowSubstract)
		print("col", colSubstract)
	}
}

func scan() (arr [][]int, invertDim bool) {
	var n, m int
	fmt.Scan(&n, &m)
	if n > m {
		invertDim = true
		n, m = m, n
	}
	arr = make([][]int, n)
	for i := range arr {
		arr[i] = make([]int, m)
	}
	if invertDim {
		for j := range arr[0] {
			for i := range arr {
				fmt.Scan(&arr[i][j])
			}
		}
	} else {
		for i := range arr {
			for j := range arr[i] {
				fmt.Scan(&arr[i][j])
			}
		}
	}
	return
}

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

func substract(arr []int, diff int) {
	for i := range arr {
		arr[i] -= diff
	}
}

func sum(arr []int) (sum int) {
	for _, v := range arr {
		sum += v
	}
	return
}

func print(label string, vals []int) {
	for i, n := range vals {
		for j := 0; j < n; j++ {
			fmt.Println(label, i+1)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	arr := scan()

	rowSubstract := make([]int, len(arr))
	for i, row := range arr {
		min := min(row)
		rowSubstract[i] = min
		substract(row, rowSubstract[i])
	}

	colSubstract := arr[0]
	for _, row := range arr {
		for j, cell := range row {
			if cell != colSubstract[j] {
				fmt.Println("-1")
				return
			}
		}
	}

	fmt.Println(sum(rowSubstract) + sum(colSubstract))
	print("row", rowSubstract)
	print("col", colSubstract)
}

func scan() [][]int {
	var n, m int
	fmt.Scan(&n, &m)
	arr := make([][]int, n)
	for i := range arr {
		arr[i] = make([]int, m)
		for j := range arr[i] {
			fmt.Scan(&arr[i][j])
		}
	}
	return arr
}

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

func substract(arr []int, diff int) {
	for i := range arr {
		arr[i] -= diff
	}
}

func sum(arr []int) (sum int) {
	for _, v := range arr {
		sum += v
	}
	return
}

func print(label string, vals []int) {
	for i, n := range vals {
		for j := 0; j < n; j++ {
			fmt.Println(label, i)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	col := make([]int, n)
	row := make([]int, m)
	for j := range row {
		fmt.Scan(&row[j])
	}
	col[0] = extractMin(row)
	for i := 1; i < n; i++ {
		var v int
		fmt.Scan(&v)
		col[i] = v - row[0]
		if col[i] < 0 {
			fmt.Println("-1")
			return
		}
		for j := 1; j < m; j++ {
			fmt.Scan(&v)
			if col[i] != v-row[j] {
				fmt.Println("-1")
				return
			}
		}
	}
	base := extractMin(col)
	sum := sum(row) + sum(col)
	if n > m {
		fmt.Println(sum + base*m)
		for i := range row {
			for j := 0; j < base; j++ {
				fmt.Println("row", i+1)
			}
		}
	} else {
		fmt.Println(sum + base*n)
		for j := range col {
			for i := 0; i < base; i++ {
				fmt.Println("col", j+1)
			}
		}
	}
	for i, v := range row {
		for k := 0; k < v; k++ {
			fmt.Println("col", i+1)
		}
	}
	for j, v := range col {
		for k := 0; k < v; k++ {
			fmt.Println("row", j+1)
		}
	}
}

func extractMin(arr []int) int {
	min := arr[0]
	for _, v := range arr {
		if min > v {
			min = v
		}
	}
	for i := range arr {
		arr[i] -= min
	}
	return min
}

func sum(arr []int) int {
	res := 0
	for _, v := range arr {
		res += v
	}
	return res
}

package main

import (
	"fmt"
)

func main() {
	arr := scan()

	rowSubstract := make([]int, len(arr))
	for i, row := range arr {
		min := min(row)
		rowSubstract[i] = min
		substract(row, rowSubstract[i])
	}

	colSubstract := arr[0]
	for _, row := range arr {
		for j, cell := range row {
			if cell != colSubstract[j] {
				fmt.Println("-1")
				return
			}
		}
	}

	fmt.Println(sum(rowSubstract) + sum(colSubstract))
	print("row", rowSubstract)
	print("col", colSubstract)
}

func scan() [][]int {
	var n, m int
	fmt.Scan(&n, &m)
	arr := make([][]int, n)
	for i := range arr {
		arr[i] = make([]int, m)
		for j := range arr[i] {
			fmt.Scan(&arr[i][j])
		}
	}
	return arr
}

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

func substract(arr []int, diff int) {
	for i := range arr {
		arr[i] -= diff
	}
}

func sum(arr []int) (sum int) {
	for _, v := range arr {
		sum += v
	}
	return
}

func print(label string, vals []int) {
	for i, n := range vals {
		for j := 0; j < n; j++ {
			fmt.Println(label, i+1)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	col := make([]int, n)
	row := make([]int, m)
	for j := range row {
		fmt.Scan(&row[j])
	}
	col[0] = extractMin(row)
	for i := 1; i < n; i++ {
		var v int
		fmt.Scan(&v)
		col[i] = v - row[0]
		if col[i] < 0 {
			fmt.Println("-1")
			return
		}
		for j := 1; j < m; j++ {
			fmt.Scan(&v)
			if col[i] != v-row[j] {
				fmt.Println("-1")
				return
			}
		}
	}
	base := extractMin(col)
	if n < m {
		for i := range row {
			for j := 0; j < base; j++ {
				fmt.Println("row", i+1)
			}
		}
	} else {
		for j := range col {
			for i := 0; i < base; i++ {
				fmt.Println("col", j+1)
			}
		}
	}
	for i, v := range row {
		for k := 0; k < v; k++ {
			fmt.Println("col", i+1)
		}
	}
	for j, v := range col {
		for k := 0; k < v; k++ {
			fmt.Println("row", j+1)
		}
	}
}

func extractMin(arr []int) int {
	min := arr[0]
	for _, v := range arr {
		if min > v {
			min = v
		}
	}
	for i := range arr {
		arr[i] -= min
	}
	return min
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	col := make([]int, n)
	row := make([]int, m)
	for j := range row {
		fmt.Scan(&row[j])
	}
	col[0] = extractMin(row)
	for i := 1; i < n; i++ {
		var v int
		fmt.Scan(&v)
		col[i] = v - row[0]
		if col[i] < 0 {
			fmt.Println("-1")
			return
		}
		for j := 1; j < m; j++ {
			fmt.Scan(&v)
			if col[i] != v-row[j] {
				fmt.Println("-1")
				return
			}
		}
	}
	base := extractMin(col)
	sum := sum(row) + sum(col)
	if n < m {
		fmt.Println(sum + base*len(row))
		for i := range row {
			for j := 0; j < base; j++ {
				fmt.Println("row", i+1)
			}
		}
	} else {
		fmt.Println(sum + base*len(col))
		for j := range col {
			for i := 0; i < base; i++ {
				fmt.Println("col", j+1)
			}
		}
	}
	for i, v := range row {
		for k := 0; k < v; k++ {
			fmt.Println("col", i+1)
		}
	}
	for j, v := range col {
		for k := 0; k < v; k++ {
			fmt.Println("row", j+1)
		}
	}
}

func extractMin(arr []int) int {
	min := arr[0]
	for _, v := range arr {
		if min > v {
			min = v
		}
	}
	for i := range arr {
		arr[i] -= min
	}
	return min
}

func sum(arr []int) int {
	res := 0
	for _, v := range arr {
		res += v
	}
	return res
}

package main

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

func main() {
	sc := NewScanner()
	n, m := sc.NextInt(), sc.NextInt()
	grid := make([][]int, n)
	grid2 := make([][]int, n)

	for i := 0; i < n; i++ {
		grid[i] = sc.NextIntArray()
		grid2[i] = make([]int, m)
		for j := 0; j < m; j++ {
			grid2[i][j] = grid[i][j]
		}
	}

	ans := make([]string, 0)
	for i := 0; i < n; i++ {
		mn := grid[i][0]
		for j := 0; j < m; j++ {
			if mn > grid[i][j] {
				mn = grid[i][j]
			}
		}

		for k := 0; k < mn; k++ {
			ans = append(ans, fmt.Sprintf("row %d", i+1))
		}
		for j := 0; j < m; j++ {
			grid[i][j] -= mn
		}
	}

	for j := 0; j < m; j++ {
		mn := grid[0][j]
		for i := 0; i < n; i++ {
			if mn > grid[i][j] {
				mn = grid[i][j]
			}
		}

		for k := 0; k < mn; k++ {
			ans = append(ans, fmt.Sprintf("col %d", j+1))
		}
		for i := 0; i < n; i++ {
			grid[i][j] -= mn
		}
	}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if 0 < grid[i][j] {
				fmt.Println(-1)
				return
			}
		}
	}

	ans2 := make([]string, 0)

	for j := 0; j < m; j++ {
		mn := grid2[0][j]
		for i := 0; i < n; i++ {
			if mn > grid2[i][j] {
				mn = grid2[i][j]
			}
		}

		for k := 0; k < mn; k++ {
			ans2 = append(ans2, fmt.Sprintf("col %d", j+1))
		}
		for i := 0; i < n; i++ {
			grid2[i][j] -= mn
		}
	}

	for i := 0; i < n; i++ {
		mn := grid2[i][0]
		for j := 0; j < m; j++ {
			if mn > grid2[i][j] {
				mn = grid2[i][j]
			}
		}

		for k := 0; k < mn; k++ {
			ans2 = append(ans2, fmt.Sprintf("row %d", i+1))
		}
		for j := 0; j < m; j++ {
			grid2[i][j] -= mn
		}
	}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if 0 < grid[i][j] {
				fmt.Println(-1)
				return
			}
		}
	}

	if len(ans) < len(ans2) {
		fmt.Println(len(ans))
		for _, v := range ans {
			fmt.Println(v)
		}
	} else {
		if len(ans) > len(ans2) {
			fmt.Println(len(ans2))
			for _, v := range ans2 {
				fmt.Println(v)
			}
		}

	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}