You are given $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$. You choose any subset of the given numbers (possibly, none or all numbers) and negate these numbers (i. e. change $$$x \to (-x)$$$). What is the maximum number of different values in the array you can achieve?

The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The next lines contain the description of the $$$t$$$ test cases, two lines per a test case. In the first line you are given one integer $$$n$$$ ($$$1 \leq n \leq 100$$$): the number of integers in the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$-100 \leq a_i \leq 100$$$).

For each test case, print one integer: the maximum number of different elements in the array that you can achieve negating numbers in the array.

NoteIn the first example we can, for example, negate the first and the last numbers, achieving the array $$$[-1, 1, 2, -2]$$$ with four different values.In the second example all three numbers are already different.In the third example negation does not change anything.

package main

import (
	"fmt"
)

var mp map[int]int

func main(){

	var tst int
// 	tst1, err1 :=
    fmt.Scan(&tst)
// 	if err1 !=nil {
// 	    fmt.Println(tst1, err1)
// 	}
	for i:=0 ; i< tst; i++ {
		mp = make(map[int]int)
		var n int
		var a int
		cnt :=0
// 		n1, err :=
        fmt.Scan(&n)
// 		if err != nil {
//           fmt.Println(n1,err)
//         }
		for j :=1 ; j<=n; j++{

// 			a1, err2 :=
           fmt.Scan(&a)
		  //  if err2 != nil {
    //               fmt.Println(a1,err2)
    //         }

			if mp[a]==0{
				cnt++
				mp[a]=1
			}else if mp[-a]==0{
				cnt++
				mp[-a]=1
			}
		}

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

package main

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

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

var mp map[int]int

func main(){
// 	defer writer.Flush()
	var tst int
	tst1, err1 := fmt.Scanf("%d", &tst)
	if err1 !=nil {
	    fmt.Println(tst1, err1)
	}
// 	fmt.Println("tst=",tst)
	for i:=0 ; i< tst; i++ {
		mp = make(map[int]int)
		var n int
		var a int
		cnt :=0
		n1, err := fmt.Scan(&n)
		if err != nil {
           fmt.Println(n1,err)
        }
// 		fmt.Println("val =",n,"\ni=",i)
		for j :=1 ; j<=n; j++{
// 			fmt.Scanf("%d", &a)
			a1, err2 := fmt.Scan(&a)
		    if err2 != nil {
                  fmt.Println(a1,err2)
            }
            // fmt.Println(j ,"=" , a)
			if mp[a]==0{
				cnt++
				mp[a]=1
			}else if mp[-a]==0{
				cnt++
				mp[-a]=1

			}
// 			fmt.Printf("%d ", cnt)
		}

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

package main

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

/*
3
4
1 1 2 2
3
1 2 3
2
0 0

*/
/*
	A template for Go on codeforces.com
	Author: Yakov, frvr.ru
*/

func main() {
	// START WRITING YOUR SOLUTION HERE:
	// writeLine(typeOf(readInt()))
	t := readInt()

	for t > 0 {
		_ = readInt()
		// 		writeLine(k)
		map_ := make(map[int]int)
		arr := readInts()
		for _, i := range arr {
			map_[int(math.Abs(float64(i)))] += 1
		}
		ans := 0.0

		for k, _ := range map_ {
			if k == 0 {
				ans += math.Min(1, float64(map_[k]))
			} else {
				ans += math.Min(2, float64(map_[k]))
			}
		}
		write(int(ans), "\n")
		t--
	}

}

/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */

var in = bufio.NewReader(os.Stdin)

type float = float32
type double = float64
type long = int64
type ulong = uint64

func typeOf(arg interface{}) string {
	switch reflect.TypeOf(arg).Kind() {
	case reflect.Int:
		return "int"
	case reflect.Int8:
		return "int8"
	case reflect.Int16:
		return "int16"
	case reflect.Int32:
		return "int32"
	case reflect.Int64:
		return "int64"
	case reflect.Uint:
		return "uint"
	case reflect.Uint8:
		return "uint8"
	case reflect.Uint16:
		return "uint16"
	case reflect.Uint32:
		return "uint32"
	case reflect.Uint64:
		return "uint64"
	case reflect.Float32:
		return "float32"
	case reflect.Float64:
		return "float64"
	case reflect.Complex64:
		return "complex64"
	case reflect.Complex128:
		return "complex128"
	case reflect.Bool:
		return "bool"
	case reflect.String:
		return "string"
	case reflect.Chan:
		return "chan"
	case reflect.Ptr:
		return "ptr"
	case reflect.Uintptr:
		return "uintptr"
	case reflect.UnsafePointer:
		return "unsafeptr"
	case reflect.Interface:
		return "interface"
	case reflect.Array:
		return "array"
	case reflect.Slice:
		return "slice"
	case reflect.Map:
		return "map"
	case reflect.Struct:
		return "struct"
	case reflect.Func:
		return "func"
	case reflect.Invalid:
		return "invalid"
	default:
		return "nil"
	}
}

/* ~~~~~~~~~~ */

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}
func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}

func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float32(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

/* ~~~~~~~~~~ */

// Too much overhead with universal method using interface{}, wait for the generics,
// but for now — just don't look at the redundancy of the code after that commentary :)

func readBools() []bool {
	strs := readStrings()
	arr := make([]bool, len(strs))
	for i, s := range strs {
		arr[i] = readBool(s)
	}
	return arr
}
func readBytes() []byte {
	strs := readStrings()
	arr := make([]byte, len(strs))
	for i, s := range strs {
		arr[i] = readByte(s)
	}
	return arr
}
func readDoubles() []double {
	strs := readStrings()
	arr := make([]double, len(strs))
	for i, s := range strs {
		arr[i] = readDouble(s)
	}
	return arr
}
func readFloats() []float {
	strs := readStrings()
	arr := make([]float, len(strs))
	for i, s := range strs {
		arr[i] = readFloat(s)
	}
	return arr
}
func readInts() []int {
	strs := readStrings()
	arr := make([]int, len(strs))
	for i, s := range strs {
		arr[i] = readInt(s)
	}
	return arr
}
func readLongs() []long {
	strs := readStrings()
	arr := make([]long, len(strs))
	for i, s := range strs {
		arr[i] = readLong(s)
	}
	return arr
}
func readULongs() []ulong {
	strs := readStrings()
	arr := make([]ulong, len(strs))
	for i, s := range strs {
		arr[i] = readULong(s)
	}
	return arr
}

/* ~~~~~~~~~~ */

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLine(arg ...interface{})             { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

package main

import "fmt"

func main() {
	cases := 0
	fmt.Scanf("%d\n", &cases)
	for c := 0; c < cases; c++ {
		n := 0
		fmt.Scanf("%d\n", &n)
		data := make([]int, n)
		memo := make(map[int]int)
		for i := 0; i < n; i++ {
			if i == n-1 {
				fmt.Scanf("%d\n", &data[i])
			} else {
				fmt.Scanf("%d", &data[i])
			}
			if data[i] < 0 {
				data[i] = -data[i]
			}
			memo[data[i]]++
		}
		ans := 0
		for num, cnt := range memo {
			if num == 0 {
				ans++
				continue
			}
			if cnt < 2 {
				ans += cnt
			} else {
				ans += 2
			}
		}
		fmt.Printf("%d\n", ans)
	}
}

package main

import(
    "fmt"
)

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

  for d := 0; d < x ; d++{
    valuesMap := make(map[int]int)
      var howMany int
      fmt.Scan(&howMany)
         for c := 0; c < howMany; c++{
           var temp int
           fmt.Scan(&temp)
           if _,ok := valuesMap[temp]; ok{
             valuesMap[temp]++
           }else{valuesMap[temp] = 1  }
         }
    unique := 0
    for c,_ := range valuesMap{
      if  _,ok := valuesMap[-c]; ok  && c < 0{
      }else{
      if _,ok := valuesMap[c]; ok {
        if c == 0{
          unique++
        }else  if valuesMap[c] >= 2{
          unique +=2
        }else if _,ok := valuesMap[-c]; ok{
              unique +=2
          }else{unique +=1 }
      }else{
        if _,ok := valuesMap[-c]; ok {
          if valuesMap[-c] >= 2{
            unique +=2
        }else{unique +=1 }
      }
      }
    }
  }
    fmt.Println(unique)
  }

}

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)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
		}
		mapper:= make(map[int]int)
		for j:=0;j<n;j++{
			if mapper[abs(list[j])] >= 1 {
				mapper[abs(list[j])]++
				continue
			}
			mapper[abs(list[j])]= 1
		}
		count:=0
		for i,j := range mapper{
			if j == 1 || i==0 {
				count++
				continue
			}
			count+=2
		}
		fmt.Fprintln(out,count)
	}
}

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

package main

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

func process(r *bufio.Reader) {
	_ = readInt(r)
	mp := make(map[int]int, 0)
	ans := 0
	nums := readLineNumbs(r)
	for _, n := range nums {
		x, _ := strconv.Atoi(n)
		nInt := int(x)
		_, e := mp[nInt]
		if e {
			mp[nInt]++
		} else {
			mp[nInt] = 1
		}
	}
	// debug(mp)
	for k, v := range mp {
		if k > 0 {
			if v >= 2 {
				_, e := mp[-k]
				if !e {
					ans += 2
				} else {
					ans += 1
				}
			} else {
				ans += 1
			}
		} else {
			if v >= 2 {
				_, e := mp[-k]
				if !e {
					ans += 2
				} else {
					ans += 1
				}
			} else {
				ans += 1
			}
		}
	}
	fmt.Println(ans)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	t := readInt(reader)
	for i := 0; i < t; i++ {
		process(reader)
	}
}

// Thanks to user: gealbermorales for the valuable guidance with processing input using Go
// Functions are published at https://codeforces.com/blog/entry/94245

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 debug(a interface{}) {
	fmt.Printf("value is = %v \n", a)
}

package main

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

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		n := readInt(reader)
		a := readArrayInt(reader)
		cnt := make([]int, 101)
		max := 0

		for i := 0; i < n; i++ {
			if a[i] < 0 {
				a[i] *= -1
			}

			cnt[a[i]]++
			if cnt[a[i]] <= 2 && cnt[a[i]] > 0 && a[i] != 0 {
				max++
			}

			if a[i] == 0 && cnt[a[i]] == 1 {
				max++
			}
		}

		fmt.Fprintln(writer, max)

		t--
	}

	writer.Flush()
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}

