A binary string is a string that consists of characters $$$0$$$ and $$$1$$$.Let $$$\operatorname{MEX}$$$ of a binary string be the smallest digit among $$$0$$$, $$$1$$$, or $$$2$$$ that does not occur in the string. For example, $$$\operatorname{MEX}$$$ of $$$001011$$$ is $$$2$$$, because $$$0$$$ and $$$1$$$ occur in the string at least once, $$$\operatorname{MEX}$$$ of $$$1111$$$ is $$$0$$$, because $$$0$$$ and $$$2$$$ do not occur in the string and $$$0 < 2$$$.A binary string $$$s$$$ is given. You should cut it into any number of substrings such that each character is in exactly one substring. It is possible to cut the string into a single substring — the whole string.A string $$$a$$$ is a substring of a string $$$b$$$ if $$$a$$$ can be obtained from $$$b$$$ by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.What is the minimal sum of $$$\operatorname{MEX}$$$ of all substrings pieces can be?

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Description of the test cases follows. Each test case contains a single binary string $$$s$$$ ($$$1 \le |s| \le 10^5$$$). It's guaranteed that the sum of lengths of $$$s$$$ over all test cases does not exceed $$$10^5$$$.

For each test case print a single integer — the minimal sum of $$$\operatorname{MEX}$$$ of all substrings that it is possible to get by cutting $$$s$$$ optimally.

NoteIn the first test case the minimal sum is $$$\operatorname{MEX}(0) + \operatorname{MEX}(1) = 1 + 0 = 1$$$.In the second test case the minimal sum is $$$\operatorname{MEX}(1111) = 0$$$.In the third test case the minimal sum is $$$\operatorname{MEX}(01100) = 2$$$.

package main

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

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

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

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

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

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

/**
Run solve the problem CF1566B
Date: 29/04/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1566/B
Problem: CF1566B
**/
func (in *CF1566B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		str := in.NextString()
		ones := 0
		zeros := 0
		blocksZeros := 0
		tmp := 0
		for i := 0; i < len(str); i++ {
			if str[i] == '0' {
				zeros++
				tmp++
			} else {
				if tmp > 0 {
					blocksZeros++
					tmp = 0
				}
				ones++
			}
		}
		if tmp > 0 {
			blocksZeros++
			tmp = 0
		}

		if zeros == 0 {
			fmt.Println(0)
		} else if ones == 0 {
			fmt.Println(1)
		} else {

			if blocksZeros > 2 {
				fmt.Println(2)
			} else {
				fmt.Println(blocksZeros)
			}

		}

	}
}

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

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

package main

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

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

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

func solve() {
	var s string
	scan(&s)
	zero := 0
	lastZero := -1
	for i, c := range s {
		if c == '0' {
			if lastZero == -1 || i-lastZero > 1 {
				zero++
			}
			lastZero = i
		}
	}
	ans := 2
	if zero == 0 {
		ans = 0
	} else {
		if ans > zero {
			ans = zero
		}
	}
	printf("%d\n", ans)
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

import "fmt"

func main() {
	var str string
	var n int
	fmt.Scan(&n)
	for n != 0 {
		fmt.Scan(&str)
		num := len(str)
		ans := 0
		flag := byte('a')
		for i := 0; i < num; i++ {
			if flag == byte('a') {
				if str[i] == '0' {
					ans++
					flag = '0'
				} else {
					flag = '1'
				}
			} else {
				if str[i] == flag {
					continue
				} else {
					if str[i] == '0' {
						ans++
						flag = '0'
					} else {
						flag = '1'
					}
				}
			}

		}
		if ans > 2 {
			ans = 2
		}
		fmt.Println(ans)

		n--
	}

}

package main

import (
	"fmt"
	"os"
)

func findZeros(b []byte) int {
	prev := byte('#')
	n := 0
	for _, c := range b {
		if c != prev && c == '0' {
			n++
		}
		prev = c
	}
	return n
}

func testit() {
	var s string
	fmt.Fscanln(os.Stdin, &s)
	b := []byte(s)
	n := findZeros(b)
	if n > 1 {
		fmt.Println(2)
	} else if n == 1 {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}

func main() {
	var nTests uint32
	fmt.Fscanln(os.Stdin, &nTests)
	for nTests > 0 {
		testit()
		nTests--
	}
}

package main

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

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

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)
	for o := 0; o < t; o++ {

		STRING := make([]byte, 0)
		fmt.Fscan(input, &STRING)

		var Zero, One int

		q := len(STRING)
		for i := 0; i < q-1; i++ {
			if string(STRING[i]) == "0" && string(STRING[i+1]) == "1" {
				Zero++
			}
			if string(STRING[i]) == "1" {
				One++
			}
		}
		if string(STRING[q-1]) == "0" {

			Zero++

		}

		if Zero > 2 {
			fmt.Println(2)
		} else {
			fmt.Println(Zero)
		}

	}
}

package main

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

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 s string
		fmt.Fscanf(r, "%s\n", &s)

		c := [2]int{}
		for i := 0; i < len(s); i++ {
			c[s[i]-'0']++
		}

		if c[0] == 0 {
			fmt.Println("0")
		} else {
			lz := -1
			can := true
			for i := 0; i < len(s); i++ {
				if s[i] == '0' {
					if i-lz > 1 && lz != -1 {
						can = false
						break
					}
					lz = i
				}
			}

			if can {
				fmt.Println("1")
			} else {
				fmt.Println("2")
			}
		}
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1566B
Date: 29/04/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1566/B
Problem: CF1566B
**/
func (in *CF1566B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		str := in.NextString()
		ones := 0
		zeros := 0
		for i := 0; i < len(str); i++ {
			if str[i] == '0' {
				zeros++
			} else {
				ones++
			}
		}
		if zeros == 0 {
			fmt.Println(0)
		} else if ones == 0 {
			fmt.Println(1)
		} else {

			if zeros > 2 {
				fmt.Println(2)
			} else {
				fmt.Println(zeros)
			}

		}

	}
}

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

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


You are given array ai of length n. You may consecutively apply two operations to this array:  remove some subsegment (continuous subsequence) of length m < n and pay for it m·a coins;  change some elements of the array by at most 1, and pay b coins for each change. Please note that each of operations may be applied at most once (and may be not applied at all) so you can remove only one segment and each number may be changed (increased or decreased) by at most 1. Also note, that you are not allowed to delete the whole array.Your goal is to calculate the minimum number of coins that you need to spend in order to make the greatest common divisor of the elements of the resulting array be greater than 1.

The first line of the input contains integers n, a and b (1 ≤ n ≤ 1 000 000, 0 ≤ a, b ≤ 109) — the length of the array, the cost of removing a single element in the first operation and the cost of changing an element, respectively. The second line contains n integers ai (2 ≤ ai ≤ 109) — elements of the array.

Print a single number — the minimum cost of changes needed to obtain an array, such that the greatest common divisor of all its elements is greater than 1.

NoteIn the first sample the optimal way is to remove number 3 and pay 1 coin for it.In the second sample you need to remove a segment [17, 13] and then decrease number 6. The cost of these changes is equal to 2·3 + 2 = 8 coins.

package main

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

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

var A, B int64
var a []int

func main() {
	defer out.Flush()
	var N int
	fmt.Fscan(in, &N, &A, &B)
	a = make([]int, N)
	for i := range a {
		fmt.Fscan(in, &a[i])
	}

	ds := map[int]bool{}
	for _, i := range []int{a[0] - 1, a[0], a[0] + 1, a[N-1] - 1, a[N-1], a[N-1] + 1} {
		for _, d := range primeDivisors(i) {
			ds[d] = true
		}
	}

	ans := int64(impossible)
	for d, _ := range ds {
		dp := make([][]int64, 2)
		for i := range dp {
			dp[i] = make([]int64, 2)
		}
		nextDP := make([][]int64, 2)
		for i := range nextDP {
			nextDP[i] = make([]int64, 2)
		}

		for n := range a {
			for canDelete := 0; canDelete <= 1; canDelete++ {
				for canStartDeleting := 0; canStartDeleting <= canDelete; canStartDeleting++ {
					result := int64(impossible)

					if a[n]%d == 0 {
						result = minI(result, dp[canStartDeleting][canStartDeleting])
					}

					if (a[n]+1)%d == 0 || (a[n]-1)%d == 0 {
						option := dp[canStartDeleting][canStartDeleting]
						if option != impossible {
							result = minI(result, option+B)
						}
					}

					if canDelete == 1 {
						option := dp[1][0]
						if option != impossible {
							result = minI(result, option+A)
						}
					}

					nextDP[canDelete][canStartDeleting] = result
				}
			}

			dp, nextDP = nextDP, dp
		}

		ans = minI(ans, dp[1][1])
	}
	fmt.Fprintln(out, ans)
}

const impossible = -1

func minI(a, b int64) int64 {
	if a == impossible {
		return b
	}
	if b == impossible {
		return a
	}
	if b < a {
		return b
	}
	return a
}

var primes = genPrimes(1e5)

func primeDivisors(n int) []int {
	result := make([]int, 0)
	for _, p := range primes {
		if n%p == 0 {
			result = append(result, p)
		}
		for n%p == 0 {
			n /= p
		}
	}
	if n != 1 {
		result = append(result, n)
	}
	return result
}

func genPrimes(maxPrime int) []int {
	isPrime := make([]bool, maxPrime+1)
	for i := 2; i <= maxPrime; i++ {
		isPrime[i] = true
	}
	primes := make([]int, 0)
	for i := 2; i <= maxPrime; i++ {
		if isPrime[i] {
			primes = append(primes, i)
			if int64(i)*int64(i) <= int64(maxPrime) {
				for j := i * i; j <= maxPrime; j += i {
					isPrime[j] = false
				}
			}
		}
	}
	return primes
}

package main

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

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

var A, B int
var a []int

func main() {
	defer out.Flush()
	var N int
	fmt.Fscan(in, &N, &A, &B)
	a = make([]int, N)
	for i := range a {
		fmt.Fscan(in, &a[i])
	}
	fmt.Fprintln(out, solve(N-1, impossible, true, true))
}

const impossible = -1

var cache = map[Key]int{}

type Key struct {
	n                int
	g                int
	canDelete        bool
	canStartDeleting bool
}

func solve(n int, g int, canDelete, canStartDeleting bool) int {
	if g == 1 {
		return impossible
	}
	if n == -1 {
		if g == impossible {
			return impossible
		}
		return 0
	}

	key := Key{n, g, canDelete, canStartDeleting}
	if result, ok := cache[key]; ok {
		return result
	}

	result := solve(n-1, gcdI(g, a[n]), canStartDeleting, canStartDeleting)

	option := solve(n-1, gcdI(g, a[n]+1), canStartDeleting, canStartDeleting)
	if option != impossible {
		result = minI(result, option+B)
	}

	option = solve(n-1, gcdI(g, a[n]-1), canStartDeleting, canStartDeleting)
	if option != impossible {
		result = minI(result, option+B)
	}

	if canDelete {
		option = solve(n-1, g, true, false)
		if option != impossible {
			result = minI(result, option+A)
		}
	}

	cache[key] = result
	return result
}

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