func gcd(x int64, y int64) int64 {
	for y > 0 {
		x, y = y, x % y
	}

	return x
}

func lcm(x int64, y int64) int64 {
	return x*y/gcd(x,y)
}

package main

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

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

	for test := parseInt(getString(reader)); test > 0; test-- {
		_ = parseInt(getString(reader))
		A := getIntln(reader)
		occurence := make([]uint8, 101)
		for _, v := range A {
			occurence[v]++
		}
		var res int
		if occurence[0] > 0 {
			res++
		}
		for _, v := range occurence[1:] {
			if v > 1 {
				res += 2
			} else if v > 0 {
				res++
			}
		}
		writer.WriteString(fmt.Sprintln(res))
	}
	writer.Flush()
}

func parseInt(str string) int {
	var res int
	size := len(str)
	for i := 0; i < size; i++ {
		digit := int(str[i] - '0')
		for j := (i + 1); j < size; j++ {
			digit = digit<<3 + digit<<1
		}
		res += digit
	}
	return res
}

func getIntln(in *bufio.Reader) []uint8 {
	b := strings.Split(getString(in), " ")
	res := make([]uint8, len(b))
	for k, v := range b {
		x, _ := strconv.ParseInt(v, 10, 8)
		if x < 0 {
			x = -x
		}
		res[k] = uint8(x)
	}
	return res
}

func getString(in *bufio.Reader) string {
	res, _ := in.ReadString('\n')
	res = strings.ReplaceAll(res, "\n", "")
	res = strings.ReplaceAll(res, "\r", "")
	res = strings.TrimSpace(res)
	return res
}

package main

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

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

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

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

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

        for j := 0; j < n; j++ {
            var v int
            fmt.Fscan(in, &v)
            if v < 0 {
                arr[v*-1]++
            } else {
                arr[v]++
            }
        }

        var c int
        for idx, v := range arr {
            if idx == 0 {
                c += min(1, v)
            } else {
                c += min(2, v)
            }
        }
        fmt.Fprintln(out, c)
    }
    out.Flush()
}

package main

import (
    "fmt"
)

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

    for i := 0; i < n; i++ {
        m := make(map[int]int)
        var k int
        fmt.Scan(&k)

        for j := 0; j < k; j++ {
            var n2 int
            fmt.Scan(&n2)
            if n2 != 0 {
                _, ok := m[n2]
                if ok {
                    m[n2*-1] = 1
                } else {
                    m[n2] = 1
                }
            } else {
                m[0] = 1
            }
        }

        fmt.Println(len(m))
    }
}

package main

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

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

func main() {
	var ntc int
	fmt.Fscan(in, &ntc)
	for t := 0; t < ntc; t++ {
		var n int
		fmt.Fscan(in, &n)
		var a []int = make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
			if a[i] < 0 {
				a[i] = -a[i]
			}
		}
		sort.Ints(a)
		var ans = 0
		var zero = false
		for i := 0; i < n; i++ {
			if a[i] == 0 {
				zero = true
				continue
			}
			ans++
			if i > 1 {
				if a[i-1] == a[i] && a[i-2] == a[i] {
					ans--
				}
			}
		}
		if zero {
			ans++
		}
		fmt.Fprintf(out, "%d\n", ans)
	}
	out.Flush()
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1616A
Date: 11/01/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1616/A
Problem: CF1616A
**/
func (in *CF1616A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		mapa := make(map[int]int)
		for i := 0; i < n; i++ {
			val := in.NextInt()
			num, _ := mapa[val]
			mapa[val] = num + 1
		}

		for k, v := range mapa {
			if v > 1 {
				val, _ := mapa[-k]
				mapa[-k] = val + 1
			}
		}

		fmt.Println(len(mapa))
	}
}

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

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

package main

import (
	"fmt"
	"math"
)

func main() {

	t := 0
	fmt.Scan(&t)

	for t > 0 {

		n := 0
		fmt.Scan(&n)
		a := []int{}

		for n > 0 {
			temp := 0
			fmt.Scan(&temp)
			a = append(a, temp)
			n--
		}

		fmt.Println(solve(a))

		t--
	}

	// a := []int{0, 0}
	// fmt.Println(solve(a))
}

func solve(a []int) int {

	record := make([]int, 101)
	count := 0

	for i := range a {
		val := math.Abs(float64(a[i]))
		record[int(val)]++
	}

	for i := range record {

		if i == 0 {
			if record[i] > 0 {
				count++
			}
			continue
		}

		if record[i] == 1 {
			count += 1
		} else if record[i] > 1 {
			count += 2
		}

	}

	return count
}

package main

import "fmt"

var (
	T   int
	n   int
	tax = [105]int{}
)

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

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

func main() {
	fmt.Scanln(&T)
	for T > 0 {
		fmt.Scanln(&n)
		for i := 0; i <= 100; i++ {
			tax[i] = 0
		}
		for i, a := 1, 0; i <= n; i++ {
			fmt.Scan(&a)
			tax[abs(a)]++
		}
		ans := 0
		for i := 0; i <= 100; i++ {
			if i == 0 {
				ans += min(1, tax[i])
			} else {
				ans += min(2, tax[i])
			}
		}
		fmt.Printf("%d\n", ans)
		fmt.Scanln()
		T--
	}
}

package main

import "fmt"

func main() {
	var numTestCases uint

	fmt.Scan(&numTestCases)
	for testCase := numTestCases; testCase > 0; testCase-- {
		var n uint
		fmt.Scan(&n)

		var elm int
		uniqueElements := make(map[int]struct{}, n)
		for i := n; i > 0; i-- {
			fmt.Scan(&elm)
			if _, containsElm := uniqueElements[elm]; !containsElm {
				uniqueElements[elm] = struct{}{}
			} else if _, containsElm := uniqueElements[-elm]; !containsElm {
				uniqueElements[-elm] = struct{}{}
			}
		}

		fmt.Println(len(uniqueElements))
	}
}

package main

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

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

func main() {
	defer out.Flush()
	//redirectInputToFile(in, "input.txt")

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

func solve() {
	n := readInt()
	m := make(map[int]int, 0)
	for i := 0; i < n; i++ {
		next := readInt()
		if next == 0 {
			m[next] = 1
			continue
		}
		if next < 0 {
			next = -next
		}
		m[next]++
	}
	var ans int
	for _, v := range m {
		if v >= 2 {
			ans += 2
		} else {
			ans += 1
		}
	}
	println(ans)
}

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

// READ
func readInt() int {
	var res int
	fmt.Fscan(in, &res)
	return res
}

func readInt64() int64 {
	var res int64
	fmt.Fscan(in, &res)
	return res
}

func readString() string {
	var res string
	fmt.Fscan(in, &res)
	return res
}

// PRINT
func print(args ...interface{}) {
	fmt.Fprint(out, args...)
	out.Flush()
}

func println(args ...interface{}) {
	fmt.Fprintln(out, args...)
	out.Flush()
}

func printErr(args ...interface{}) {
	fmt.Fprint(err, args...)
	err.Flush()
}

func printlnErr(args ...interface{}) {
	fmt.Fprintln(err, args...)
	err.Flush()
}

package main

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

func main() {
	//file, _ := os.Open("input.txt")
	//in := bufio.NewReader(file)
	in := bufio.NewReader(os.Stdin)

	input1 := readArrInt(in)
	t := input1[0]
	for ; t != 0; t-- {
		input := readArrInt(in)
		n := input[0]
		var arr [101]bool
		var arr2 [101]bool
		ans := 0
		inp := readArrInt(in)
		for i := 0; i < n; i++ {
			num := abs(inp[i])
			if arr[num] == false {
				ans++
				arr[num] = true
			} else if num != 0 && arr2[num] == false {
				ans++
				arr2[num] = true
			}
		}
		fmt.Println(ans)
	}
}

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

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

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

func readFloat(in *bufio.Reader) float64 {
	nStr := readStr(in)
	n, _ := strconv.ParseFloat(nStr, 64)
	return n
}

func readInt(in *bufio.Reader) int {
	nStr := readStr(in)
	n, _ := strconv.Atoi(nStr)
	return n
}

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

func readLineNumbs(in *bufio.Reader) []string {
	line := readStr(in)
	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 readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n := 0, 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		o, p := map[int]int{}, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &p)
			o[p]++
			if o[p] > 1 {
				o[-p]++
				o[p]--
			}
		}
		fmt.Fprintln(w, len(o))
	}
	w.Flush()
}

func main() {
	solve()
}

package main

import "fmt"

var mp map[int]int

func main(){
	var tst int
	// fmt.Scanln(&tst)
	fmt.Scanf("%d", &tst)
	for i:=0 ; i< tst; i++ {
		mp = make(map[int]int)
		var n,a int
		cnt :=0
		// fmt.Scanln(&n)
		fmt.Scanf("%d", &n)
		for j :=0 ; j<n; j++{
			// fmt.Scanln(&a)
			fmt.Scanf("%d", &a)
			if mp[a]==0{
				cnt++
				mp[a]=1
			}else if mp[-a]==0{
				cnt++
				mp[-a]=1

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

package main

import "fmt"

func main(){
	var tst int
	// fmt.Scanln(&tst)
	fmt.Scanf("%d", &tst)
	for i:=0 ; i< tst; i++ {
		mp := make(map[int]int)
		var n,a int
		cnt :=0
		// fmt.Scanln(&n)
		fmt.Scanf("%d", &n)
		for j :=0 ; j<n; j++{
			// fmt.Scanln(&a)
			fmt.Scanf("%d", &a)
			if mp[a]==0{
				cnt++
				mp[a]=1
			}else if mp[-a]==0{
				cnt++
				mp[-a]=1

			}
		}
		fmt.Println(cnt)
	}
}

package main

import "fmt"

func main(){
	var tst int
	fmt.Scanln(&tst)
	for i:=0 ; i< tst; i++ {
		mp := make(map[int]int)
		var n,a int
		cnt :=0
		fmt.Scanln(&n)
		for j :=0 ; j<n; j++{
			fmt.Scanln(&a)
			if mp[a]==0{
				cnt++
				mp[a]=1
			}else if mp[-a]==0{
				cnt++
				mp[-a]=1

			}
		}
		fmt.Println(cnt)
	}
}

package main

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

/*
3
4
1 1 2 2
3
1 2 3
2
0 0

*/
/*
	A template for Go on codeforces.com
	Author: Yakov, frvr.ru
*/

func main() {
	// START WRITING YOUR SOLUTION HERE:
	// writeLine(typeOf(readInt()))
	t := readInt()

	for t > 0 {
		_ = readInt()
		// 		writeLine(k)
		map_ := make(map[int]int)
		arr := readInts()
		for _, i := range arr {
			map_[i] += 1
		}
		ans := 0.0

		for k, _ := range map_ {
			if k == 0 {
				ans += math.Min(1, float64(map_[k]))
			} else {
				ans += math.Min(2, float64(map_[k]))
			}
		}
		write(int(ans), "\n")
		t--
	}

}

/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */

var in = bufio.NewReader(os.Stdin)

type float = float32
type double = float64
type long = int64
type ulong = uint64

func typeOf(arg interface{}) string {
	switch reflect.TypeOf(arg).Kind() {
	case reflect.Int:
		return "int"
	case reflect.Int8:
		return "int8"
	case reflect.Int16:
		return "int16"
	case reflect.Int32:
		return "int32"
	case reflect.Int64:
		return "int64"
	case reflect.Uint:
		return "uint"
	case reflect.Uint8:
		return "uint8"
	case reflect.Uint16:
		return "uint16"
	case reflect.Uint32:
		return "uint32"
	case reflect.Uint64:
		return "uint64"
	case reflect.Float32:
		return "float32"
	case reflect.Float64:
		return "float64"
	case reflect.Complex64:
		return "complex64"
	case reflect.Complex128:
		return "complex128"
	case reflect.Bool:
		return "bool"
	case reflect.String:
		return "string"
	case reflect.Chan:
		return "chan"
	case reflect.Ptr:
		return "ptr"
	case reflect.Uintptr:
		return "uintptr"
	case reflect.UnsafePointer:
		return "unsafeptr"
	case reflect.Interface:
		return "interface"
	case reflect.Array:
		return "array"
	case reflect.Slice:
		return "slice"
	case reflect.Map:
		return "map"
	case reflect.Struct:
		return "struct"
	case reflect.Func:
		return "func"
	case reflect.Invalid:
		return "invalid"
	default:
		return "nil"
	}
}

/* ~~~~~~~~~~ */

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}
func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}

func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float32(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

/* ~~~~~~~~~~ */

// Too much overhead with universal method using interface{}, wait for the generics,
// but for now — just don't look at the redundancy of the code after that commentary :)

func readBools() []bool {
	strs := readStrings()
	arr := make([]bool, len(strs))
	for i, s := range strs {
		arr[i] = readBool(s)
	}
	return arr
}
func readBytes() []byte {
	strs := readStrings()
	arr := make([]byte, len(strs))
	for i, s := range strs {
		arr[i] = readByte(s)
	}
	return arr
}
func readDoubles() []double {
	strs := readStrings()
	arr := make([]double, len(strs))
	for i, s := range strs {
		arr[i] = readDouble(s)
	}
	return arr
}
func readFloats() []float {
	strs := readStrings()
	arr := make([]float, len(strs))
	for i, s := range strs {
		arr[i] = readFloat(s)
	}
	return arr
}
func readInts() []int {
	strs := readStrings()
	arr := make([]int, len(strs))
	for i, s := range strs {
		arr[i] = readInt(s)
	}
	return arr
}
func readLongs() []long {
	strs := readStrings()
	arr := make([]long, len(strs))
	for i, s := range strs {
		arr[i] = readLong(s)
	}
	return arr
}
func readULongs() []ulong {
	strs := readStrings()
	arr := make([]ulong, len(strs))
	for i, s := range strs {
		arr[i] = readULong(s)
	}
	return arr
}

/* ~~~~~~~~~~ */

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLine(arg ...interface{})             { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

package main

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

/*
3
4
1 1 2 2
3
1 2 3
2
0 0

*/
/*
	A template for Go on codeforces.com
	Author: Yakov, frvr.ru
*/

func main() {
	// START WRITING YOUR SOLUTION HERE:
	// writeLine(typeOf(readInt()))
	t := readInt()

	for t > 0 {
		_ = readInt()
		// 		writeLine(k)
		map_ := make(map[int]int)
		arr := readInts()
		for _, i := range arr {
			map_[i] += 1
		}
		ans := 0.0

		for k, v := range map_ {
			if k == 0 {
				ans += math.Min(1, float64(map_[v]))
			} else {
				ans += math.Min(2, float64(map_[v]))
			}
		}
		write(int(ans), "\n")
		t--
	}

}

/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */

var in = bufio.NewReader(os.Stdin)

type float = float32
type double = float64
type long = int64
type ulong = uint64

func typeOf(arg interface{}) string {
	switch reflect.TypeOf(arg).Kind() {
	case reflect.Int:
		return "int"
	case reflect.Int8:
		return "int8"
	case reflect.Int16:
		return "int16"
	case reflect.Int32:
		return "int32"
	case reflect.Int64:
		return "int64"
	case reflect.Uint:
		return "uint"
	case reflect.Uint8:
		return "uint8"
	case reflect.Uint16:
		return "uint16"
	case reflect.Uint32:
		return "uint32"
	case reflect.Uint64:
		return "uint64"
	case reflect.Float32:
		return "float32"
	case reflect.Float64:
		return "float64"
	case reflect.Complex64:
		return "complex64"
	case reflect.Complex128:
		return "complex128"
	case reflect.Bool:
		return "bool"
	case reflect.String:
		return "string"
	case reflect.Chan:
		return "chan"
	case reflect.Ptr:
		return "ptr"
	case reflect.Uintptr:
		return "uintptr"
	case reflect.UnsafePointer:
		return "unsafeptr"
	case reflect.Interface:
		return "interface"
	case reflect.Array:
		return "array"
	case reflect.Slice:
		return "slice"
	case reflect.Map:
		return "map"
	case reflect.Struct:
		return "struct"
	case reflect.Func:
		return "func"
	case reflect.Invalid:
		return "invalid"
	default:
		return "nil"
	}
}

/* ~~~~~~~~~~ */

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}
func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}

func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float32(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

/* ~~~~~~~~~~ */

// Too much overhead with universal method using interface{}, wait for the generics,
// but for now — just don't look at the redundancy of the code after that commentary :)

func readBools() []bool {
	strs := readStrings()
	arr := make([]bool, len(strs))
	for i, s := range strs {
		arr[i] = readBool(s)
	}
	return arr
}
func readBytes() []byte {
	strs := readStrings()
	arr := make([]byte, len(strs))
	for i, s := range strs {
		arr[i] = readByte(s)
	}
	return arr
}
func readDoubles() []double {
	strs := readStrings()
	arr := make([]double, len(strs))
	for i, s := range strs {
		arr[i] = readDouble(s)
	}
	return arr
}
func readFloats() []float {
	strs := readStrings()
	arr := make([]float, len(strs))
	for i, s := range strs {
		arr[i] = readFloat(s)
	}
	return arr
}
func readInts() []int {
	strs := readStrings()
	arr := make([]int, len(strs))
	for i, s := range strs {
		arr[i] = readInt(s)
	}
	return arr
}
func readLongs() []long {
	strs := readStrings()
	arr := make([]long, len(strs))
	for i, s := range strs {
		arr[i] = readLong(s)
	}
	return arr
}
func readULongs() []ulong {
	strs := readStrings()
	arr := make([]ulong, len(strs))
	for i, s := range strs {
		arr[i] = readULong(s)
	}
	return arr
}

/* ~~~~~~~~~~ */

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLine(arg ...interface{})             { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

package main

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

/*
3
4
1 1 2 2
3
1 2 3
2
0 0

*/
/*
	A template for Go on codeforces.com
	Author: Yakov, frvr.ru
*/

func main() {
	// START WRITING YOUR SOLUTION HERE:
	// writeLine(typeOf(readInt()))
	t := readInt()

	for t > 0 {
		_ = readInt()
		// 		writeLine(k)
		map_ := make(map[int]int)
		arr := readInts()
		count := 0
		for _, i := range arr {
			i = int(math.Abs(float64(i)))
			if i == 0 && map_[i] == 0 {
				map_[i] += 1
				count += 1
			} else if map_[i] < 3 &&  i!=0 {
				map_[i] += 1
				count += 1
			}
		}
		write(count, "\n")
		t--
	}

}

/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */

var in = bufio.NewReader(os.Stdin)

type float = float32
type double = float64
type long = int64
type ulong = uint64

func typeOf(arg interface{}) string {
	switch reflect.TypeOf(arg).Kind() {
	case reflect.Int:
		return "int"
	case reflect.Int8:
		return "int8"
	case reflect.Int16:
		return "int16"
	case reflect.Int32:
		return "int32"
	case reflect.Int64:
		return "int64"
	case reflect.Uint:
		return "uint"
	case reflect.Uint8:
		return "uint8"
	case reflect.Uint16:
		return "uint16"
	case reflect.Uint32:
		return "uint32"
	case reflect.Uint64:
		return "uint64"
	case reflect.Float32:
		return "float32"
	case reflect.Float64:
		return "float64"
	case reflect.Complex64:
		return "complex64"
	case reflect.Complex128:
		return "complex128"
	case reflect.Bool:
		return "bool"
	case reflect.String:
		return "string"
	case reflect.Chan:
		return "chan"
	case reflect.Ptr:
		return "ptr"
	case reflect.Uintptr:
		return "uintptr"
	case reflect.UnsafePointer:
		return "unsafeptr"
	case reflect.Interface:
		return "interface"
	case reflect.Array:
		return "array"
	case reflect.Slice:
		return "slice"
	case reflect.Map:
		return "map"
	case reflect.Struct:
		return "struct"
	case reflect.Func:
		return "func"
	case reflect.Invalid:
		return "invalid"
	default:
		return "nil"
	}
}

/* ~~~~~~~~~~ */

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}
func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}

func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float32(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

/* ~~~~~~~~~~ */

// Too much overhead with universal method using interface{}, wait for the generics,
// but for now — just don't look at the redundancy of the code after that commentary :)

func readBools() []bool {
	strs := readStrings()
	arr := make([]bool, len(strs))
	for i, s := range strs {
		arr[i] = readBool(s)
	}
	return arr
}
func readBytes() []byte {
	strs := readStrings()
	arr := make([]byte, len(strs))
	for i, s := range strs {
		arr[i] = readByte(s)
	}
	return arr
}
func readDoubles() []double {
	strs := readStrings()
	arr := make([]double, len(strs))
	for i, s := range strs {
		arr[i] = readDouble(s)
	}
	return arr
}
func readFloats() []float {
	strs := readStrings()
	arr := make([]float, len(strs))
	for i, s := range strs {
		arr[i] = readFloat(s)
	}
	return arr
}
func readInts() []int {
	strs := readStrings()
	arr := make([]int, len(strs))
	for i, s := range strs {
		arr[i] = readInt(s)
	}
	return arr
}
func readLongs() []long {
	strs := readStrings()
	arr := make([]long, len(strs))
	for i, s := range strs {
		arr[i] = readLong(s)
	}
	return arr
}
func readULongs() []ulong {
	strs := readStrings()
	arr := make([]ulong, len(strs))
	for i, s := range strs {
		arr[i] = readULong(s)
	}
	return arr
}

/* ~~~~~~~~~~ */

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLine(arg ...interface{})             { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

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

/*
3
4
1 1 2 2
3
1 2 3
2
0 0

*/
func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

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

	var num int

	for ; t > 0; t -= 1 {
	    var count int
		scanf("%d", &num)
		map_ := make(map[int]int)
		for i := 0; i < num; i += 1 {
			var j int
			scanf("%d", &j)
			if map_[j] <= 2 {
				map_[j] += 1
				count += 1
			}
		}
		printf("%d\n", count)
	}

}

package main

import "fmt"

func main() {
	cases := 0
	fmt.Scanf("%d\n", &cases)
	for c := 0; c < cases; c++ {
		n := 0
		fmt.Scanf("%d\n", &n)
		data := make([]int, n)
		memo := make(map[int]int)
		for i := 0; i < n; i++ {
			if i == n-1 {
				fmt.Scanf("%d\n", &data[i])
			} else {
				fmt.Scanf("%d", &data[i])
			}
			memo[data[i]]++
		}
		ans := 0
		for num, cnt := range memo {
			if num == 0 {
				ans++
				continue
			}
			if cnt < 2 {
				ans += cnt
			} else {
				ans += 2
			}
		}
		fmt.Printf("%d\n", ans)
	}
}

package main

import "fmt"

func main() {
	cases := 0
	fmt.Scanf("%d\n", &cases)
	for c := 0; c < cases; c++ {
		n := 0
		fmt.Scanf("%d\n", &n)
		data := make([]int, n)
		memo := make(map[int]int)
		for i := 0; i < n; i++ {
			fmt.Scanf("%d", &data[i])
			memo[data[i]]++
		}
		ans := 0
		for num, cnt := range memo {
			if num == 0 {
				ans++
				continue
			}
			if cnt < 2 {
				ans += cnt
			} else {
				ans += 2
			}
		}
		fmt.Printf("%d\n", ans)
	}
}

package main

import "fmt"

func main() {
	cases := 0
	fmt.Scanf("%d\n", &cases)
	for c := 0; c < cases; c++ {
		n := 0
		fmt.Scanf("%d\n", &n)
		data := make([]int, n)
		memo := make(map[int]int)
		for i := 0; i < n; i++ {
			fmt.Scanf("%d", &data[i])
			memo[data[i]]++
		}
		ans := 0
		for num, cnt := range memo {
			if num == 0 {
				ans++
				continue
			}
			if cnt < 2 {
				ans += cnt
			} else {
				cnt += 2
			}
		}
		fmt.Printf("%d\n", ans)
	}
}

package main

import(
    "fmt"
)

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

  for d := 0; d < x ; d++{
    valuesMap := make(map[int]int)
      var howMany int
      fmt.Scan(&howMany)
      var max,min int
         for c := 0; c < howMany; c++{
           var temp int
           fmt.Scan(&temp)
           if c == 0 { max,min = temp,temp}
           if _,ok := valuesMap[temp]; ok{
             valuesMap[temp]++
           }else{valuesMap[temp] = 1  }
           if temp > max {max = temp}
           if min > temp{min = temp}
         }
    unique := 0
    if max < 0 { max = -min}
    for c:= 0; c <= max ; c++{
      if _,ok := valuesMap[c]; ok {
        if c == 0{
          unique++
        }else  if valuesMap[c] >= 2{
          unique +=2
        }else if _,ok := valuesMap[-c]; ok{
              unique +=2
          }else{unique +=1 }
      }else{
        if _,ok := valuesMap[-c]; ok {
          if valuesMap[-c] >= 2{
            unique +=2
        }else{unique +=1 }
      }
      }
    }
    fmt.Println(unique)
  }

}

package main

import(
    "fmt"
)

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

  for d := 0; d < x ; d++{
    valuesMap := make(map[int]int)
      var howMany int
      fmt.Scan(&howMany)
      var max int
         for c := 0; c < howMany; c++{
           var temp int
           fmt.Scan(&temp)
           if c == 0 { max = temp}
           if _,ok := valuesMap[temp]; ok{
             valuesMap[temp]++
           }else{valuesMap[temp] = 1  }
           if temp > max {max = temp}
         }
    unique := 0
    if max < 0 { max = -max}
    for c:= 0; c <= max ; c++{
      if _,ok := valuesMap[c]; ok {
        if c == 0{
          unique++
        }else  if valuesMap[c] >= 2{
          unique +=2
        }else if _,ok := valuesMap[-c]; ok{
              unique +=2
          }else{unique +=1 }
      }else{
        if _,ok := valuesMap[-c]; ok {
          if valuesMap[-c] >= 2{
            unique +=2
        }else{unique +=1 }
      }
      }
    }
    fmt.Println(unique)
  }

}

package main

import(
    "fmt"
)

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

  for d := 0; d < x ; d++{
    container := make([]int,0)
      var howMany int
      fmt.Scan(&howMany)
         for c := 0; c < howMany; c++{
           var temp int
           fmt.Scan(&temp)
           container = append(container,temp)
         }
    valuesMap := make(map[int]int)
    max := container[0]
    for _,c := range container{
      if _,ok := valuesMap[c]; ok{
        valuesMap[c]++
      }else{valuesMap[c] = 1  }
      if c > max {max = c}
    }
    unique := 0
    for c:= 0; c <= max ; c++{
      if _,ok := valuesMap[c]; ok {
        if c == 0{
          unique++
        }else  if valuesMap[c] >= 2{
          unique +=2
        }else if _,ok := valuesMap[-c]; ok{
              unique +=2
          }else{unique +=1 }
      }else{
        if _,ok := valuesMap[-c]; ok {
          if valuesMap[-c] >= 2{
            unique +=2
        }else{unique +=1 }
      }
      }
    }
    fmt.Println(unique)
  }

}

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)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
		}
		mapper:= make(map[int]int)
		for j:=0;j<n;j++{
			if mapper[list[j]] >= 1 {
				mapper[list[j]]++
				continue
			}
			mapper[abs(list[j])]= 1
		}
		count:=0
		for i,j := range mapper{
			if j == 1 || i==0 {
				count++
				continue
			}
			count+=2
		}
		fmt.Fprintln(out,count)
	}
}

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

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)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
		}
		mapper:= make(map[int]int)
		for j:=0;j<n;j++{
			if mapper[list[j]] >= 1 {
				mapper[list[j]]++
				continue
			}
			mapper[list[j]]= 1
		}
		count:=0
		for i,j := range mapper{
			if j == 1 || i==0 {
				count++
				continue
			}
			count+=2
		}
		fmt.Fprintln(out,count)
	}
}