func gcdI(a, b int) int {
	if a == impossible {
		return b
	}
	if b == impossible {
		return a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

package main

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

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

var A, B int64
var a []int

func main() {
	defer out.Flush()
	var N int
	fmt.Fscan(in, &N, &A, &B)
	a = make([]int, N)
	for i := range a {
		fmt.Fscan(in, &a[i])
	}

	ds := map[int]bool{}
	for _, i := range []int{a[0] - 1, a[0], a[0] + 1, a[N-1] - 1, a[N-1], a[N-1] + 1} {
		for _, d := range primeDivisors(i) {
			ds[d] = true
		}
	}

	ans := int64(impossible)
	for d, _ := range ds {
		cache = map[Key]int64{}
		ans = minI(ans, solve(N-1, d, true, true))
	}
	fmt.Fprintln(out, ans)
}

const impossible = -1

var cache map[Key]int64

type Key struct {
	n                int
	canDelete        bool
	canStartDeleting bool
}

func solve(n int, d int, canDelete, canStartDeleting bool) int64 {
	if n == -1 {
		return 0
	}

	key := Key{n, canDelete, canStartDeleting}
	if result, ok := cache[key]; ok {
		return result
	}

	result := int64(impossible)

	if a[n]%d == 0 {
		result = minI(result, solve(n-1, d, canStartDeleting, canStartDeleting))
	}

	if (a[n]+1)%d == 0 || (a[n]-1)%d == 0 {
		option := solve(n-1, d, canStartDeleting, canStartDeleting)
		if option != impossible {
			result = minI(result, option+B)
		}
	}

	if canDelete {
		option := solve(n-1, d, true, false)
		if option != impossible {
			result = minI(result, option+A)
		}
	}

	cache[key] = result
	return result
}

func minI(a, b int64) int64 {
	if a == impossible {
		return b
	}
	if b == impossible {
		return a
	}
	if b < a {
		return b
	}
	return a
}

var primes = genPrimes(1e5)

func primeDivisors(n int) []int {
	result := make([]int, 0)
	for _, p := range primes {
		if n%p == 0 {
			result = append(result, p)
		}
		for n%p == 0 {
			n /= p
		}
	}
	if n != 1 {
		result = append(result, n)
	}
	return result
}

func genPrimes(maxPrime int) []int {
	isPrime := make([]bool, maxPrime+1)
	primes := make([]int, 0)
	for i := 2; i <= maxPrime; i++ {
		if isPrime[i] {
			primes = append(primes, i)
			if int64(i)*int64(i) <= int64(maxPrime) {
				for j := i * i; j <= maxPrime; j += i {
					isPrime[j] = false
				}
			}
		}
	}
	return primes
}

package main

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

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

var A, B int
var a []int

func main() {
	defer out.Flush()
	var N int
	fmt.Fscan(in, &N, &A, &B)
	a = make([]int, N)
	for i := range a {
		fmt.Fscan(in, &a[i])
	}
	fmt.Fprintln(out, solve(N-1, impossible, true, true))
}

const impossible = -1

var cache = map[Key]int{}

type Key struct {
	n                int
	g                int
	canDelete        bool
	canStartDeleting bool
}

func solve(n int, g int, canDelete, canStartDeleting bool) int {
	if g == 1 {
		return impossible
	}
	if n == -1 {
		if g == impossible {
			return impossible
		}
		return 0
	}

	key := Key{n, g, canDelete, canStartDeleting}
	if result, ok := cache[key]; ok {
		return result
	}

	result := solve(n-1, gcdI(g, a[n]), canStartDeleting, canStartDeleting)

	option := solve(n-1, gcdI(g, a[n]+1), canStartDeleting, canStartDeleting)
	if option != impossible {
		result = minI(result, option+B)
	}

	if a[n] >= 1 {
		option = solve(n-1, gcdI(g, a[n]-1), canStartDeleting, canStartDeleting)
		if option != impossible {
			result = minI(result, option+B)
		}
	}

	if canDelete {
		option = solve(n-1, g, true, false)
		if option != impossible {
			result = minI(result, option+A)
		}
	}

	cache[key] = result
	return result
}

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

func gcdI(a, b int) int {
	if a == impossible {
		return b
	}
	if b == impossible {
		return a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}


Today Pari and Arya are playing a game called Remainders.Pari chooses two positive integer x and k, and tells Arya k but not x. Arya have to find the value . There are n ancient numbers c1, c2, ..., cn and Pari has to tell Arya  if Arya wants. Given k and the ancient values, tell us if Arya has a winning strategy independent of value of x or not. Formally, is it true that Arya can understand the value  for any positive integer x?Note, that  means the remainder of x after dividing it by y.

The first line of the input contains two integers n and k (1 ≤ n,  k ≤ 1 000 000) — the number of ancient integers and value k that is chosen by Pari. The second line contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 1 000 000).

Print "Yes" (without quotes) if Arya has a winning strategy independent of value of x, or "No" (without quotes) otherwise.

NoteIn the first sample, Arya can understand  because 5 is one of the ancient numbers.In the second sample, Arya can't be sure what  is. For example 1 and 7 have the same remainders after dividing by 2 and 3, but they differ in remainders after dividing by 7.

package main

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

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text = strings.TrimRight(text, "\r\n")
	s := strings.Split(text, " ")
	x, _ := strconv.ParseInt(s[0], 10, 64)
	totalv, _ := strconv.ParseInt(s[1], 10, 64)

	text, _ = reader.ReadString('\n')
	text = strings.TrimRight(text, "\r\n")
	s = strings.Split(text, " ")
	var a int64
	a = 1
	if x != int64(len(s)) {
		fmt.Println("Read Error")
	}
	for _, ss := range s {

		v, _ := strconv.ParseInt(ss, 10, 64)

		a = (v * a) / gcd(v, a)
		a = gcd(a, totalv)
		if a%totalv == 0 {
			fmt.Println("Yes")
			return
		}
	}

	fmt.Println("No")
}

package main

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

var in *bufio.Scanner

func main() {
    var n int
    var k int64
    in = bufio.NewScanner(os.Stdin)
    const MaxTokenLength = 1024 * 1024
    in.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
    in.Split(bufio.ScanWords)
    n = readInt()
    k = (int64)(readInt())
    var ans int64 = 1
    for i := 0;i < n;i++ {
        var t int64 = (int64)(readInt())
        t = gcd(t,k)
        ans = ans * t / gcd(ans,t)
    }
    if ans % k == 0 {
      fmt.Println("Yes")
    } else {
      fmt.Println("No")
    }
}
func gcd(a,b int64) int64 {
    if b == 0 {
        return a
    } else {
        return gcd(b,a % b)
    }
}

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

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

package main

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

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

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

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

	can := true
	for _, f := range factors(k) {
		ok := false
		for _, e := range c {
			if e%f == 0 {
				ok = true
				break
			}
		}
		if !ok {
			can = false
			break
		}
	}

	if can {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func factors(a int) []int {
	var f []int
	for p := 2; p*p <= a; p++ {
		if a%p != 0 {
			continue
		}
		factor := 1
		for a%p == 0 {
			factor *= p
			a /= p
		}
		f = append(f, factor)
	}
	if a > 1 {
		f = append(f, a)
	}
	return f
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF687B(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}

	n, k := read(), read()
	if k == 1 {
		Fprint(out, "Yes")
		return
	}

	factors := []int{}
	exponents := []int{}
	kk := k
	for i := 2; i*i <= kk; i++ {
		cnt := 0
		for ; kk%i == 0; kk /= i {
			cnt++
		}
		if cnt > 0 {
			factors = append(factors, i)
			exponents = append(exponents, cnt)
		}
	}
	if kk > 1 {
		factors = append(factors, kk)
		exponents = append(exponents, 1)
	}

	match := make([]bool, len(factors))
	for i := 0; i < n; i++ {
		c := read()
		for j, f := range factors {
			cnt := 0
			for ; c%f == 0; c /= f {
				cnt++
			}
			if cnt >= exponents[j] {
				match[j] = true
			}
		}
	}
	for _, ok := range match {
		if !ok {
			Fprint(out, "No")
			return
		}
	}
	Fprint(out, "Yes")
}

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

package main

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	s := strings.Split(scanner.Text(), " ")
	//x, _ = strconv.ParseInt(s[1], 10, 64)
	totalv, _ := strconv.ParseInt(s[1], 10, 64)
	scanner.Scan()
	s = strings.Split(scanner.Text(), " ")
	var a int64
	a = 1
	for _, ss := range s {
		v, _ := strconv.ParseInt(ss, 10, 64)
		a = (v * a) / gcd(v, a)
		a /= gcd(a, totalv)
	}
	if a%totalv == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

package main

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	s := strings.Split(scanner.Text(), " ")
	//x, _ = strconv.ParseInt(s[1], 10, 64)
	totalv, _ := strconv.ParseInt(s[1], 10, 64)
	scanner.Scan()
	s = strings.Split(scanner.Text(), " ")
	var a int64
	a = 1
	for _, ss := range s {
		v, _ := strconv.ParseInt(ss, 10, 64)
		a = (v * a) / gcd(v, a)
		a = gcd(a, totalv)
		if a%totalv == 0 {
			fmt.Println("Yes")
			return
		}
	}

	fmt.Println("No")
}

package main

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	s := strings.Split(scanner.Text(), " ")
	//x, _ = strconv.ParseInt(s[1], 10, 64)
	totalv, _ := strconv.ParseInt(s[1], 10, 64)
	scanner.Scan()
	s = strings.Split(scanner.Text(), " ")
	var a int64
	a = 1
	for _, ss := range s {
		v, _ := strconv.ParseInt(ss, 10, 64)
		a = (v * a)
		a /= gcd(a, totalv)
	}
	if a%totalv == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

package main

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	s := strings.Split(scanner.Text(), " ")
	x, _ := strconv.ParseInt(s[0], 10, 64)
	totalv, _ := strconv.ParseInt(s[1], 10, 64)
	scanner.Scan()
	s = strings.Split(scanner.Text(), " ")
	var a int64
	a = 1
	if x != int64(len(s)) {
		fmt.Println("Read Error")
	}
	for _, ss := range s {
		v, _ := strconv.ParseInt(ss, 10, 64)
		a = (v * a) / gcd(v, a)
		a = gcd(a, totalv)
		if a%totalv == 0 {
			fmt.Println("Yes")
			return
		}
	}

	fmt.Println("No")
}

package main

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