package main

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

func process(r *bufio.Reader) {
	_ = readInt(r)
	mp := make(map[int]int, 0)
	ans := 0
	nums := readLineNumbs(r)
	for _, n := range nums {
		x, _ := strconv.Atoi(n)
		nInt := int(x)
		_, e := mp[nInt]
		if e {
			mp[nInt]++
		} else {
			mp[nInt] = 1
		}
	}
	for k, v := range mp {
		if k > 0 {
			if v >= 2 {
				_, e := mp[-k]
				if !e {
					ans += 2
				} else {
					ans += 1
				}
			} else {
				ans += 1
			}
		} else {
			ans += 1
		}
	}
	fmt.Println(ans)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	t := readInt(reader)
	for i := 0; i < t; i++ {
		process(reader)
	}
}

// Thanks to user: gealbermorales for the valuable guidance with processing input using Go
// Functions are published at https://codeforces.com/blog/entry/94245

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 debug(a interface{}) {
	fmt.Printf("value is = %v \n", a)
}

package main

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

func process() {
	reader := bufio.NewReader(os.Stdin)
	readInt(reader)
	mp := make(map[int]int, 0)
	ans := 0
	nums := readLineNumbs(reader)
	// debug(mp)
	for _, n := range nums {
		x, _ := strconv.Atoi(n)
		nInt := int(x)
		_, e := mp[nInt]
		if e {
			mp[nInt]++
		} else {
			mp[nInt] = 1
		}
	}
	// debug(mp)
	for k, v := range mp {
		if k > 0 {
			if v >= 2 {
				_, e := mp[-k]
				if !e {
					ans += 2
				} else {
					ans += 1
				}
			} else {
				ans += 1
			}
		} else {
			ans += 1
		}
	}
	fmt.Println(ans)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	t := readInt(reader)
	for i := 0; i < t; i++ {
		process()
	}
}

// Thanks to user: gealbermorales for the valuable guidance with processing input using Go
// Functions are published at https://codeforces.com/blog/entry/94245

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 debug(a interface{}) {
	fmt.Printf("value is = %v \n", a)
}

package main

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

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		n := readInt(reader)
		s := readString(reader)

		k := 0
		for i := 1; i < n; i++ {
			if s[i] >= s[i-1] {
				k = i
				break
			}
		}

		ans := ""
		for i := 0; i < k; i++ {
			ans += string(s[i])
		}

		for i := k-1; i >=0; i-- {
			ans += string(s[i])
		}

		fmt.Fprintln(writer, ans)

		t--
	}

	writer.Flush()
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}

func gcd(x int64, y int64) int64 {
	for y > 0 {
		x, y = y, x % y
	}

	return x
}

func lcm(x int64, y int64) int64 {
	return x*y/gcd(x,y)
}

package main

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

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

func main() {
	var ntc int
	fmt.Fscan(in, &ntc)
	for t := 0; t < ntc; t++ {
		var n int
		fmt.Fscan(in, &n)
		var a []int = make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
		}
		sort.Ints(a)
		var ans = 0
		var zero = false
		for i := 0; i < n; i++ {
			if a[i] == 0 {
				zero = true
				continue
			}
			ans++
			if i > 1 {
				if a[i-1] == a[i] && a[i-2] == a[i] {
					ans--
				}
			}
		}
		if zero {
			ans++
		}
		fmt.Fprintf(out, "%d\n", ans)
	}
	out.Flush()
}


While Patrick was gone shopping, Spongebob decided to play a little trick on his friend. The naughty Sponge browsed through Patrick's personal stuff and found a sequence a1, a2, ..., am of length m, consisting of integers from 1 to n, not necessarily distinct. Then he picked some sequence f1, f2, ..., fn of length n and for each number ai got number bi = fai. To finish the prank he erased the initial sequence ai.It's hard to express how sad Patrick was when he returned home from shopping! We will just say that Spongebob immediately got really sorry about what he has done and he is now trying to restore the original sequence. Help him do this or determine that this is impossible.

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 100 000) — the lengths of sequences fi and bi respectively. The second line contains n integers, determining sequence f1, f2, ..., fn (1 ≤ fi ≤ n). The last line contains m integers, determining sequence b1, b2, ..., bm (1 ≤ bi ≤ n).

Print "Possible" if there is exactly one sequence ai, such that bi = fai for all i from 1 to m. Then print m integers a1, a2, ..., am. If there are multiple suitable sequences ai, print "Ambiguity". If Spongebob has made a mistake in his calculations and no suitable sequence ai exists, print "Impossible".

NoteIn the first sample 3 is replaced by 1 and vice versa, while 2 never changes. The answer exists and is unique.In the second sample all numbers are replaced by 1, so it is impossible to unambiguously restore the original sequence.In the third sample fi ≠ 3 for all i, so no sequence ai transforms into such bi and we can say for sure that Spongebob has made a mistake.

package main

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

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

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

type ii struct {
	index, qt int
}

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

    n, m := ReadInt(), ReadInt()

    mapa := make(map[int]*ii)

    for i := 1; i <= n; i++ {
    	val := ReadInt()
    	if _, ok := mapa[val]; ok {
    		mapa[val].index = -1
    		mapa[val].qt++
    	} else {
    		mapa[val] = &ii{i,1}
    	}
    }

    amb := false

    var resp []int

    for i := 1; i <= m; i++ {
    	val := ReadInt()
    	if _, ok := mapa[val]; !ok {
			writer.WriteString("Impossible\n")
			return
    	}

   		if mapa[val].qt == 0 {
   			writer.WriteString("Impossible\n")
			return
   		}

    	if mapa[val].qt > 1 {
    		amb = true
    		mapa[val].qt--
    	} else {
    		resp = append(resp, mapa[val].index)
    	}
    }

    if amb {
		writer.WriteString("Ambiguity\n")
		return
    }

	writer.WriteString("Possible\n")
    for _,elem := range resp {
		writer.WriteString(strconv.Itoa(elem))
		writer.WriteString(" ")
    }
	writer.WriteString("\n")
}


One day Alex decided to remember childhood when computers were not too powerful and lots of people played only default games. Alex enjoyed playing Minesweeper that time. He imagined that he saved world from bombs planted by terrorists, but he rarely won.Alex has grown up since then, so he easily wins the most difficult levels. This quickly bored him, and he thought: what if the computer gave him invalid fields in the childhood and Alex could not win because of it?He needs your help to check it.A Minesweeper field is a rectangle $$$n \times m$$$, where each cell is either empty, or contains a digit from $$$1$$$ to $$$8$$$, or a bomb. The field is valid if for each cell:   if there is a digit $$$k$$$ in the cell, then exactly $$$k$$$ neighboring cells have bombs.  if the cell is empty, then all neighboring cells have no bombs. Two cells are neighbors if they have a common side or a corner (i. e. a cell has at most $$$8$$$ neighboring cells).

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the sizes of the field. The next $$$n$$$ lines contain the description of the field. Each line contains $$$m$$$ characters, each of them is "." (if this cell is empty), "*" (if there is bomb in this cell), or a digit from $$$1$$$ to $$$8$$$, inclusive.

Print "YES", if the field is valid and "NO" otherwise. You can choose the case (lower or upper) for each letter arbitrarily.

NoteIn the second example the answer is "NO" because, if the positions of the bombs are preserved, the first line of the field should be *2*1.You can read more about Minesweeper in Wikipedia's article.

package main

import (
	"fmt"
)

func main() {
	var linesCount int
	var lineLength int
	fmt.Scan(&linesCount)
	fmt.Scan(&lineLength)
	board := make([]string, linesCount)
	for i, _ := range board {
		fmt.Scan(&board[i])
	}
	for i, line := range board {
		for j, ch := range line {
			if ch != '*' {
				var expected int8 = 0
				if ch != '.' {
					expected = int8(ch) - int8('0')
				}
				var actual int8 = 0
				if j > 0 && (line[j - 1] == '*'){
					actual++
				}
				if j < lineLength - 1 && (line[j + 1] == '*'){
					actual++
				}
				if i > 0 {
					if board[i-1][j] == '*' {
						actual++
					}
					if j > 0 && (board[i - 1][j - 1] == '*') {
						actual++
					}
					if j < lineLength - 1 && (board[i - 1][j + 1] == '*') {
						actual++
					}
				}
				if i < linesCount - 1 {
					if board[i+1][j] == '*' {
						actual++
					}
					if j > 0  && (board[i + 1][j - 1] == '*'){
						actual++
					}
					if j < lineLength - 1 && (board[i + 1][j + 1] == '*'){
						actual++
					}
				}
				if actual != expected {
					fmt.Println("NO")
					return
				}
			}
		}
	}
	fmt.Println("YES")
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	var (
		i, j int
		a    = make([][]byte, n)
	)
	for {
		var d byte
		fmt.Scanf("%c", &d)

		if d < 42 || d > 56 {
			continue
		}

		if j == 0 {
			a[i] = make([]byte, m)
		}
		a[i][j] = d

		j++
		if j == m {
			j = 0
			i++
		}

		if i == n {
			break
		}
	}

	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if a[i][j] == 42 {
				continue
			}

			var (
				required byte
				found    byte
			)

			if a[i][j] >= 49 {
				required = a[i][j] - 48
			}

			startI := i-1
			stopI := i+1
			startJ := j-1
			stopJ := j+1

			if i == 0 {
				startI =0
			}

			if stopI >=n {
				stopI = n-1
			}

			if j == 0 {
				startJ =0
			}

			if stopJ >=m {
				stopJ = m-1
			}

			for ci :=startI; ci <= stopI; ci++ {
				for cj :=startJ; cj <= stopJ; cj++ {
					if ci == i && cj == j {
						continue
					}
					if a[ci][cj] == 42 {
						found++
					}
				}
			}

			if found != required {
				fmt.Print("NO")
				return
			}
		}
	}

	fmt.Print("YES")
}

package main

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

func Resolve(input string) string {
	rows := strings.Split(input, "\n")
	n, m := parseFieldSize(rows[0])

	gameField := parseGameField(rows, m)

	for i, row := range gameField {
		for j, cell := range row {
			switch cell {
			case ".":
				bombsFound := findBombsNear(gameField, i, j, n, m)
				if bombsFound != 0 {
					// рядом с пустыми ячейками не может быть бомб
					return "NO"
				}
			case "*":
				break
			default:
				numberOfBombs, err := strconv.Atoi(cell)
				if err != nil {
					panic("got unexpected symbol: " + string(cell) + err.Error())
				}

				if numberOfBombs == 0 {
					continue
				}

				bombsFound := findBombsNear(gameField, i, j, n, m)

				if numberOfBombs != bombsFound {
					return "NO"
				}
			}
		}
	}
	return "YES"
}
func findBombsNear(gameField [][]string, rowIdx, cellIdx, fieldRows, fieldCells int) int {
	var bombsFound int

	for i := rowIdx - 1; i <= rowIdx+1; i++ {
		if i < 0 {
			// вышли за поле
			continue
		}

		for j := cellIdx - 1; j <= cellIdx+1; j++ {
			if j < 0 {
				// вышли за поле
				continue
			}

			if (i == rowIdx) && (j == cellIdx) {
				continue
			}

			// вышли за поле вниз
			if i > fieldRows-1 {
				continue
			}

			// вышли за поле направо
			if j > fieldCells-1 {
				continue
			}

			if gameField[i][j] == "*" {
				bombsFound++
			}
		}

	}

	return bombsFound
}

func parseFieldSize(header string) (int, int) {
	fieldSize := strings.Split(header, " ")

	n, err := strconv.Atoi(fieldSize[0])
	if err != nil {
		panic("can't parse field size N: " + fieldSize[0])
	}

	m, err := strconv.Atoi(fieldSize[1])
	if err != nil {
		panic("can't parse field size M: " + fieldSize[1])
	}

	return n, m
}

func parseGameField(rows []string, cells int) [][]string {
	countOfLines := len(rows) - 1 // минус заголовок
	gameField := make([][]string, countOfLines)

	for i := 1; i < countOfLines; i++ {
		gameField[i-1] = make([]string, cells)
		for j := 0; j < cells; j++ {
			gameField[i-1][j] = string(rows[i][j])
		}
	}

	return gameField
}

func main() {
	var (
		line        string
		overalInput string
		scanner     = bufio.NewScanner(os.Stdin)
	)

	if scanner.Scan() {
		line = scanner.Text()
	}

	rowsCount, _ := parseFieldSize(line)
	overalInput += line + "\n"

	for i := 0; i < rowsCount; i++ {
		if scanner.Scan() {
			line = scanner.Text()
		}
		overalInput += line + "\n"
	}

	fmt.Println(Resolve(overalInput))
}

package main

import "fmt"

type T struct {
  code uint8
  nBombs int
}