func main() {
	var primes []byte
	var i int64
	var mp int64
	mp = 1000000
	for i = 0; i < mp; i++ {
		primes = append(primes, 0)
	}
	primes[0] = 1
	primes[1] = 1
	for i = 2; i < mp; i++ {
		if primes[i] == 0 {
			var j int64
			for j = i * 2; j < mp; j += i {
				primes[j] = 1
			}
		}
	}
	p := []int{}
	for i, v := range primes {
		if v == 0 {
			p = append(p, i)
		}
	}

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	s := strings.Split(scanner.Text(), " ")
	//x, _ = strconv.ParseInt(s[1], 10, 64)
	v, _ := strconv.ParseInt(s[1], 10, 64)
	expected := make(map[int]int)
	for v != 1 {
		i := 0
		for i < len(p) {
			if int(v)%p[i] == 0 {
				expected[p[i]] += 1
				v /= int64(p[i])
			} else {
				i++
			}
		}
	}
	exp := []int64{}
	for v, ex := range expected {
		exp = append(exp, int64(v)*int64(ex))
	}
	scanner.Scan()
	s = strings.Split(scanner.Text(), " ")
	used := map[int64]bool{}
	for _, ss := range s {
		v, _ := strconv.ParseInt(ss, 10, 64)
		if used[v] {
			continue
		}
		e := []int64{}

		used[v] = true
		for _, x := range exp {

			if v%int64(x) != 0 {
				e = append(e, x)
			} else {
				v /= int64(x)
			}
		}
		exp = e
		if len(exp) == 0 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

package main

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

func main() {
	var primes []byte
	var i int64
	var mp int64
	mp = 1000000
	for i = 0; i < mp; i++ {
		primes = append(primes, 0)
	}
	primes[0] = 1
	primes[1] = 1
	for i = 2; i < mp; i++ {
		if primes[i] == 0 {
			var j int64
			for j = i * 2; j < mp; j += i {
				primes[j] = 1
			}
		}
	}
	p := []int{}
	for i, v := range primes {
		if v == 0 {
			p = append(p, i)
		}
	}

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	s := strings.Split(scanner.Text(), " ")
	//x, _ = strconv.ParseInt(s[1], 10, 64)
	v, _ := strconv.ParseInt(s[1], 10, 64)
	expected := []int{}
	for v != 1 {
		i := 0
		for i < len(p) {
			if int(v)%p[i] == 0 {
				expected = append(expected, p[i])
				v /= int64(p[i])
			} else {
				i++
			}
		}
	}
	scanner.Scan()
	s = strings.Split(scanner.Text(), " ")
	for _, ss := range s {
		v, _ := strconv.ParseInt(ss, 10, 64)
		e := []int{}
		for _, x := range expected {

			if v%int64(x) != 0 {
				e = append(e, x)
			} else {
				v /= int64(x)
			}
		}
		expected = e
		if len(expected) == 0 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

package main

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

func main() {
	var primes []byte
	var i int64
	var mp int64
	mp = 1000000
	for i = 0; i < mp; i++ {
		primes = append(primes, 0)
	}
	primes[0] = 1
	primes[1] = 1
	for i = 2; i < mp; i++ {
		if primes[i] == 0 {
			var j int64
			for j = i * 2; j < mp; j += i {
				primes[j] = 1
			}
		}
	}
	p := []int{}
	for i, v := range primes {
		if v == 0 {
			p = append(p, i)
		}
	}

	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text = strings.TrimRight(text, "\r\n")
	s := strings.Split(text, " ")
	//x, _ = strconv.ParseInt(s[1], 10, 64)
	v, _ := strconv.ParseInt(s[1], 10, 64)
	expected := make(map[int]int)
	for v != 1 {
		i := 0
		for i < len(p) {
			if int(v)%p[i] == 0 {
				expected[p[i]] += 1
				v /= int64(p[i])
			} else {
				i++
			}
		}
	}
	exp := []int64{}
	for v, ex := range expected {
		exp = append(exp, int64(v)*int64(ex))
	}
	text, _ = reader.ReadString('\n')
	text = strings.TrimRight(text, "\r\n")
	s = strings.Split(text, " ")
	used := map[int64]bool{}
	for _, ss := range s {
		v, _ := strconv.ParseInt(ss, 10, 64)
		if used[v] {
			continue
		}
		e := []int64{}

		used[v] = true
		for _, x := range exp {

			if v%int64(x) != 0 {
				e = append(e, x)
			} else {
				v /= int64(x)
			}
		}
		exp = e
		if len(exp) == 0 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

package main

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	s := strings.Split(scanner.Text(), " ")
	//x, _ = strconv.ParseInt(s[1], 10, 64)
	totalv, _ := strconv.ParseInt(s[1], 10, 64)
	scanner.Scan()
	s = strings.Split(scanner.Text(), " ")
	var a int64
	a = 1
	for _, ss := range s {
		v, _ := strconv.ParseInt(ss, 10, 64)
		a = (v * a) / gcd(v, a)
		if a%totalv == 0 {
			fmt.Println("Yes")
			return
		}
		a /= gcd(a, totalv)
	}

	fmt.Println("No")
}

package main

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	s := strings.Split(scanner.Text(), " ")
	//x, _ = strconv.ParseInt(s[1], 10, 64)
	totalv, _ := strconv.ParseInt(s[1], 10, 64)
	scanner.Scan()
	s = strings.Split(scanner.Text(), " ")
	var a int64
	a = 1
	for _, ss := range s {
		v, _ := strconv.ParseInt(ss, 10, 64)
		a = (v * a) / gcd(v, a)
	}
	if a%totalv == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

package main

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

func main() {
	var primes []byte
	var i int64
	var mp int64
	mp = 1000000
	for i = 0; i < mp; i++ {
		primes = append(primes, 0)
	}
	primes[0] = 1
	primes[1] = 1
	for i = 2; i < mp; i++ {
		if primes[i] == 0 {
			var j int64
			for j = i * 2; j < mp; j += i {
				primes[j] = 1
			}
		}
	}
	p := []int{}
	for i, v := range primes {
		if v == 0 {
			p = append(p, i)
		}
	}

	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text = strings.TrimRight(text, "\r\n")
	s := strings.Split(text, " ")
	x, _ := strconv.ParseInt(s[0], 10, 64)
	v, _ := strconv.ParseInt(s[1], 10, 64)
	expected := make(map[int]int)
	for v != 1 {
		i := 0
		for i < len(p) {
			if int(v)%p[i] == 0 {
				expected[p[i]] += 1
				v /= int64(p[i])
			} else {
				i++
			}
		}
	}
	exp := []int64{}
	for v, ex := range expected {
		exp = append(exp, int64(v)*int64(ex))
	}
	text, _ = reader.ReadString('\n')
	text = strings.TrimRight(text, "\r\n")
	s = strings.Split(text, " ")
	used := map[int64]bool{}
	if x != int64(len(s)) {
		fmt.Println("Read Error")
	}
	for _, ss := range s {
		v, _ := strconv.ParseInt(ss, 10, 64)
		if used[v] {
			continue
		}
		e := []int64{}

		used[v] = true
		for _, x := range exp {

			if v%int64(x) != 0 {
				e = append(e, x)
			} else {
				v /= int64(x)
			}
		}
		exp = e
		if len(exp) == 0 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

package main

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

func main() {
	var primes []byte
	var i int64
	var mp int64
	mp = 1000000
	for i = 0; i < mp; i++ {
		primes = append(primes, 0)
	}
	primes[0] = 1
	primes[1] = 1
	for i = 2; i < mp; i++ {
		if primes[i] == 0 {
			var j int64
			for j = i * 2; j < mp; j += i {
				primes[j] = 1
			}
		}
	}
	p := []int{}
	for i, v := range primes {
		if v == 0 {
			p = append(p, i)
		}
	}

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	s := strings.Split(scanner.Text(), " ")
	//x, _ = strconv.ParseInt(s[1], 10, 64)
	v, _ := strconv.ParseInt(s[1], 10, 64)
	expected := []int{}
	for v != 1 {
		i := 0
		for i < len(p) {
			if int(v)%p[i] == 0 {
				expected = append(expected, p[i])
				v /= int64(p[i])
			} else {
				i++
			}
		}
	}
	scanner.Scan()
	s = strings.Split(scanner.Text(), " ")
	for _, ss := range s {
		v, _ := strconv.ParseInt(ss, 10, 64)
		e := []int{}
		for _, x := range expected {

			if v%int64(x) != 0 {
				e = append(e, x)
			} else {
				for (v % int64(x)) == 0 {
					v /= int64(x)
				}
			}
		}
		expected = e
		if len(expected) == 0 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

package main

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	s := strings.Split(scanner.Text(), " ")
	//x, _ = strconv.ParseInt(s[1], 10, 64)
	totalv, _ := strconv.ParseInt(s[1], 10, 64)
	scanner.Scan()
	s = strings.Split(scanner.Text(), " ")
	var a int64
	a = 1
	for _, ss := range s {
		v, _ := strconv.ParseInt(ss, 10, 64)
		a = (v * a) / gcd(v, a)
		if a%totalv == 0 {
			fmt.Println("Yes")
			return
		}
	}

	fmt.Println("No")
}

package main

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

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

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

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

	f := New()
	l := f.lcm(c)

	divides := true
	for p, v := range f.factorise(k) {
		if v > l[p] {
			divides = false
			break
		}
	}

	if divides {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

type Factoriser struct {
	fact []int
}

func New() *Factoriser {
	limit := int(1e6) + 1
	p := make([]bool, limit)

	f := make([]int, limit)
	for i := 2; i < limit; i++ {
		if p[i] {
			continue
		}
		f[i] = i
		if i > limit/i {
			continue
		}
		for j := i * i; j < limit; j += i + i {
			p[j] = true
			f[j] = i
		}
	}

	return &Factoriser{fact: f}
}

func (f *Factoriser) factorise(num int) map[int]int {
	l := make(map[int]int)
	for num > 1 {
		d := f.fact[num]
		l[d]++
		num /= d
	}
	return l
}

func (f *Factoriser) lcm(a []int) map[int]int {
	l := make(map[int]int)
	for _, e := range a {
		for k, v := range f.factorise(e) {
			if _, ok := l[k]; ok {
				l[k] = max(l[k], v)
			} else {
				l[k] = v
			}
		}
	}
	return l
}

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

package main

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

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

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

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

	f := New()
	l := lcm(c)

	divides := true
	for p, v := range f.factorise(k) {
		if v > l[p] {
			divides = false
			break
		}
	}

	if divides {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

type Factoriser struct {
	fact map[int]int
}

func New() *Factoriser {
	limit := int(1e6) + 1
	p := make([]bool, limit)

	for i := 2; i < limit; i++ {
		p[i] = true
	}

	f := make(map[int]int)
	for i := 2; i < limit; i++ {
		if !p[i] {
			continue
		}
		f[i] = i
		for j := i + i; j < limit; j += i {
			p[j] = false
			f[j] = i
		}
	}

	return &Factoriser{fact: f}
}

func (f *Factoriser) factorise(num int) map[int]int {
	l := make(map[int]int)
	for num > 1 {
		d := f.fact[num]
		l[d]++
		num /= d
	}
	return l
}

func lcm(a []int) map[int]int {
	f := New()
	l := make(map[int]int)
	for _, e := range a {
		for k, v := range f.factorise(e) {
			l[k] += v
		}
	}
	return l
}


Bike is interested in permutations. A permutation of length n is an integer sequence such that each integer from 0 to (n - 1) appears exactly once in it. For example, [0, 2, 1] is a permutation of length 3 while both [0, 2, 2] and [1, 2, 3] is not.A permutation triple of permutations of length n (a, b, c) is called a Lucky Permutation Triple if and only if . The sign ai denotes the i-th element of permutation a. The modular equality described above denotes that the remainders after dividing ai + bi by n and dividing ci by n are equal.Now, he has an integer n and wants to find a Lucky Permutation Triple. Could you please help him?

The first line contains a single integer n (1 ≤ n ≤ 105).

If no Lucky Permutation Triple of length n exists print -1. Otherwise, you need to print three lines. Each line contains n space-seperated integers. The first line must contain permutation a, the second line — permutation b, the third — permutation c. If there are multiple solutions, print any of them.

NoteIn Sample 1, the permutation triple ([1, 4, 3, 2, 0], [1, 0, 2, 4, 3], [2, 4, 0, 1, 3]) is Lucky Permutation Triple, as following holds:  ;  ;  ;  ;  . In Sample 2, you can easily notice that no lucky permutation triple exists.

package main

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

var w *bufio.Writer

var sc *bufio.Scanner

const minus, zero byte = '-', '0'

func nextInt() int {
	var ans, fst int = 0, 0
	var neg bool = false
	sc.Scan()
	if sc.Bytes()[0] == minus {
		fst = 1
		neg = true
	}
	for _, j := range sc.Bytes()[fst:] {
		ans = ans*10 + int(j-zero)
	}
	if neg == true {
		ans = -ans
	}
	return ans
}

func printInt(n int) {
	w.WriteString(strconv.Itoa(n) + " ")
}

func main() {

	w = bufio.NewWriter(os.Stdout)
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	if n%2 == 0 {
		w.WriteString("-1")
		w.Flush()
		return
	}
	for i := 0; i < n; i++ {
		printInt(i)
	}
	w.WriteString("\n")
	for i := 0; i < n; i++ {
		printInt(i)
	}
	w.WriteString("\n")
	for i := 0; i < n; i++ {
		printInt((i * 2) % n)
	}
	w.WriteString("\n")
	w.Flush()
	//YOU FORGOT TO FLUSH!
}

//303A
package main
import (
	//"fmt"
	"os"
	"bufio"
	"strconv"
)

func main() {
	var nn int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	nn, _ = strconv.Atoi(r.Text())

	if nn%2==0 {
		w.WriteString("-1\n")
	} else {
		for i:=0; i<nn ; i+=1 {
			if i>0 {
				w.WriteString(" ")
			}
			w.WriteString(strconv.Itoa(i))
		}
		w.WriteString("\n")

		for i:=0; i<nn ; i+=1 {
			if i>0 {
				w.WriteString(" ")
			}
			w.WriteString(strconv.Itoa(i))
		}
		w.WriteString("\n")

		for i:=0; i<nn ; i+=1 {
			if i>0 {
				w.WriteString(" ")
				//fmt.Print(" ")
			}
			w.WriteString(strconv.Itoa((i+i)%nn))
		}
		w.WriteString("\n")
	}
	w.Flush()
}

// 303A-Andre,Dikai,Eric
package main

import (
	"fmt"
)

func main() {
	var n,i,j int
	fmt.Scan(&n)
	if n%2 == 0{
		fmt.Println("-1")
		return

	}
	for i=0;i<2;i++{
		for j=0;j<n;j++ {
			fmt.Print(j," ")
		}
		fmt.Println()
	}
	for j=0;j<n;j++{
		fmt.Print((2*j)%n," ")

	}
}

// 303A
package main

import (
	"fmt"
)

func main() {
	var n, i int
	fmt.Scan(&n)
	if n%2 != 0 {
		for i = 0; i < n; i++ {
			fmt.Printf("%d ", i)
		}
		fmt.Println()
		for i = 0; i < n; i++ {
			fmt.Printf("%d ", i)
		}
		fmt.Println()
		for i = 0; i < n; i++ {
			fmt.Printf("%d ", (i+i)%n)
		}
		fmt.Println()
	} else {
		fmt.Println(-1)
	}
}

// 303A-mic
package main

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

func main() {
	z := bufio.NewWriter(os.Stdout)
	var n, i int
	fmt.Scan(&n)
	if n&1 == 1 {
		for i = 0; i < n; i++ {
			z.WriteString(strconv.Itoa(i) + " ")
		}
		z.WriteString("\n")
		for i = 0; i < n; i++ {
			z.WriteString(strconv.Itoa(i) + " ")
		}
		z.WriteString("\n")
		for i = 0; i < n; i++ {
			z.WriteString(strconv.Itoa((2*i)%n) + " ")
		}
		z.WriteString("\n")
	} else {
		z.WriteString("-1")
		z.WriteString("\n")
	}
	z.Flush()
}

package main

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

var w *bufio.Writer

var sc *bufio.Scanner

const minus, zero byte = '-', '0'

func nextInt() int {
	var ans, fst int = 0, 0
	var neg bool = false
	sc.Scan()
	if sc.Bytes()[0] == minus {
		fst = 1
		neg = true
	}
	for _, j := range sc.Bytes()[fst:] {
		ans = ans*10 + int(j-zero)
	}
	if neg == true {
		ans = -ans
	}
	return ans
}

func printInt(n int) {
	w.WriteString(strconv.Itoa(n) + " ")
}

func main() {

	w = bufio.NewWriter(os.Stdout)
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	if n == 2 {
		w.WriteString("-1")
		return
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			w.WriteString("-1")
			return
		}
	}
	for i := 0; i < n; i++ {
		printInt(i)
	}
	w.WriteString("\n")
	for i := 0; i < n; i++ {
		printInt(i)
	}
	w.WriteString("\n")
	for i := 0; i < n; i++ {
		printInt((i * 2) % n)
	}
	w.WriteString("\n")
	w.Flush()
	//YOU FORGOT TO FLUSH!
}

package main

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

var w *bufio.Writer

var sc *bufio.Scanner

const minus, zero byte = '-', '0'

func nextInt() int {
	var ans, fst int = 0, 0
	var neg bool = false
	sc.Scan()
	if sc.Bytes()[0] == minus {
		fst = 1
		neg = true
	}
	for _, j := range sc.Bytes()[fst:] {
		ans = ans*10 + int(j-zero)
	}
	if neg == true {
		ans = -ans
	}
	return ans
}

func printInt(n int) {
	w.WriteString(strconv.Itoa(n) + " ")
}

func main() {

	w = bufio.NewWriter(os.Stdout)
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			w.WriteString("-1")
			return
		}
	}
	for i := 0; i < n; i++ {
		printInt(i)
	}
	w.WriteString("\n")
	for i := 0; i < n; i++ {
		printInt(i)
	}
	w.WriteString("\n")
	for i := 0; i < n; i++ {
		printInt((i * 2) % n)
	}
	w.WriteString("\n")
	w.Flush()
	//YOU FORGOT TO FLUSH!
}

package main

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

var w *bufio.Writer

var sc *bufio.Scanner

const minus, zero byte = '-', '0'

func nextInt() int {
	var ans, fst int = 0, 0
	var neg bool = false
	sc.Scan()
	if sc.Bytes()[0] == minus {
		fst = 1
		neg = true
	}
	for _, j := range sc.Bytes()[fst:] {
		ans = ans*10 + int(j-zero)
	}
	if neg == true {
		ans = -ans
	}
	return ans
}

func printInt(n int) {
	w.WriteString(strconv.Itoa(n) + " ")
}

func main() {

	w = bufio.NewWriter(os.Stdout)
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	if n == 2 {
		w.WriteString("-1")
		w.Flush()
		return
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			w.WriteString("-1")
			w.Flush()
			return
		}
	}
	for i := 0; i < n; i++ {
		printInt(i)
	}
	w.WriteString("\n")
	for i := 0; i < n; i++ {
		printInt(i)
	}
	w.WriteString("\n")
	for i := 0; i < n; i++ {
		printInt((i * 2) % n)
	}
	w.WriteString("\n")
	w.Flush()
	//YOU FORGOT TO FLUSH!
}

// 303A-Andre,Dikai,Eric
package main

import (
    "fmt"
)

func main() {
    var n,i,j int
    fmt.Scan(&n)
    if n%2 == 0{
        fmt.Println("-1")
        return
    }
    for i=0;i<2;i++{
        for j=0;j<n;j++ {
            fmt.Println(j," ")
        }
    }
    for j=0;j<n;j++{
        fmt.Println((2*j)%n," ")
        return
    }
}

// 303A-Andre,Dikai,Eric
package main

import (
	"fmt"
)

func main() {
	var n,i,j int
	fmt.Scan(&n)
	if n%2 == 0{
		fmt.Println("-1")

	}
	for i=0;i<2;i++{
		for j=0;j<n;j++ {
			fmt.Print(j," ")
		}
		fmt.Println()
	}
	for j=0;j<n;j++{
		fmt.Print((2*j)%n," ")

	}
}

// 303A
package main

import (
	"fmt"
)

func main() {
	var n, i int
	fmt.Scan(&n)
	if n%2 != 0 {
		for i = 0; i < n; i++ {
			fmt.Printf("%d ", i)
		}
		fmt.Println()
		for i = 0; i < n; i++ {
			fmt.Printf("%d ", i)
		}
		fmt.Println()
		for i = 0; i < n; i++ {
			fmt.Printf("%d ", (i+i)%n)
		}
		fmt.Println()
	} else {
		fmt.Println()
	}
}


You are given an array $$$a$$$ of length $$$n$$$. The array is called 3SUM-closed if for all distinct indices $$$i$$$, $$$j$$$, $$$k$$$, the sum $$$a_i + a_j + a_k$$$ is an element of the array. More formally, $$$a$$$ is 3SUM-closed if for all integers $$$1 \leq i < j < k \leq n$$$, there exists some integer $$$1 \leq l \leq n$$$ such that $$$a_i + a_j + a_k = a_l$$$.Determine if $$$a$$$ is 3SUM-closed.

The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ ($$$3 \leq n \leq 2 \cdot 10^5$$$) — the length of the array. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^9 \leq a_i \leq 10^9$$$) — the elements of the array. It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, output "YES" (without quotes) if $$$a$$$ is 3SUM-closed and "NO" (without quotes) otherwise. You can output "YES" and "NO" in any case (for example, strings "yEs", "yes" and "Yes" will be recognized as a positive response).

NoteIn the first test case, there is only one triple where $$$i=1$$$, $$$j=2$$$, $$$k=3$$$. In this case, $$$a_1 + a_2 + a_3 = 0$$$, which is an element of the array ($$$a_2 = 0$$$), so the array is 3SUM-closed.In the second test case, $$$a_1 + a_4 + a_5 = -1$$$, which is not an element of the array. Therefore, the array is not 3SUM-closed.In the third test case, $$$a_i + a_j + a_k = 0$$$ for all distinct $$$i$$$, $$$j$$$, $$$k$$$, and $$$0$$$ is an element of the array, so the array is 3SUM-closed.

package main

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

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

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

		aa := make([]int64, 6)
		var a, b, z int
		var idx int
		for i := 0; i < n; i++ {
			var v int64
			fmt.Fscan(in, &v)
			if v < 0 {
				a++
			} else if v > 0 {
				b++
			} else {
				z++
			}

			if (v < 0 && a < 3) || (v > 0 && b < 3) || (v == 0 && z < 3) {
				aa[idx] = v
				idx++
			}
		}

		f := true
		if a > 2 || b > 2 {
			f = false
		}
	Loop:
		for i := 0; i < idx; i++ {
			for j := i + 1; j < idx; j++ {
				for k := j + 1; k < idx; k++ {
					d := aa[i] + aa[j] + aa[k]
					var f2 bool
					for v := 0; v < idx; v++ {
						if aa[v] == d {
							f2 = true
							break
						}
					}
					if !f2 {
						f = false
						break Loop
					}
				}
			}
		}

		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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

func slove() {
	var n int
	fmt.Fscan(r, &n)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	cnt := map[int]int{}
	for i := range nums {
		cnt[nums[i]]++
	}
	if n > 6 {
		sort.Ints(nums)
		for i:=1;i<n-1;i++ {
			if nums[i] != 0 {
				fmt.Fprintln(w, "NO")
				return
			}
		}
		if cnt[nums[0] + nums[n-1]] == 0 {
			fmt.Fprintln(w, "NO")
			return
		} else {
			fmt.Fprintln(w, "YES")
			return
		}
	}
	for i:=0;i<n;i++ {
		for j:=i+1;j<n;j++ {
			for k:=j+1;k<n;k++ {
				if cnt[nums[i]+nums[j]+nums[k]] == 0 {
					fmt.Fprintln(w, "NO")
					return
				}
			}
		}
	}
	fmt.Fprintln(w, "YES")
}

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

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

package main

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

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

func solve(arr []int) string {
	positives := []int{}
	negatives := []int{}
	zeros := 0
	for i := 0; i < len(arr); i++ {
		if arr[i] > 0 {
			positives = append(positives, arr[i])
		} else if arr[i] < 0 {
			negatives = append(negatives, arr[i])
		} else {
			zeros++
		}
	}
	if len(positives) > 2 || len(negatives) > 2 {
		return "NO"
	}
	if zeros > 2 {
		zeros = 2
	}
	final := append(positives, negatives...)
	for i := 0; i < zeros; i++ {
		final = append(final, 0)
	}
	//fmt.Println(final)
	answer := true
	for i := 0; i < len(final); i++ {
		for j := i + 1; j < len(final); j++ {
			for k := j + 1; k < len(final); k++ {
				tmp_answer := false
				if contains(arr, final[i]+final[j]+final[k]) {
					tmp_answer = true
				}
				answer = answer && tmp_answer
			}
		}
	}
	if answer {
		return "YES"
	} else {
		return "NO"
	}

}

func contains(s []int, e int) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

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

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

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

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

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

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

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

func main() {
	in := bufio.NewReader(os.Stdin)
	t := readInt(in)
	for ; t > 0; t-- {
		readInt(in)
		arr := readArrInt(in)
		if judge(arr) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func judge(arr []int) bool {
	var tmp []int
	m := make(map[int]struct{})
	var negCnt, posCnt, zero int
	for _, val := range arr {
		if val > 0 {
			posCnt++
			tmp = append(tmp, val)
		}
		if val < 0 {
			negCnt++
			tmp = append(tmp, val)
		}
		if val == 0 {
			zero++
		}
		m[val] = struct{}{}
	}
	if zero > 0 {
		tmp = append(tmp, 0)
	}
	if posCnt >= 3 || negCnt >= 3 {
		return false
	}
	n := len(tmp)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			for k := j + 1; k < n; k++ {
				if _, has := m[tmp[i]+tmp[j]+tmp[k]]; !has {
					return false
				}
			}
		}
	}
	return true
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int     { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }
func gis(n int) []int  { res := make([]int,n); for i:=0;i<n;i++ { res[i] = gi() }; return res }
func gf() float64 { f,e := strconv.ParseFloat(gs(),64); if e != nil {panic(e)}; return f }
func gbs() []byte { return []byte(gs()) }
func gfs(n int) []float64  { res := make([]float64,n); for i:=0;i<n;i++ { res[i] = gf() }; return res }
func gss(n int) []string  { res := make([]string,n); for i:=0;i<n;i++ { res[i] = gs() }; return res }
func gi64() int64     { i,e := strconv.ParseInt(gs(),10,64); if e != nil {panic(e)}; return i }
func gis64(n int) []int64  { res := make([]int64,n); for i:=0;i<n;i++ { res[i] = gi64() }; return res }

func ia(m int) []int { return make([]int,m) }
func iai(m int,v int) []int { a := make([]int,m); for i:=0;i<m;i++ { a[i] = v }; return a }
func twodi(n int,m int,v int) [][]int {
	r := make([][]int,n); for i:=0;i<n;i++ { x := make([]int,m); for j:=0;j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill2(m int) ([]int,[]int) { a,b := ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i] = gi(),gi()}; return a,b }
func fill3(m int) ([]int,[]int,[]int) { a,b,c := ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i] = gi(),gi(),gi()}; return a,b,c }
func fill4(m int) ([]int,[]int,[]int,[]int) { a,b,c,d := ia(m),ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i],d[i] = gi(),gi(),gi(),gi()}; return a,b,c,d }
func abs(a int) int { if a < 0 { return -a }; return a }
func rev(a []int) { i,j := 0,len(a)-1; for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max(a,b int) int { if a > b { return a }; return b }
func min(a,b int) int { if a > b { return b }; return a }
func maxarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr(a []int) int { ans := 0; for _,aa := range(a) { ans += aa }; return ans }
func zeroarr(a []int) { for i:=0; i<len(a); i++ { a[i] = 0 } }
func powmod(a,e,mod int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint(a,e int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd(a,b int) int { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended(a,b int) (int,int,int) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv(a,m int) (int,bool) { g,x,_ := gcdExtended(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func vecintstring(a []int) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.Itoa(a) }; return strings.Join(astr," ") }
func makefact(n int,mod int) ([]int,[]int) {
	fact,factinv := make([]int,n+1),make([]int,n+1)
	fact[0] = 1; for i:=1;i<=n;i++ { fact[i] = fact[i-1] * i % mod }
	factinv[n] = powmod(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * (i+1) % mod }
	return fact,factinv
}

func ia64(m int) []int64 { return make([]int64,m) }
func iai64(m int,v int64) []int64 { a := make([]int64,m); for i:=0;i<m;i++ { a[i] = v }; return a }
func twodi64(n int,m int,v int64) [][]int64 {
	r := make([][]int64,n); for i:=0;i<n;i++ { x := make([]int64,m); for j:=0;j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill264(m int) ([]int64,[]int64) { a,b := ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i] = gi64(),gi64()}; return a,b }
func fill364(m int) ([]int64,[]int64,[]int64) { a,b,c := ia64(m),ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i],c[i] = gi64(),gi64(),gi64()}; return a,b,c }
func fill464(m int) ([]int64,[]int64,[]int64,[]int64) { a,b,c,d := ia64(m),ia64(m),ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i],c[i],d[i] = gi64(),gi64(),gi64(),gi64()}; return a,b,c,d }
func abs64(a int64) int64 { if a < 0 { return -a }; return a }
func rev64(a []int64) { i,j := 0,len(a)-1; for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max64(a,b int64) int64 { if a > b { return a }; return b }
func min64(a,b int64) int64 { if a > b { return b }; return a }
func maxarr64(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr64(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr64(a []int64) int64 { ans := int64(0); for _,aa := range(a) { ans += aa }; return ans }
func zeroarr64(a []int64) { for i:=0; i<len(a); i++ { a[i] = 0 } }
func powmod64(a,e,mod int64) int64 { res, m := int64(1), a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint64(a,e int64) int64 { res, m := int64(1), a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd64(a,b int64) int64 { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended64(a,b int64) (int64,int64,int64) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended64(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv64(a,m int64) (int64,bool) { g,x,_ := gcdExtended64(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func vecint64string(a []int64) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.FormatInt(a,10) }; return strings.Join(astr," ") }
func makefact64(n int,mod int64) ([]int64,[]int64) {
	fact,factinv := make([]int64,n+1),make([]int64,n+1)
	fact[0] = 1; for i:=1;i<=n;i++ { fact[i] = fact[i-1] * int64(i) % mod }
	factinv[n] = powmod64(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * int64(i+1) % mod }
	return fact,factinv
}
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	// If the array has 3 positive numbers or 3 negative numbers, then it cannot be closed
	T := gi()
	for tt:=1;tt<=T;tt++ {
		N := gi(); A := gis(N)
		z := 0; nz := ia(0); for _,a := range A { if a == 0 { z++ } else { nz = append(nz,a) } }
		good := true
		if len(nz) > 4 {
			good = false
		} else {
			sb := make(map[int64]bool)
			if z > 0 { sb[0] = true }
			for _,x := range nz { sb[int64(x)] = true }
			if z > 0 {
				for i:=0;i<len(nz);i++ {
					for j:=i+1;j<len(nz);j++ {
						s := int64(nz[i])+int64(nz[j])
						if !sb[s] { good = false }
					}
				}
			}
			for i:=0;i<len(nz);i++ {
				for j:=i+1;j<len(nz);j++ {
					for k:=j+1;k<len(nz);k++ {
						s := int64(nz[i])+int64(nz[j])+int64(nz[k])
						if !sb[s] { good = false }
					}
				}
			}
		}
		if good { fmt.Fprintln(wrtr,"YES") } else { fmt.Fprintln(wrtr,"NO") }
	}
}

package main

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

func main() {
	r, w := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var t, n int
	Fscan(r, &t)
	for t > 0 {
		t--
		Fscan(r, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(r, &a[i])
		}
		sort.Ints(a)
		if (a[1] == 0 && a[n-1] == 0) || (a[0] == 0 && a[n-2] == 0) {
			Fprintln(w, "YES")
			continue
		}
		if n == 3 {
			if a[0]+a[1] == 0 || a[0]+a[2] == 0 || a[1]+a[2] == 0 {
				Fprintln(w, "YES")
			} else {
				Fprintln(w, "NO")
			}
			continue
		}
		if n == 4 {
			for i := 0; i < n-2; i++ {
				for j := i+1; j < n-1; j++ {
					for k := j+1; k < n; k++ {
						if a[i]+a[j]+a[k] != a[0] && a[i]+a[j]+a[k] != a[1] && a[i]+a[j]+a[k] != a[2] && a[i]+a[j]+a[k] != a[3] {
							Fprintln(w, "NO")
							n = -1
							j = n
							i = n
							break
						}
					}
				}
			}
			if n == 4{
				Fprintln(w, "YES")
			}
			continue
		}
		if a[1] == 0 && a[n-2] == 0 && a[0] == -a[n-1] {
			Fprintln(w, "YES")
		} else {
			Fprintln(w, "NO")
		}
	}
}

package main

import (

	"bufio"
	"fmt"
	"os"
)

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

func check(a []int, mp map[int]bool) bool {

	for i := 0; i < len(a); i++ {

		for j := i + 1; j < len(a); j++ {

			for k := j + 1; k < len(a); k++ {

				sum := a[j] + a[i] + a[k]
				if !mp[sum] {

					return false
				}
			}
		}
	}
	return true
}

func solve(n int) {

	var (

		a, b []int
		negative = 0
		positive = 0
		zero = 0
		mp map[int]bool = map[int]bool{}
	)
	for i := 0; i < n; i++ {

		var x int
		fmt.Fscan(in, &x)
		a = append(a, x)
		if x < 0 {

			negative += 1
		} else if x > 0 {

			positive += 1
		} else {

			zero += 1
		}
		mp[x] = true
	}
	if zero >= n - 1 {

		fmt.Fprintln(out, "YES")
		return
	}
	if negative > 2 || positive > 2 {

		fmt.Fprintln(out, "NO")
		return
	}
	if zero > 0 && (negative > 1 || positive > 1) {

		fmt.Fprintln(out, "NO")
		return
	}
	zero = 0
	for i := 0; i < n; i++ {

		if a[i] == 0 {

			zero += 1
			if zero < 3 {

				b = append(b, 0)
			}
		} else {

			b = append(b, a[i])
		}
	}
	if check(b, mp) {

		fmt.Fprintln(out, "YES")
	} else {

		fmt.Fprintln(out, "NO")
	}
}
func main() {

	defer out.Flush()
	var T int
	fmt.Fscan(in, &T)

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

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

package main

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

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

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

		aa := make([]int64, 6)
		var a, b, z int
		var idx int
		for i := 0; i < n; i++ {
			var v int64
			fmt.Fscan(in, &v)
			if v < 0 {
				a++
			} else if v > 0 {
				b++
			} else {
				z++
			}

			if a < 3 && b < 3 && z < 3 {
				aa[idx] = v
				idx++
			}
		}

		f := true
		if a > 2 || b > 2 {
			f = false
		}
	Loop:
		for i := 0; i < idx; i++ {
			for j := i + 1; j < idx; j++ {
				for k := j + 1; k < idx; k++ {
					d := aa[i] + aa[j] + aa[k]
					var f2 bool
					for v := 0; v < idx; v++ {
						if aa[v] == d {
							f2 = true
							break
						}
					}
					if !f2 {
						f = false
						break Loop
					}
				}
			}
		}

		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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

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

		aa := make([]int64, 6)
		var a, b, z int
		var idx int
		for i := 0; i < n; i++ {
			var v int64
			fmt.Fscan(in, &v)
			if v < 0 {
				a++
			} else if v > 0 {
				b++
			} else {
				z++
			}

			if a <= 3 && b <= 3 && z <= 3 {
				aa[idx] = v
				idx++
			}
		}

		f := true
	Loop:
		for i := 0; i < idx; i++ {
			for j := i + 1; j < idx; j++ {
				for k := j + 1; k < idx; k++ {
					d := aa[i] + aa[j] + aa[k]
					var f2 bool
					for v := 0; v < idx; v++ {
						if aa[v] == d {
							f2 = true
							break
						}
					}
					if !f2 {
						f = false
						break Loop
					}
				}
			}
		}

		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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

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

		aa := make([]int64, 9)
		var a, b, z int
		var idx int
		for i := 0; i < n; i++ {
			var v int64
			fmt.Fscan(in, &v)
			if v < 0 {
				a++
			} else if v > 0 {
				b++
			} else {
				z++
			}

			if a < 3 && b < 3 && z < 3 {
				aa[idx] = v
				idx++
			}
		}

		f := true
		if a > 2 || b > 2 {
			f = false
		}
	Loop:
		for i := 0; i < idx; i++ {
			for j := i + 1; j < idx; j++ {
				for k := j + 1; k < idx; k++ {
					d := aa[i] + aa[j] + aa[k]
					var f2 bool
					for v := 0; v < idx; v++ {
						if aa[v] == d {
							f2 = true
							break
						}
					}
					if !f2 {
						f = false
						break Loop
					}
				}
			}
		}

		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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

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

		aa := make([]int64, 9)
		var a, b, z int
		var idx int
		for i := 0; i < n; i++ {
			var v int64
			fmt.Fscan(in, &v)
			if v < 0 {
				a++
			} else if v > 0 {
				b++
			} else {
				z++
			}

			if a <= 3 && b <= 3 && z <= 3 {
				aa[idx] = v
				idx++
			}
		}

		f := true
	Loop:
		for i := 0; i < idx; i++ {
			for j := i + 1; j < idx; j++ {
				for k := j + 1; k < idx; k++ {
					d := aa[i] + aa[j] + aa[k]
					var f2 bool
					for _, v := range aa {
						if v == d {
							f2 = true
							break
						}
					}
					if !f2 {
						f = false
						break Loop
					}
				}
			}
		}

		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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

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

		aa := make([]int64, 9)
		var a, b, z int
		var idx int
		for i := 0; i < n; i++ {
			var v int64
			fmt.Fscan(in, &v)
			if v < 0 {
				if a < 3 {
					aa[idx] = v
					idx++
				}
				a++
			} else if v > 0 {
				if b < 3 {
					aa[idx] = v
					idx++
				}
				b++
			} else {
				if z < 3 {
					aa[idx] = v
				}
				z++
			}
		}

		f := true
	Loop:
		for i := 0; i < idx; i++ {
			for j := i + 1; j < idx; j++ {
				for k := j + 1; k < idx; k++ {
					d := aa[i] + aa[j] + aa[k]
					var f2 bool
					for _, v := range aa {
						if v == d {
							f2 = true
							break
						}
					}
					if !f2 {
						f = false
						break Loop
					}
				}
			}
		}

		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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

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

		aa := make([]int, 9)
		var a, b, z int
		var idx int
		for i := 0; i < n; i++ {
			var v int
			fmt.Fscan(in, &v)
			if v < 0 {
				a++
			} else if v > 0 {
				b++
			} else {
				z++
			}

			if a <= 3 && b <= 3 && z <= 3 {
				aa[idx] = v
				idx++
			}
		}

		f := true
	Loop:
		for i := 0; i < idx; i++ {
			for j := i + 1; j < idx; j++ {
				for k := j + 1; k < idx; k++ {
					d := aa[i] + aa[j] + aa[k]
					var f2 bool
					for _, v := range aa {
						if v == d {
							f2 = true
							break
						}
					}
					if !f2 {
						f = false
						break Loop
					}
				}
			}
		}

		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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

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

		aa := make([]int, n)
		var a, b, z int
		var x, y int
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
			if aa[i] < 0 {
				a++
				x = aa[i]
			} else if aa[i] > 0 {
				b++
				y = aa[i]
			} else {
				z++
			}
		}

		f := true
		if a > 2 || b > 2 {
			f = false
		}

		if z > 0 && (a == 2 || b == 2) {
			f = false
		}

		if n > 3 && z != n {
			if x != y*-1 || z < n-2 {
				f = false
			}
		} else {
			d := aa[0] + aa[1] + aa[2]
			if d != aa[0] && d != aa[1] && d != aa[2] {
				f = false
			}
		}

		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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

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

		aa := make([]int, n)
		var a, b, z int
		var x, y int
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
			if aa[i] < 0 {
				a++
				x = aa[i]
			} else if aa[i] > 0 {
				b++
				y = aa[i]
			} else {
				z++
			}
		}

		f := true
		if a > 2 || b > 2 {
			f = false
		}

		if z > 0 && (a == 2 || b == 2) {
			f = false
		}

		if n > 3 && z != n {
			if x != y*-1 || z != n-2 {
				f = false
			}
		} else {
			d := aa[0] + aa[1] + aa[2]
			if d != aa[0] && d != aa[1] && d != aa[2] {
				f = false
			}
		}

		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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)

		aa := make([]int64, n)
		m := make(map[int64][]int, n)
		var f bool
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
			if len(m[aa[i]*-1]) > 0 {
				f = true
			}
			m[aa[i]] = append(m[aa[i]], i)
		}

		if !f {
			sort.Slice(aa, func(i, j int) bool { return aa[i] < aa[j] })
		Loop:
			for k := n - 3; k < n; k++ {
				for i := 0; i < k-1; i++ {
					for j := i + 1; j < k; j++ {
						g := m[aa[k]-aa[i]-aa[j]]
						for _, v := range g {
							if v != i && v != j {
								f = true
								break Loop
							}
						}
					}
				}
			}
		}
		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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)

		aa := make([]int64, n)
		m := make(map[int64]bool, n)
		var f bool
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
			if m[aa[i]*-1] {
				f = true
			}
			m[aa[i]] = true
		}

		if !f {
			sort.Slice(aa, func(i, j int) bool { return aa[i] < aa[j] })
		Loop:
			for k := n - 3; k < n; k++ {
				for i := 0; i < k-1; i++ {
					for j := i + 1; j < k; j++ {
						if m[aa[k]-aa[i]-aa[j]] {
							f = true
							break Loop
						}
					}
				}
			}
		}
		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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

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

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

		var f bool
	Loop:
		for i := 0; i < n-2; i++ {
			for j := i + 1; j < n-1; j++ {
				if m[-aa[i]] > j {
					f = true
					break Loop
				}
			}
		}

		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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

func slove() {
	var n int
	fmt.Fscan(r, &n)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	if n == 3 {
		sum := nums[0] + nums[1] + nums[2]
		if nums[0] == sum || nums[1] == sum || nums[2] == sum {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
		return
	}
	sort.Ints(nums)
	sum := nums[0] + nums[1] + nums[2]
	if sum != nums[0] && sum != nums[1] && sum != nums[2] {
		fmt.Fprintln(w, "NO")
		return
	}
	sum = nums[n-1] + nums[n-2] + nums[n-3]
	if sum != nums[n-1] && sum != nums[n-2] && sum != nums[n-3] {
		fmt.Fprintln(w, "NO")
		return
	}
	for i:=3;i<n-3;i++ {
		if nums[i] != 0 {
			fmt.Fprintln(w, "NO")
			return
		}
	}
	cnt := map[int]int{}
	for i := range nums {
		cnt[nums[i]]++
	}
	new := make([]int, 0)
	for i:=0;i<3;i++ {
		new = append(new, nums[i])
	}
	for i:=max(3, n-3);i<n;i++ {
		new = append(new, nums[i])
	}
	for i:=0;i<len(new);i++ {
		for j:=i+1;j<len(new);j++ {
			for k:=j+1;k<len(new);k++ {
				if _, ok := cnt[nums[i] + nums[j] + nums[k]]; !ok {
					fmt.Fprintln(w, "NO")
					return
				}
			}
		}
	}
	if cnt[0] > 0 {
		for i:=0;i<len(new);i++ {
			for j:=i+1;j<len(new);j++ {
				if _, ok := cnt[nums[i] + nums[j]]; !ok {
					fmt.Fprintln(w, "NO")
					return
				}
			}
		}
	}
	fmt.Fprintln(w, "YES")
}

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

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

package main

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

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

func slove() {
	var n int
	fmt.Fscan(r, &n)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	if n == 3 {
		sum := nums[0] + nums[1] + nums[2]
		if nums[0] == sum || nums[1] == sum || nums[2] == sum {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
		return
	}
	sort.Ints(nums)
	sum := nums[0] + nums[1] + nums[2]
	if sum != nums[0] && sum != nums[1] && sum != nums[2] {
		fmt.Fprintln(w, "NO")
		return
	}
	sum = nums[n-1] + nums[n-2] + nums[n-3]
	if sum != nums[n-1] && sum != nums[n-2] && sum != nums[n-3] {
		fmt.Fprintln(w, "NO")
		return
	}
	for i:=3;i<n-3;i++ {
		if nums[i] != 0 {
			fmt.Fprintln(w, "NO")
			return
		}
	}
	cnt := map[int]int{}
	for i := range nums {
		cnt[nums[i]]++
	}
	new := make([]int, 0)
	for i:=0;i<3;i++ {
		new = append(new, nums[i])
	}
	for i:=max(3, n-3);i<n;i++ {
		new = append(new, nums[i])
	}
	for i:=0;i<len(new);i++ {
		for j:=i+1;j<len(new);j++ {
			for k:=j+1;k<len(new);k++ {
				if _, ok := cnt[nums[i] + nums[j] + nums[k]]; !ok {
					fmt.Fprintln(w, "NO")
					return
				}
			}
		}
	}
	if len(nums) > 6 {
		for i:=0;i<len(new);i++ {
			for j:=i+1;j<len(new);j++ {
				if _, ok := cnt[nums[i] + nums[j]]; !ok {
					fmt.Fprintln(w, "NO")
					return
				}
			}
		}
	}
	fmt.Fprintln(w, "YES")
}

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

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

package main

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

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

func slove() {
	var n int
	fmt.Fscan(r, &n)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	if n == 3 {
		sum := nums[0] + nums[1] + nums[2]
		if nums[0] == sum || nums[1] == sum || nums[2] == sum {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
		return
	}
	sort.Ints(nums)
	sum := nums[0] + nums[1] + nums[2]
	if sum != nums[0] && sum != nums[1] && sum != nums[2] {
		fmt.Fprintln(w, "NO")
		return
	}
	sum = nums[n-1] + nums[n-2] + nums[n-3]
	if sum != nums[n-1] && sum != nums[n-2] && sum != nums[n-3] {
		fmt.Fprintln(w, "NO")
		return
	}
	for i:=3;i<n-3;i++ {
		if nums[i] != 0 {
			fmt.Fprintln(w, "NO")
			return
		}
	}
	if nums[2] == 0 && nums[n-3] != 0 {
		fmt.Fprintln(w, "NO")
		return
	}
	if nums[2] != 0 && nums[n-3] == 0 {
		fmt.Fprintln(w, "NO")
		return
	}
	cnt := map[int]int{}
	for i := range nums {
		cnt[nums[i]]++
	}
	new := make([]int, 0)
	for i:=0;i<3;i++ {
		new = append(new, nums[i])
	}
	for i:=max(3, n-3);i<n;i++ {
		new = append(new, nums[i])
	}
	for i:=3;i<n-3;i++ {
		if nums[i] != 0 {
			fmt.Fprintln(w, "NO")
			return
		}
	}
	for i:=0;i<len(new);i++ {
		for j:=i+1;j<len(new);j++ {
			for k:=j+1;k<len(new);k++ {
				if _, ok := cnt[nums[i] + nums[j] + nums[k]]; !ok {
					fmt.Fprintln(w, "NO")
					return
				}
			}
		}
	}
	fmt.Fprintln(w, "YES")
}

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

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

package main

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

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

func slove() {
	var n int
	fmt.Fscan(r, &n)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	if n == 3 {
		sum := nums[0] + nums[1] + nums[2]
		if nums[0] == sum || nums[1] == sum || nums[2] == sum {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
		return
	}
	sort.Ints(nums)
	sum := nums[0] + nums[1] + nums[2]
	if sum != nums[0] && sum != nums[1] && sum != nums[2] {
		fmt.Fprintln(w, "NO")
		return
	}
	sum = nums[n-1] + nums[n-2] + nums[n-3]
	if sum != nums[n-1] && sum != nums[n-2] && sum != nums[n-3] {
		fmt.Fprintln(w, "NO")
		return
	}
	for i:=3;i<n-3;i++ {
		if nums[i] != 0 {
			fmt.Fprintln(w, "NO")
			return
		}
	}
	if nums[2] == 0 && nums[n-3] != 0 {
		fmt.Fprintln(w, "NO")
		return
	}
	if nums[2] != 0 && nums[n-3] == 0 {
		fmt.Fprintln(w, "NO")
		return
	}
	cnt := map[int]int{}
	for i := range nums {
		cnt[nums[i]]++
	}
	new := make([]int, 0)
	for i:=0;i<3;i++ {
		new = append(new, nums[i])
	}
	for i:=max(3, n-3);i<n;i++ {
		new = append(new, nums[i])
	}
	for i:=0;i<len(new);i++ {
		for j:=i+1;j<len(new);j++ {
			for k:=j+1;k<len(new);k++ {
				if _, ok := cnt[nums[i] + nums[j] + nums[k]]; !ok {
					fmt.Fprintln(w, "NO")
					return
				}
			}
		}
	}
	fmt.Fprintln(w, "YES")
}

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

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

package main

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

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

func slove() {
	var n int
	fmt.Fscan(r, &n)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	if n == 3 {
		sum := nums[0] + nums[1] + nums[2]
		if nums[0] == sum || nums[1] == sum || nums[2] == sum {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
		return
	}
	sort.Ints(nums)
	sum := nums[0] + nums[1] + nums[2]
	if sum != nums[0] && sum != nums[1] && sum != nums[2] {
		fmt.Fprintln(w, "NO")
		return
	}
	sum = nums[n-1] + nums[n-2] + nums[n-3]
	if sum != nums[n-1] && sum != nums[n-2] && sum != nums[n-3] {
		fmt.Fprintln(w, "NO")
		return
	}
	fmt.Fprintln(w, "YES")
}

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

package main

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

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

func solve(arr []int) string {
	positives := []int{}
	negatives := []int{}
	zeros := 0
	for i := 0; i < len(arr); i++ {
		if arr[i] > 0 {
			positives = append(positives, arr[i])
		} else if arr[i] < 0 {
			negatives = append(negatives, arr[i])
		} else {
			zeros++
		}
	}
	if len(positives) > 2 || len(negatives) > 2 {
		return "NO"
	}
	if zeros > 2 {
		zeros = 2
	}
	final := append(positives, negatives...)
	for i := 0; i < zeros; i++ {
		final = append(final, 0)
	}
	//fmt.Println(final)
	for i := 0; i < len(final); i++ {
		for j := i + 1; j < len(final); j++ {
			for k := j + 1; k < len(final); k++ {
				if final[i]+final[j]+final[k] != 0 {
					return "NO"
				}
			}
		}
	}
	return "YES"
}

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

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

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

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

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

func solve(arr []int) string {
	positives := []int{}
	negatives := []int{}
	zeros := 0
	for i := 0; i < len(arr); i++ {
		if arr[i] > 0 {
			positives = append(positives, arr[i])
		} else if arr[i] < 0 {
			negatives = append(negatives, arr[i])
		} else {
			zeros++
		}
	}
	if len(positives) > 2 && len(negatives) > 2 {
		return "NO"
	}
	if zeros > 2 {
		zeros = 2
	}
	final := append(positives, negatives...)
	for i := 0; i < zeros; i++ {
		final = append(final, 0)
	}
	//fmt.Println(final)
	for i := 0; i < len(final); i++ {
		for j := i + 1; j < len(final); j++ {
			for k := j + 1; k < len(final); k++ {
				if final[i]+final[j]+final[k] != 0 {
					return "NO"
				}
			}
		}
	}
	return "YES"
}

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

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

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

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

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

func solve(arr []int) string {
	positives := []int{}
	negatives := []int{}
	for i := 0; i < len(arr); i++ {
		if arr[i] > 0 {
			positives = append(positives, arr[i])
		} else if arr[i] < 0 {
			negatives = append(negatives, arr[i])
		}
	}
	if len(positives) == 0 && len(negatives) == 0 {
		return "YES"
	} else if len(arr) == 3 && arr[0]+arr[1]+arr[2] == 0 {
		return "YES"
	}
	return "NO"
}

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

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

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

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

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

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

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

func main() {
	in := bufio.NewReader(os.Stdin)
	t := readInt(in)
	for ; t > 0; t-- {
		readInt(in)
		arr := readArrInt(in)
		if judge(arr) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func judge(arr []int) bool {
	var tmp []int
	m := make(map[int]struct{})
	var negCnt, posCnt int
	for _, val := range arr {
		if val > 0 {
			posCnt++
			tmp = append(tmp, val)
		}
		if val < 0 {
			negCnt++
			tmp = append(tmp, val)
		}
		m[val] = struct{}{}
	}
	if posCnt >= 3 || negCnt >= 3 {
		return false
	}
	n := len(tmp)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			for k := j + 1; k < n; k++ {
				if _, has := m[tmp[i]+tmp[j]+tmp[k]]; !has {
					return false
				}
			}
		}
	}
	return true
}

package main

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

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

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

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

func main() {
	in := bufio.NewReader(os.Stdin)
	t := readInt(in)
	for ; t > 0; t-- {
		readInt(in)
		arr := readArrInt(in)
		if judge(arr) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func judge(arr []int) bool {
	var tmp []int
	m := make(map[int]struct{})
	var negCnt, posCnt int
	for _, val := range arr {
		if val > 0 {
			posCnt++
			tmp = append(tmp, val)
		}
		if val < 0 {
			negCnt++
			tmp = append(tmp, val)
		}
		m[val] = struct{}{}
	}
	if posCnt >= 3 || negCnt >= 3 {
		return false
	}
	n := len(tmp)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			for k := j + 1; k < n; k++ {
				if _, has := m[arr[i]+arr[j]+arr[k]]; !has {
					return false
				}
			}
		}
	}
	return true
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int     { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }
func gis(n int) []int  { res := make([]int,n); for i:=0;i<n;i++ { res[i] = gi() }; return res }
func gf() float64 { f,e := strconv.ParseFloat(gs(),64); if e != nil {panic(e)}; return f }
func gbs() []byte { return []byte(gs()) }
func gfs(n int) []float64  { res := make([]float64,n); for i:=0;i<n;i++ { res[i] = gf() }; return res }
func gss(n int) []string  { res := make([]string,n); for i:=0;i<n;i++ { res[i] = gs() }; return res }
func gi64() int64     { i,e := strconv.ParseInt(gs(),10,64); if e != nil {panic(e)}; return i }
func gis64(n int) []int64  { res := make([]int64,n); for i:=0;i<n;i++ { res[i] = gi64() }; return res }

func ia(m int) []int { return make([]int,m) }
func iai(m int,v int) []int { a := make([]int,m); for i:=0;i<m;i++ { a[i] = v }; return a }
func twodi(n int,m int,v int) [][]int {
	r := make([][]int,n); for i:=0;i<n;i++ { x := make([]int,m); for j:=0;j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill2(m int) ([]int,[]int) { a,b := ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i] = gi(),gi()}; return a,b }
func fill3(m int) ([]int,[]int,[]int) { a,b,c := ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i] = gi(),gi(),gi()}; return a,b,c }
func fill4(m int) ([]int,[]int,[]int,[]int) { a,b,c,d := ia(m),ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i],d[i] = gi(),gi(),gi(),gi()}; return a,b,c,d }
func abs(a int) int { if a < 0 { return -a }; return a }
func rev(a []int) { i,j := 0,len(a)-1; for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max(a,b int) int { if a > b { return a }; return b }
func min(a,b int) int { if a > b { return b }; return a }
func maxarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr(a []int) int { ans := 0; for _,aa := range(a) { ans += aa }; return ans }
func zeroarr(a []int) { for i:=0; i<len(a); i++ { a[i] = 0 } }
func powmod(a,e,mod int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint(a,e int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd(a,b int) int { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended(a,b int) (int,int,int) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv(a,m int) (int,bool) { g,x,_ := gcdExtended(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func vecintstring(a []int) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.Itoa(a) }; return strings.Join(astr," ") }
func makefact(n int,mod int) ([]int,[]int) {
	fact,factinv := make([]int,n+1),make([]int,n+1)
	fact[0] = 1; for i:=1;i<=n;i++ { fact[i] = fact[i-1] * i % mod }
	factinv[n] = powmod(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * (i+1) % mod }
	return fact,factinv
}

func ia64(m int) []int64 { return make([]int64,m) }
func iai64(m int,v int64) []int64 { a := make([]int64,m); for i:=0;i<m;i++ { a[i] = v }; return a }
func twodi64(n int,m int,v int64) [][]int64 {
	r := make([][]int64,n); for i:=0;i<n;i++ { x := make([]int64,m); for j:=0;j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill264(m int) ([]int64,[]int64) { a,b := ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i] = gi64(),gi64()}; return a,b }
func fill364(m int) ([]int64,[]int64,[]int64) { a,b,c := ia64(m),ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i],c[i] = gi64(),gi64(),gi64()}; return a,b,c }
func fill464(m int) ([]int64,[]int64,[]int64,[]int64) { a,b,c,d := ia64(m),ia64(m),ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i],c[i],d[i] = gi64(),gi64(),gi64(),gi64()}; return a,b,c,d }
func abs64(a int64) int64 { if a < 0 { return -a }; return a }
func rev64(a []int64) { i,j := 0,len(a)-1; for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max64(a,b int64) int64 { if a > b { return a }; return b }
func min64(a,b int64) int64 { if a > b { return b }; return a }
func maxarr64(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr64(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr64(a []int64) int64 { ans := int64(0); for _,aa := range(a) { ans += aa }; return ans }
func zeroarr64(a []int64) { for i:=0; i<len(a); i++ { a[i] = 0 } }
func powmod64(a,e,mod int64) int64 { res, m := int64(1), a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint64(a,e int64) int64 { res, m := int64(1), a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd64(a,b int64) int64 { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended64(a,b int64) (int64,int64,int64) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended64(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv64(a,m int64) (int64,bool) { g,x,_ := gcdExtended64(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func vecint64string(a []int64) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.FormatInt(a,10) }; return strings.Join(astr," ") }
func makefact64(n int,mod int64) ([]int64,[]int64) {
	fact,factinv := make([]int64,n+1),make([]int64,n+1)
	fact[0] = 1; for i:=1;i<=n;i++ { fact[i] = fact[i-1] * int64(i) % mod }
	factinv[n] = powmod64(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * int64(i+1) % mod }
	return fact,factinv
}
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	// If the array has 3 positive numbers or 3 negative numbers, then it cannot be closed
	T := gi()
	for tt:=1;tt<=T;tt++ {
		N := gi(); A := gis(N)
		z := 0; nz := ia(0); for _,a := range A { if a == 0 { z++ } else { nz = append(nz,a) } }
		good := true
		if len(nz) > 4 {
			good = false
		} else {
			sb := make(map[int64]bool)
			if z > 0 { sb[0] = true }
			for _,x := range nz { sb[int64(x)] = true }
			if z > 0 {
				for i:=0;i<len(nz);i++ {
					for j:=i+1;j<len(nz);j++ {
						s := int64(i)+int64(j)
						if !sb[s] { good = false }
					}
				}
			}
			for i:=0;i<len(nz);i++ {
				for j:=i+1;j<len(nz);j++ {
					for k:=j+1;k<len(nz);k++ {
						s := int64(i)+int64(j)+int64(k)
						if !sb[s] { good = false }
					}
				}
			}
		}
		if good { fmt.Fprintln(wrtr,"YES") } else { fmt.Fprintln(wrtr,"NO") }
	}
}


Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degreev and sv, were the first integer is the number of vertices adjacent to vertex v, and the second integer is the XOR sum of the numbers of vertices adjacent to v (if there were no adjacent vertices, he wrote down 0). Next day Misha couldn't remember what graph he initially had. Misha has values degreev and sv left, though. Help him find the number of edges and the edges of the initial graph. It is guaranteed that there exists a forest that corresponds to the numbers written by Misha.

The first line contains integer n (1 ≤ n ≤ 216), the number of vertices in the graph. The i-th of the next lines contains numbers degreei and si (0 ≤ degreei ≤ n - 1, 0 ≤ si < 216), separated by a space.

In the first line print number m, the number of edges of the graph. Next print m lines, each containing two distinct numbers, a and b (0 ≤ a ≤ n - 1, 0 ≤ b ≤ n - 1), corresponding to edge (a, b). Edges can be printed in any order; vertices of the edge can also be printed in any order.

NoteThe XOR sum of numbers is the result of bitwise adding numbers modulo 2. This operation exists in many modern programming languages. For example, in languages C++, Java and Python it is represented as "^", and in Pascal — as "xor".

package main

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

var readWriter = bufio.NewReadWriter(bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout))

func main() {
	defer readWriter.Flush()

	var n int

	fmt.Fscan(readWriter, &n)

	data := make([][2]int, n)
	var results [][2]int

	var queue []int
	var curQueueSize int

	for i := 0; i < n; i++ {
		fmt.Fscan(readWriter, &data[i][0], &data[i][1])

		if data[i][0] == 1 {
			queue = append(queue, i)
			curQueueSize++
		}
	}

	for i := 0; i < curQueueSize; i++ {
		if data[queue[i]][0] == 0 {
			continue
		}

		if data[queue[i]][0] == 1 {
			data[queue[i]][0]--
			data[data[queue[i]][1]][0]--
			data[data[queue[i]][1]][1] ^= queue[i]
			queue = append(queue, data[queue[i]][1])
			curQueueSize++

			result := [2]int{queue[i], data[queue[i]][1]}
			results = append(results, result)
		}
	}

	fmt.Fprintln(readWriter, len(results))

	for i := 0; i < len(results); i++ {
		fmt.Fprintln(readWriter, results[i][0], results[i][1])
	}
}

package main

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

var readWriter = bufio.NewReadWriter(bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout))

func main() {
	defer readWriter.Flush()

	var n int

	fmt.Fscan(readWriter, &n)

	data := make([][2]int, n)
	var results [][2]int

	var queue []int

	for i := 0; i < n; i++ {
		fmt.Fscan(readWriter, &data[i][0], &data[i][1])

		if data[i][0] == 1 {
			queue = append(queue, i)
		}
	}

	for len(queue) > 0 {
		index := queue[0]

		if data[index][0] == 0 {
			queue = queue[1:len(queue)]
			continue
		}

		if data[index][0] == 1 {
			data[index][0]--
			data[data[index][1]][0]--
			data[data[index][1]][1] ^= index
			queue = append(queue, data[index][1])

			result := [2]int{index, data[index][1]}
			results = append(results, result)
		}

		queue = queue[1:len(queue)]
	}

	fmt.Fprintln(readWriter, len(results))

	for i := 0; i < len(results); i++ {
		fmt.Fprintln(readWriter, results[i][0], results[i][1])
	}
}

package main

import (
	"fmt"
)

func main() {
	var n int

	fmt.Scan(&n)

	data := make([][2]int, n)
	var results [][2]int

	var queue []int

	for i := 0; i < n; i++ {
		fmt.Scan(&data[i][0], &data[i][1])

		if data[i][0] == 1 {
			queue = append(queue, i)
		}
	}

	for len(queue) > 0 {
		if data[queue[0]][0] == 0 {
			queue = queue[1:len(queue)]
			continue
		}

		if data[queue[0]][0] == 1 {
			data[data[queue[0]][1]][0]--
			data[data[queue[0]][1]][1] ^= queue[0]
			queue = append(queue, data[queue[0]][1])

			result := [2]int{queue[0], data[queue[0]][1]}
			results = append(results, result)
		}

		queue = queue[1:len(queue)]
	}

	fmt.Println(len(results))

	for i := 0; i < len(results); i++ {
		fmt.Println(results[i][0], results[i][1])
	}
}

package main

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

var readWriter = bufio.NewReadWriter(bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout))

func main() {
	defer readWriter.Flush()

	var n int

	fmt.Fscan(readWriter, &n)

	data := make([][2]int, n)
	var results [][2]int

	var queue []int
	var curQueueSize int

	for i := 0; i < n; i++ {
		fmt.Fscan(readWriter, &data[i][0], &data[i][1])

		if data[i][0] == 1 {
			queue = append(queue, i)
			curQueueSize++
		}
	}

	for i := 0; i < curQueueSize; i++ {
		if data[queue[i]][0] == 0 {
			queue = queue[1:len(queue)]
			curQueueSize--
			continue
		}

		if data[queue[i]][0] == 1 {
			data[queue[i]][0]--
			data[data[queue[i]][1]][0]--
			data[data[queue[i]][1]][1] ^= queue[i]
			queue = append(queue, data[queue[i]][1])
			curQueueSize++

			result := [2]int{queue[i], data[queue[i]][1]}
			results = append(results, result)
		}

		queue = queue[1:len(queue)]
		curQueueSize--
	}

	fmt.Fprintln(readWriter, len(results))

	for i := 0; i < len(results); i++ {
		fmt.Fprintln(readWriter, results[i][0], results[i][1])
	}
}