var (
  n int
  m int
  b byte
  field [100][100]T
)

func Check(i int, j int)bool {
  num:=0;
  if (i-1 >= 0) && (field[i-1][j].code == 0) { num++ }
  if (i+1 < n) && (field[i+1][j].code == 0) { num++ }
  if (j-1 >= 0) && (field[i][j-1].code == 0) { num++ }
  if (j+1 < m) && (field[i][j+1].code == 0) { num++ }
  if ((i-1 >= 0) && (j-1 >= 0)) && (field[i-1][j-1].code == 0) { num++ }
  if ((i+1 < n) && (j-1 >= 0)) && (field[i+1][j-1].code == 0) { num++ }
  if ((i-1 >= 0) && (j+1 < m)) && (field[i-1][j+1].code == 0) { num++ }
  if ((i+1 < n) && (j+1 < m)) && (field[i+1][j+1].code == 0) { num++ }
  return (num == field[i][j].nBombs)
}

func main() {
  s:=""
  fmt.Scanln(&n, &m)
  for i:=0; i < n; i++ {
    fmt.Scanln(&s)
    for j:=0; j < m; j++ {
      if s[j] == '*' {
        field[i][j].code = 0
        field[i][j].nBombs = 99
      } else {
        if s[j] == '.' {
          field[i][j].code = 2
          field[i][j].nBombs = 0
        } else {
          field[i][j].code = 2
          field[i][j].nBombs = int(s[j]) - 48
        }
      }
    }
  }
  f:=true;
  for i:=0; i < n; i++ {
    for j:=0; j < m; j++ {
      if field[i][j].code == 2 {
        f=Check(i,j);
        if !f { break }
      }
    }
    if !f { break }
  }
  if f { fmt.Println("YES")} else {fmt.Println("NO")}
}

// Codeforces 978 F done
package main

import (
	"bufio"
	"fmt"
	"strings"
	"strconv"
	"os"
)
var in *bufio.Reader

func readFive() (int,int,int,int,int) {
	var a [5]int
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for i:=0; i<len(ss); i++ {
		a[i], err = strconv.Atoi(ss[i])
		if err != nil {
			fmt.Println("n atoi failure", err)
			panic(err)
		}
	}
	return a[0],a[1],a[2],a[3],a[4]
}

func readLineNumbs(n int) []int {
	a := make([]int, n)
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for j:=0; j<n; j++ {
		aa,err := strconv.Atoi(ss[j])
		if err != nil {
			fmt.Println("aa conv failed", err)
			panic(err)
		}
		a[j] = aa
	}
	return a
}

var n,m int
var f []string
var valid bool

func readData() {
	in = bufio.NewReader(os.Stdin)
	// reading n, k
	n, m, _, _, _ = readFive()
	// reading f
	f = make([]string, n)
	for i:=0; i<n; i++ {
		f[i],_ = in.ReadString('\n')
	}
}

func starCount(i,j int) int {
	cnt := 0
	for di:=-1; di<=1; di++ {
		for dj:=-1; dj<=1; dj++ {
			ii := i+di
			jj := j+dj
			if ii>=0 && ii<n && jj>=0 && jj<m {
				c := (f[ii])[jj]
				isStar := c=='*'
				// fmt.Printf("c,isStar = %c %t\n", c, isStar)
				if isStar {
					cnt++
				}
			}
		}
	}
	return cnt
}

func solve() {
	valid = true
	for i:=0; i<n; i++ {
		for j:=0; j<m; j++ {
			c := f[i][j]
			if c=='*' {
				continue
			}
			cnt := starCount(i, j)
			ccnt := 0
			if '1'<=c && c<='8' {
				ccnt = int(c) - int('0')
			} else if c=='.' {
				ccnt = 0
			} else {
				fmt.Printf("Illegal character %c\n", c)
			}
			if cnt != ccnt {
				// fmt.Printf("Difference. i,j = %d %d  cnt,ccnt = %d %d\n",i,j,cnt,ccnt)
				valid = false
				return
			}
		}
	}
}

func printRes() {
	var ans string
	if valid {
		ans = "Yes"
	} else {
		ans = "No"
	}
	fmt.Println(ans)
}

func main() {
	readData()
	solve()
	printRes()
}

package main;

import (
	"fmt"
)

func main() {
	var my = [...]int{-1, -1, -1, 0, 0, 1, 1, 1};
	var mx = [...]int{-1, 0, 1, -1, 1, -1, 0, 1};

	var n int;
	var m int;

	fmt.Scan(&n);
	fmt.Scan(&m);

	board := make([]string, n);

	for i, _ := range board {
		fmt.Scan(&board[i]);
	}

	var flag bool = true;

	for i, line := range board {
		for j, ch := range line {
			if ch != '*' {
				var num = -1;
				if ch == '.' {
					num = 0;
				} else {
					num = int(ch) - int('0')
				}

				cnt := 0;
				for k := 0; k < 8; k++ {
					ny := i + my[k];
					nx := j + mx[k];

					if ny < 0 || ny >= n || nx < 0 || nx >= m {
						continue;
					}

					if board[ny][nx] == '*' {
						cnt++;
					}
				}
				// fmt.Println(i, j, cnt, num);
				if cnt != num {
					flag = false;
				}
			}
		}
	}

	if flag {
		fmt.Println("YES");
	} else {
		fmt.Println("NO");
	}
}

package main

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

func main() {
	var (
		err        error
		input, row string
	)

	inputReader := bufio.NewReader(os.Stdin)

	for err != io.EOF {
		row, err = inputReader.ReadString('\n')
		input += row
	}

	fmt.Print(Solve(input))
}

func Solve(input string) string {
	sourceMx, rows, columns := ParseMatrix(input)

	expectedMx := make([][]byte, rows)

	for i := int64(0); i < rows; i++ {
		expectedMx[i] = make([]byte, columns)

		for j := int64(0); j < columns; j++ {
			expectedMx[i][j] = '.'
		}
	}

	CalculateSaper(rows, columns, sourceMx, expectedMx)

	if MatrixEquals(rows, columns, sourceMx, expectedMx) {
		return "YES"
	}

	return "NO"
}

func CalculateSaper(rows int64, columns int64, sourceMx [][]byte, expectedMx [][]byte) {
	for r := int64(0); r < rows; r++ {
		for c := int64(0); c < columns; c++ {
			if sourceMx[r][c] == '*' {
				for er := r - 1; er <= r+1; er++ {
					for ec := c - 1; ec <= c+1; ec++ {
						if er < 0 || er >= rows {
							continue
						}

						if ec < 0 || ec >= columns {
							continue
						}

						if er == r && ec == c {
							expectedMx[er][ec] = '*'
							continue
						}

						if expectedMx[er][ec] == '.' {
							expectedMx[er][ec] = '0'
						}

						if expectedMx[er][ec] != '*' {
							expectedMx[er][ec]++
						}
					}
				}
			}
		}
	}
}

func ParseMatrix(input string) (mx [][]byte, rows int64, columns int64) {
	inputReader := bufio.NewReader(bytes.NewBufferString(input))
	row, _ := inputReader.ReadString('\n')
	fmt.Sscanf(row, "%d %d", &rows, &columns)

	mx = make([][]byte, rows)

	for n := int64(0); n < rows; n++ {
		row, _ := inputReader.ReadString('\n')

		mx[n] = make([]byte, columns)

		for m := int64(0); m < columns; m++ {
			mx[n][m] = row[m]
		}
	}

	return
}

func MatrixEquals(rows int64, columns int64, left, right [][]byte) bool {
	for r := int64(0); r < rows; r++ {
		for c := int64(0); c < columns; c++ {
			if left[r][c] != right[r][c] {
				return false
			}
		}
	}

	return true
}

package main

import (
	"fmt"
	"strconv"
)

func emptyMatrix(r,c int) [][]int{
	__ := make([][]int, r)
	for i := 0; i < r; i++{
		 __[i] = make([]int,c)
	}
	return __
}

func neighBombs(mapp [][]int, loc [2]int) int {
	n_bombs := 0
	neighbours := [][]int{
		{loc[0]-1, loc[1]-1},
		{loc[0]-1, loc[1]},
		{loc[0]-1, loc[1]+1},
		{loc[0], loc[1]-1},
		{loc[0], loc[1]+1},
		{loc[0]+1, loc[1]-1},
		{loc[0]+1, loc[1]},
		{loc[0]+1, loc[1]+1},
	}
	for _, path := range neighbours{
		if (0 <= path[0]) && (path[0] < len(mapp)) && (0 <= path[1]) && (path[1] < len(mapp[0])){
			if mapp[path[0]][path[1]] == -1 {
				n_bombs+=1
			}
		}
	}
	return n_bombs
}

func main() {
	var r,c,temp_digit int
	var ln string
	fmt.Scanln(&r,&c)
	mapp := emptyMatrix(r,c)
	for i := 0;i < r; i++ {
		fmt.Scanln(&ln)
		for j := 0; j < c;j++ {
			if ln[j] == '.'{
				mapp[i][j] = 0
				continue
			}
			if ln[j] == '*' {
				mapp[i][j] = -1
				continue
			}
			temp_digit,_ = strconv.Atoi(string(ln[j]))
			mapp[i][j] = temp_digit
		}
	}
	for rows := 0; rows < len(mapp); rows++{
		for col := 0; col < len(mapp[0]); col++{
			if mapp[rows][col] != neighBombs(mapp, [2]int{rows,col}) && mapp[rows][col] != -1 {
				fmt.Print("NO")
				return
			}
		}
	}
	fmt.Print("YES")
}

package main;

import (
	"fmt"
)

func main() {
	var my = [...]int{-1, -1, -1, 0, 0, 1, 1, 1};
	var mx = [...]int{-1, 0, 1, -1, 1, -1, 0, 1};

	var n int;
	var m int;

	fmt.Scan(&n);
	fmt.Scan(&m);

	board := make([]string, n);

	for i, _ := range board {
		fmt.Scan(&board[i]);
	}

	var flag bool = true;

	for i, line := range board {
		for j, ch := range line {
			if ch != '*' {
				var num = -1;
				if ch == '.' {
					num = 0;
				} else {
					num = int(ch) - int('0')
				}

				cnt := 0;
				for k := 0; k < 8; k++ {
					ny := i + my[k];
					nx := j + mx[k];

					if ny < 0 || ny >= n || nx <= 0 || nx >= m {
						continue;
					}

					if board[ny][nx] == '*' {
						cnt++;
					}
				}
				// fmt.Println(i, j, cnt, num);
				if cnt != num {
					flag = false;
				}
			}
		}
	}

	if flag {
		fmt.Println("YES");
	} else {
		fmt.Println("NO");
	}
}


A bitstring is a string that contains only the characters 0 and 1.Koyomi Kanou is working hard towards her dream of becoming a writer. To practice, she decided to participate in the Binary Novel Writing Contest. The writing prompt for the contest consists of three bitstrings of length $$$2n$$$. A valid novel for the contest is a bitstring of length at most $$$3n$$$ that contains at least two of the three given strings as subsequences.Koyomi has just received the three prompt strings from the contest organizers. Help her write a valid novel for the contest.A string $$$a$$$ is a subsequence of a string $$$b$$$ if $$$a$$$ can be obtained from $$$b$$$ by deletion of several (possibly, zero) characters.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$). Each of the following three lines contains a bitstring of length $$$2n$$$. It is guaranteed that these three strings are pairwise distinct. It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$10^5$$$.

For each test case, print a single line containing a bitstring of length at most $$$3n$$$ that has at least two of the given bitstrings as subsequences. It can be proven that under the constraints of the problem, such a bitstring always exists. If there are multiple possible answers, you may output any of them.

NoteIn the first test case, the bitstrings 00 and 01 are subsequences of the output string: 010 and 010. Note that 11 is not a subsequence of the output string, but this is not required.In the second test case all three input strings are subsequences of the output string: 011001010, 011001010 and 011001010.

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var buf bytes.Buffer
	tc := readNum(reader)
	for tc > 0 {
		tc--
		n := readNum(reader)
		A, _ := reader.ReadString('\n')
		B, _ := reader.ReadString('\n')
		C, _ := reader.ReadString('\n')
		res := solve(n, A, B, C)
		buf.WriteString(res)
		buf.WriteByte('\n')
	}
	fmt.Print(buf.String())
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, A, B, C string) string {
	v0 := make([]string, 0, 2)
	v1 := make([]string, 0, 2)
	if label(n, A) {
		v0 = append(v0, A)
	} else {
		v1 = append(v1, A)
	}
	if label(n, B) {
		v0 = append(v0, B)
	} else {
		v1 = append(v1, B)
	}
	if label(n, C) {
		v0 = append(v0, C)
	} else {
		v1 = append(v1, C)
	}

	if len(v0) > 1 {
		return mix(n, v0[0], v0[1], '0')
	}
	return mix(n, v1[0], v1[1], '1')
}

func mix(n int, a, b string, c byte) string {
	v1 := make([]int, 0, n)
	v2 := make([]int, 0, n)
	v1 = append(v1, -1)
	v2 = append(v2, -1)

	for i := 0; i < 2*n; i++ {
		if a[i] == c {
			v1 = append(v1, i)
		}
		if b[i] == c {
			v2 = append(v2, i)
		}
	}

	var res bytes.Buffer

	for i := 0; i < n; i++ {
		for j := v1[i] + 1; j < v1[i+1]; j++ {
			res.WriteByte(a[j])
		}
		for j := v2[i] + 1; j < v2[i+1]; j++ {
			res.WriteByte(b[j])
		}
		res.WriteByte(c)
	}

	for j := v1[n] + 1; j < 2*n; j++ {
		res.WriteByte(a[j])
	}
	for j := v2[n] + 1; j < 2*n; j++ {
		res.WriteByte(b[j])
	}

	return res.String()
}

func label(n int, s string) bool {
	var cnt0 int
	for i := 0; i < 2*n; i++ {
		if s[i] == '0' {
			cnt0++
		}
	}
	return cnt0 >= n
}

func solve1(n int, A, B, C string) string {
	var p1, p2, p3 int
	var buf bytes.Buffer

	N := 2 * n
	for p1 < N && p2 < N && p3 < N {
		if A[p1] == B[p2] {
			buf.WriteByte(A[p1])
			p1++
			p2++
		} else if A[p1] == C[p3] {
			buf.WriteByte(A[p1])
			p1++
			p3++
		} else {
			// B[p2] == C[p3]
			buf.WriteByte(B[p2])
			p2++
			p3++
		}
	}
	l := buf.Len() - n
	if p1 == N {
		if p2 >= l {
			buf.WriteString(B[p2:N])
		} else {
			buf.WriteString(C[p3:N])
		}
	} else if p2 == N {
		if p1 >= l {
			buf.WriteString(A[p1:N])
		} else {
			buf.WriteString(C[p3:N])
		}
	} else {
		// p3 == N
		if p1 >= l {
			buf.WriteString(A[p1:N])
		} else {
			buf.WriteString(B[p2:N])
		}
	}

	return buf.String()
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var buf bytes.Buffer
	tc := readNum(reader)
	for tc > 0 {
		tc--
		n := readNum(reader)
		A, _ := reader.ReadString('\n')
		B, _ := reader.ReadString('\n')
		C, _ := reader.ReadString('\n')
		res := solve(n, A, B, C)
		buf.WriteString(res)
		buf.WriteByte('\n')
	}
	fmt.Print(buf.String())
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, A, B, C string) string {
	var p1, p2, p3 int
	var buf bytes.Buffer

	N := 2 * n
	for p1 < N && p2 < N && p3 < N {
		if A[p1] == B[p2] {
			buf.WriteByte(A[p1])
			p1++
			p2++
		} else if A[p1] == C[p3] {
			buf.WriteByte(A[p1])
			p1++
			p3++
		} else {
			// B[p2] == C[p3]
			buf.WriteByte(B[p2])
			p2++
			p3++
		}
	}
	l := buf.Len() - n
	if p1 == N {
		if p2 >= l {
			buf.WriteString(B[p2:N])
		} else {
			buf.WriteString(C[p3:N])
		}
	} else if p2 == N {
		if p1 >= l {
			buf.WriteString(A[p1:N])
		} else {
			buf.WriteString(C[p3:N])
		}
	} else {
		// p3 == N
		if p1 >= l {
			buf.WriteString(A[p1:N])
		} else {
			buf.WriteString(B[p2:N])
		}
	}

	return buf.String()
}

package main

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

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

	var T, n int
	var a, b, c string
	var s []byte
	f := func(a, b string) {
		c0 := strings.Count(a, "0")
		if c0 >= n != (strings.Count(b, "0") >= n) {
			return
		}
		tar := byte('0')
		if c0 < n {
			tar = '1'
		}
		s = nil
		i, j := 0, 0
		for i < 2*n && j < 2*n {
			if a[i] == b[j] {
				s = append(s, a[i])
				i++
				j++
			} else if a[i] != tar {
				s = append(s, a[i])
				i++
			} else {
				s = append(s, b[j])
				j++
			}
		}
		s = append(s, a[i:]...)
		s = append(s, b[j:]...)
	}
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &a, &b, &c)
		f(a, b)
		f(a, c)
		f(b, c)
		Fprintln(out, string(s))
	}
}
func main() { CF1508A(os.Stdin, os.Stdout) }

package main

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

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 int
		fmt.Fscan(in, &n)
		v := make([]string, 3)
		at := make([][]int, 2)
		for i := 0; i < 3; i++ {
			fmt.Fscan(in, &v[i])
			count := 0
			for _, c := range v[i] {
				if c == '1' {
					count++
				}
			}
			idx := 0
			if count >= n {
				idx = 1
			}
			at[idx] = append(at[idx], i)
		}
		idx := 0
		if len(at[0]) < 2 {
			idx = 1
		}
		w := &strings.Builder{}
		i, j := 0, 0
		x := '0'
		if idx == 1 {
			x = '1'
		}
		for i < len(v[at[idx][0]]) && j < len(v[at[idx][1]]) {
			if v[at[idx][0]][i] == v[at[idx][1]][j] {
				w.WriteByte(v[at[idx][0]][i])
				i++
				j++
			}else {
				if rune(v[at[idx][1]][j]) != x {
					w.WriteByte(v[at[idx][1]][j])
					j++
				}else {
					w.WriteByte(v[at[idx][0]][i])
					i++
				}
			}
		}
		w.WriteString(v[at[idx][0]][i:])
		w.WriteString(v[at[idx][1]][j:])
		fmt.Fprintln(out, w.String())
	}
}

package main

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

func main() {

	/*rand.Seed(time.Now().Unix())

	str := "01"

	for k := 0; k < 1000; k++ {
		var bts bytes.Buffer
		for j := 0; j < 10; j++ {
			idx := rand.Intn(2)
			b := str[idx]
			bts.WriteByte(b)
		}
		aa := bts.String()

		bts = bytes.Buffer{}
		for j := 0; j < 10; j++ {
			idx := rand.Intn(2)
			b := str[idx]
			bts.WriteByte(b)
		}
		bb := bts.String()

		bts = bytes.Buffer{}
		for j := 0; j < 10; j++ {
			idx := rand.Intn(2)
			b := str[idx]
			bts.WriteByte(b)
		}
		cc := bts.String()

		ans := solve(aa, bb, cc, 5)

		var count int

		if len(ans) > 15 {
			panic("Incorrect len " + strconv.Itoa(len(ans)))
		}

		idx := 0
		for j := 0; j < len(ans); j++ {
			a := ans[j]

			if a == aa[idx] {
				idx++

				if idx >= 10 {
					count++
					break
				}
			}
		}

		idx = 0
		for j := 0; j < len(ans); j++ {
			a := ans[j]

			if a == bb[idx] {
				idx++

				if idx >= 10 {
					count++
					break
				}
			}
		}

		idx = 0
		for j := 0; j < len(ans); j++ {
			a := ans[j]

			if a == cc[idx] {
				idx++

				if idx >= 10 {
					count++
					break
				}
			}
		}

		if count < 2 {
			fmt.Println(aa)
			fmt.Println(bb)
			fmt.Println(cc)
			fmt.Println(ans)
			panic("Count less then two")
		}

	}*/

	r := bufio.NewReader(os.Stdin)

	var t int

	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		var n int

		fmt.Fscan(r, &n)

		var a, b, c string
		fmt.Fscan(r, &a)
		fmt.Fscan(r, &b)
		fmt.Fscan(r, &c)

		ans := solve(a, b, c, n)

		fmt.Println(ans)
	}
}

func solve(a, b, c string, n int) string {
	n = 2 * n

	var ans bytes.Buffer

	var aZer int
	var aOne int

	for i:= 0; i < n; i++ {
		if a[i] == '0' {
			aZer++
		} else if a[i] == '1' {
			aOne++
		} else {
			panic("unknown" + string(a[i]))
		}
	}

	var bZer int
	var bOne int

	for i:= 0; i < n; i++ {
		if b[i] == '0' {
			bZer++
		} else if b[i] == '1' {
			bOne++
		} else {
			panic("unknown" + string(b[i]))
		}
	}

	var cZer int
	var cOne int

	for i:= 0; i < n; i++ {
		if c[i] == '0' {
			cZer++
		} else if c[i] == '1' {
			cOne++
		} else {
			panic("unknown" + string(c[i]))
		}
	}

	first, second, char := getTwo(a, b, c, aZer, aOne, bZer, bOne, cZer, cOne)

	opposite := getOpposite(char)

	key := 0
	mp := make(map[int]int)

	for  i := 0; i < n; i++ {
		if second[i] == opposite {
			mp[key]++
		} else {
			key++
		}
	}

	key = 0

	for i := 0; i < n; i++ {
		f := first[i]

		if f == char {
			n := mp[key]

			for j := 0; j < n; j++ {
				ans.WriteByte(opposite)
			}

			ans.WriteByte(f)
			key++

		} else {
			ans.WriteByte(f)
		}
	}

	if v , ok := mp[key]; ok {

		for j := 0; j < v; j++ {
			ans.WriteByte(opposite)
		}
	}

	return ans.String()
}

func getOpposite(c byte) byte {
	if c == '1' {
		return '0'
	} else if c == '0' {
		return '1'
	}
	panic("unknown" + string(c))
}

func getTwo(a, b, c string, aZer, aOne, bZer, bOne, cZer, cOne int) (string, string, byte) {
	if aZer >= aOne {
		if bZer >= bOne {
			//todo take a b 0
			if aZer >= bZer {
				return a, b, '0'
			} else {
				return b, a, '0'
			}

		} else {

			if cZer >= cOne {
				if aZer >= cZer {
					return a, c, '0'
				} else {
					return c, a, '0'
				}
				//todo take a c 0

			} else {
				if bOne >= cOne {
					return b, c, '1'
				} else {
					return c, b, '1'
				}
				//todo take b c 1
			}
		}

	} else {
		if bZer >= bOne {

			if cZer >= cOne {
				if bZer >= cZer {
					return b, c, '0'
				} else {
					return c, b, '0'
				}
				//todo take b, c 0

			} else {
				if aOne >= cOne {
					return a, c, '1'
				} else {
					return c, a, '1'
				}
				//todo take a, c 1

			}
		} else {
			if aOne >= bOne {
				return a, b, '1'
			} else {
				return b, a, '1'
			}
			//todo take a, b 1
		}
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var buf bytes.Buffer
	tc := readNum(reader)
	for tc > 0 {
		tc--
		n := readNum(reader)
		A, _ := reader.ReadString('\n')
		B, _ := reader.ReadString('\n')
		C, _ := reader.ReadString('\n')
		res := solve(n, A, B, C)
		buf.WriteString(res)
		buf.WriteByte('\n')
	}
	fmt.Print(buf.String())
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, A, B, C string) string {
	var p1, p2, p3 int
	var buf bytes.Buffer

	N := 2 * n
	for p1 < N && p2 < N && p3 < N {
		if A[p1] == B[p2] {
			buf.WriteByte(A[p1])
			p1++
			p2++
		} else if A[p1] == C[p3] {
			buf.WriteByte(A[p1])
			p1++
			p3++
		} else {
			// B[p2] == C[p3]
			buf.WriteByte(B[p2])
			p2++
			p3++
		}
	}
	l := (N - buf.Len()) / 2
	if p1 == N {
		if p2 >= l {
			buf.WriteString(B[p2:N])
		} else {
			buf.WriteString(C[p3:N])
		}
	} else if p2 == N {
		if p1 >= l {
			buf.WriteString(A[p1:N])
		} else {
			buf.WriteString(C[p3:N])
		}
	} else {
		// p3 == N
		if p1 >= l {
			buf.WriteString(A[p1:N])
		} else {
			buf.WriteString(B[p2:N])
		}
	}

	return buf.String()
}

package main

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

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 int
		fmt.Fscan(in, &n)
		v := make([]string, 3)
		at := make([][]int, 2)
		for i := 0; i < 3; i++ {
			fmt.Fscan(in, &v[i])
			count := 0
			for _, c := range v[i] {
				if c == '1' {
					count++
				}
			}
			idx := 0
			if count > n {
				idx = 1
			}
			at[idx] = append(at[idx], i)
		}
		idx := 0
		if len(at[0]) < 2 {
			idx = 1
		}
		w := &strings.Builder{}
		i, j := 0, 0
		x := '0'
		if idx == 1 {
			x = '1'
		}
		for i < len(v[at[idx][0]]) && j < len(v[at[idx][1]]) {
			if v[at[idx][0]][i] == v[at[idx][1]][j] {
				w.WriteByte(v[at[idx][0]][i])
				i++
				j++
			}else {
				w.WriteByte(v[at[idx][0]][i])
				i++
				if rune(v[at[idx][1]][j]) != x {
					w.WriteByte(v[at[idx][1]][j])
					j++
				}
			}
		}
		w.WriteString(v[at[idx][0]][i:])
		w.WriteString(v[at[idx][1]][j:])
		fmt.Fprintln(out, w.String())
	}
}

package main

import (
	"bufio"
	"os"

	"fmt"
	"bytes"
)

func main() {

	r := bufio.NewReader(os.Stdin)

	var t int

	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		var n int

		fmt.Fscan(r, &n)

		var a, b, c string
		fmt.Fscan(r, &a)
		fmt.Fscan(r, &b)
		fmt.Fscan(r, &c)

		ans := solve(a, b, c, n)

		fmt.Println(ans)
	}
}

func solve(a, b, c string, n int) string {
	n = 2 * n

	var ans bytes.Buffer

	var aZer int
	var aOne int

	for i:= 0; i < n; i++ {
		if a[i] == '0' {
			aZer++
		} else if a[i] == '1' {
			aOne++
		} else {
			panic("unknown" + string(a[i]))
		}
	}

	var bZer int
	var bOne int

	for i:= 0; i < n; i++ {
		if b[i] == '0' {
			bZer++
		} else if b[i] == '1' {
			bOne++
		} else {
			panic("unknown" + string(b[i]))
		}
	}

	var cZer int
	var cOne int

	for i:= 0; i < n; i++ {
		if c[i] == '0' {
			cZer++
		} else if c[i] == '1' {
			cOne++
		} else {
			panic("unknown" + string(c[i]))
		}
	}

	first, second, char := getTwo(a, b, c, aZer, aOne, bZer, bOne, cZer, cOne)

	opposite := getOpposite(char)

	key := 0
	mp := make(map[int]int)

	for  i := 0; i < n; i++ {
		if second[i] == opposite {
			mp[key]++
		} else {
			key++
		}
	}

	key = 0

	for i := 0; i < n; i++ {
		f := first[i]

		if f == char {
			n := mp[key]

			for j := 0; j < n; j++ {
				ans.WriteByte(opposite)

			}

			ans.WriteByte(f)
			key++

		} else {
			ans.WriteByte(f)
		}
	}

	return ans.String()
}

func getOpposite(c byte) byte {
	if c == '1' {
		return '0'
	} else if c == '0' {
		return '1'
	}
	panic("unknown" + string(c))
}

func getTwo(a, b, c string, aZer, aOne, bZer, bOne, cZer, cOne int) (string, string, byte) {
	if aZer >= aOne {
		if bZer >= bOne {
			//todo take a b 0
			if aZer >= bZer {
				return a, b, '0'
			} else {
				return b, a, '0'
			}

		} else {

			if cZer >= cOne {
				if aZer >= cZer {
					return a, c, '0'
				} else {
					return c, a, '0'
				}
				//todo take a c 0

			} else {
				if bOne >= cOne {
					return b, c, '1'
				} else {
					return c, b, '1'
				}
				//todo take b c 1
			}
		}

	} else {
		if bZer >= bOne {

			if cZer >= cOne {
				if bZer >= cZer {
					return b, c, '0'
				} else {
					return c, b, '0'
				}
				//todo take b, c 0

			} else {
				if aOne >= bOne {
					return a, c, '1'
				} else {
					return c, a, '1'
				}
				//todo take a, c 1

			}
		} else {
			if aOne >= bOne {
				return a, b, '1'
			} else {
				return b, a, '1'
			}
			//todo take a, b 1
		}
	}
}

package main

import (
	"bufio"
	"os"

	"fmt"
	"bytes"
)

func main() {

	r := bufio.NewReader(os.Stdin)

	var t int

	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		var n int

		fmt.Fscan(r, &n)

		var a, b, c string
		fmt.Fscan(r, &a)
		fmt.Fscan(r, &b)
		fmt.Fscan(r, &c)

		ans := solve(a, b, c, n)

		fmt.Println(ans)
	}
}

func solve(a, b, c string, n int) string {

	n = 2 * n

	diff := make([]bool, len(a))

	for i := 0 ; i < len(a); i++ {
		if a [i] != b[i] {
			diff[i] = true
		}
	}

	var aCount int
	var bCount int

	for i := 0; i < n; i++ {
		if diff[i] == true {
			if a[i] == c[i] {
				aCount++
			} else {
				bCount++
			}
		}
	}

	var ans bytes.Buffer

	if aCount > bCount {

		for i := 0; i < n; i++ {
			if diff[i] == true  {
				ans.WriteRune(rune(a[i]))
				ans.WriteRune(rune(c[i]))
			} else {
				ans.WriteRune(rune(a[i]))
			}
		}

	} else {
		for i := 0; i < n; i++ {
			if diff[i] == true  {
				ans.WriteRune(rune(b[i]))
				ans.WriteRune(rune(c[i]))
			} else {
				ans.WriteRune(rune(b[i]))
			}
		}
	}

	return ans.String()
}