An array $$$b$$$ of length $$$k$$$ is called good if its arithmetic mean is equal to $$$1$$$. More formally, if $$$$$$\frac{b_1 + \cdots + b_k}{k}=1.$$$$$$Note that the value $$$\frac{b_1+\cdots+b_k}{k}$$$ is not rounded up or down. For example, the array $$$[1,1,1,2]$$$ has an arithmetic mean of $$$1.25$$$, which is not equal to $$$1$$$.You are given an integer array $$$a$$$ of length $$$n$$$. In an operation, you can append a non-negative integer to the end of the array. What's the minimum number of operations required to make the array good?We have a proof that it is always possible with finitely many operations.

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 50$$$) — the length of the initial array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1,\ldots,a_n$$$ ($$$-10^4\leq a_i \leq 10^4$$$), the elements of the array.

For each test case, output a single integer — the minimum number of non-negative integers you have to append to the array so that the arithmetic mean of the array will be exactly $$$1$$$.

NoteIn the first test case, we don't need to add any element because the arithmetic mean of the array is already $$$1$$$, so the answer is $$$0$$$.In the second test case, the arithmetic mean is not $$$1$$$ initially so we need to add at least one more number. If we add $$$0$$$ then the arithmetic mean of the whole array becomes $$$1$$$, so the answer is $$$1$$$.In the third test case, the minimum number of elements that need to be added is $$$16$$$ since only non-negative integers can be added.In the fourth test case, we can add a single integer $$$4$$$. The arithmetic mean becomes $$$\frac{-2+4}{2}$$$ which is equal to $$$1$$$.

package main

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

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

    scanner.Scan()
    tests, _ := strconv.Atoi(scanner.Text())

    for i := 0; i < tests; i += 1 {
        scanner.Scan()
        n, _ := strconv.Atoi(scanner.Text())

        sum := 0
        for j := 0; j < n; j += 1 {
            scanner.Scan()
            num, _ := strconv.Atoi(scanner.Text())
            sum += num
        }

        if sum < n {
            fmt.Println(1)
        } else {
            fmt.Println(sum - n)
        }
    }
}

package main
import (
    "os"
    "fmt"
    "bufio"
)
func sum(a []int) int {
    s := 0
    for i := range a {
        s += a[i]
    }
    return s
}
var rd = bufio.NewReader(os.Stdin)
func main() {
    q := 0
    fmt.Fscan(rd, &q)
    for t := 0; t < q; t++ {
        n := 0
        fmt.Fscan(rd, &n)
        a := make([]int, n)
        for i := range a {
            fmt.Fscan(rd, &a[i])
        }
        if sum(a) < n {
            fmt.Println(1)
       } else {
            fmt.Println(sum(a) - n)
       }
    }
}

package main
import (
    "os"
    "fmt"
    "bufio"
)
func sum(a []int) int {
    s := 0
    for i := range a {
        s += a[i]
    }
    return s
}
var rd = bufio.NewReader(os.Stdin)
func main() {
    q := 0
    fmt.Fscan(rd, &q)
    for t := 0; t < q; t++ {
        n := 0
        fmt.Fscan(rd, &n)
        a := make([]int, n)
        for i := range a {
            fmt.Fscan(rd, &a[i])
        }
        s:= sum(a)
        if s < n {
            fmt.Println(1)
       } else {
            fmt.Println(s - n)
       }
    }
}

package main
import (
    "os"
    "fmt"
    "bufio"
)
var rd = bufio.NewReader(os.Stdin)
func main() {
    q := 0
    fmt.Fscan(rd, &q)
    for t := 0; t < q; t++ {
        n, s := 0, 0
        fmt.Fscan(rd, &n)
        a := make([]int, n)
        for i := range a {
            fmt.Fscan(rd, &a[i])
            s += a[i]
        }
        if s < n {
            fmt.Println(1)
       } else {
            fmt.Println(s - n)
       }
    }
}

package main

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

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

	for t > 0 {
		var n int64
		fmt.Fscanf(r, "%d\n", &n)
		s := make([]int64, n)
		for i := 0; int64(i) < n; i++ {
			fmt.Fscanf(r, "%d ", &s[i])
		}
		fmt.Fscanf(r, "\n")
		fmt.Println(solve(s))
		t--
	}
}

func solve(s []int64) int64 {
	var sum int64
	for _, v := range s {
		sum += v
	}
	if float64(sum)/float64(len(s)) == 1 {
		return 0
	}
	if sum <= 0 {
		return 1
	}
	if sum <= int64(len(s)) {
		return 1
	}
	return sum - int64(len(s))
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n,sum int
		fmt.Scan(&n)
		var list []int = make([]int,n)
		for j:=0;j<n;j++{
			fmt.Scan(&list[j])
			sum+=list[j]
		}
		if sum-n < 0 {
			fmt.Println(1)
		}else{
			fmt.Println(sum-n)
		}
	}
}
func abs(x int) int {
	var result int
	if x > 0 {
		result = x
	} else {
		if x < 0 {
			result = x*-1
		}
	}
	return result
}

package main

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

func sum(arr []int32) int32 {
	total := int32(0)
	for _, value := range arr {
		total += value
	}
	return total
}

func solve(n int32, arr []int32) int32 {
	total := sum(arr)
	if total < n {
		return 1
	} else {
		return total - n
	}
}

func arrayScanf(in *bufio.Reader, n int32, arr *[]int32) {
	m := int32(0)
	for i := int32(0); i < n; i++ {
		if i > 0 {
			fmt.Fscanf(in, " ")
		}
		fmt.Fscanf(in, "%d", &m)
		*arr = append(*arr, m)
	}
	fmt.Fscanf(in, "\n")
}

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

	tt := int32(0)
	fmt.Fscanf(in, "%d\n", &tt)
	for tt > 0 {
		n := int32(0)
		a := []int32{}
		fmt.Fscanf(in, "%d\n", &n)
		arrayScanf(in, n, &a)
		fmt.Fprintf(out, "%d\n", solve(n, a))
		tt--
	}
	out.Flush()
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n, sum int
		_, _ = fmt.Fscan(in, &n)

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

			sum += temp
		}

		if sum == n {
			fmt.Println(0)
			continue
		}

		if sum < n {
			fmt.Println(1)
			continue
		}

		fmt.Println(sum - n)
	}
}

package main

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

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

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

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

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

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

/**
 Run solve the problem CF1537A
 Date: 21/08/21
 User: pepradere
 URL: https://codeforces.com/problemset/problem/1529/A
 Problem: CF1537A
**/
func (in *CF1537A) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		size := in.NextInt()
		sum := 0
		for i := 0; i < size; i++ {
			num := in.NextInt()
			sum += num
		}
		ans := 0

		if size > sum {
			ans = 1
		} else if size < sum {
			ans = sum - size
		}

		fmt.Println(ans)
	}

}

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

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

package main

import "fmt"

var t int
var n int

func main() {
	fmt.Scan(&t)
	for t > 0 {
		sum := 0
		var x int
		fmt.Scan(&n)
		for i := 1; i <= n; i++ {
			fmt.Scan(&x)
			sum += x
		}
		if sum == n {
			fmt.Println(0)
		} else {
			if sum <= 0 {
				fmt.Println(1)
			} else {
				if sum > n {
					fmt.Println(sum - n)
				} else {
					fmt.Println(1)
				}
			}
		}
		t--
	}
}

package main

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

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

	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		s := 0
		for _, v := range a {
			s += v
		}
		if s >=n {Fprintln(out, s-n)
		} else {Fprintln(out, 1)}
	}

	T := 1
	Fscan(in, &T) //
	for Case := 1; Case <= T; Case++ {
		solve(Case)
	}

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

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

package main

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

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

	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		s := 0
		for _, v := range a {
			s += v
		}
		if s >=n {
			Fprintln(out, s-n)
		} else {
			Fprintln(out, 1)
		}
	}

	T := 1
	Fscan(in, &T) //
	for Case := 1; Case <= T; Case++ {
		solve(Case)
	}

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

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

package main

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

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

	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		sum := 0
		for _, v := range a {
			sum += v
		}
		if sum >=n {
			Fprintln(out, sum-n)
		} else {
			Fprintln(out, 1)
		}
	}

	T := 1
	Fscan(in, &T) //
	for Case := 1; Case <= T; Case++ {
		solve(Case)
	}

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

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

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a, b int
		fmt.Scan(&a)
		sum := 0
		for j := 0; j < a; j++ {
			fmt.Scan(&b)
			sum += b
		}
		if sum-a < 0 {
			fmt.Println("1")
		} else {
			fmt.Println(sum - a)
		}
	}
}

package main

import "fmt"

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

	for i:= 0; i < n; i++ {
		fmt.Scanf("%d\n", &m)
		k = 0
		l = 0
		for j := 0; j < m; j++ {
			fmt.Scanf("%d", &val)
			k++
			l += val
		}
		fmt.Scanln()

		if k <= l {
			fmt.Println(l - k)
		} else {
			fmt.Println(1)
		}
	}
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	i := 0
	for scanner.Scan() {
	    m := scanner.Text()
	    if i!=0 && i%2 == 0{
	        res2 := strings.Split(m, " ")
	        var length int64
	        length = int64(len(res2))
		var add int64
		for _,j:= range res2 {
		    i,_ := strconv.ParseInt(j, 10, 64)
		    add+=i
		}
		if add >= length{
		    fmt.Println(add-length)
		}else{
		    fmt.Println(1)
		}
	    }
	    i++
	}

}

package main

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

func main() {
	var (
		t int
		n int
	)
	fmt.Scanf("%d\n", &t)
	scanner := bufio.NewScanner(os.Stdin)
	for i := 0; i < t; i++ {
		sum := 0
		scanner.Scan()
		n, _ = strconv.Atoi(scanner.Text())
		scanner.Scan()
		as := strings.Split(scanner.Text(), " ")
		for j := 0; j < n; j++ {
			tn, _ := strconv.Atoi(as[j])
			sum += tn
		}
		if sum < n {
			fmt.Println(1)
		} else if sum > n {
			fmt.Println(sum - n)
		} else {
			fmt.Println(0)
		}
	}
}

package main

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

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

	for test, _ := strconv.ParseInt(getString(reader), 10, 32); test > 0; test-- {
		n, _ := strconv.ParseInt(getString(reader), 10, 32)
		A := getIntln(reader)
		var sum int64
		for _, v := range A {
			sum += v
		}
		if sum == n {
			writer.WriteString("0\n")
		} else if sum > n {
			writer.WriteString(fmt.Sprintln(sum - n))
		} else {
			writer.WriteString("1\n")
		}
	}
	writer.Flush()
}

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

}

func getIntln(in *bufio.Reader) []int64 {
	b := strings.Split(getString(in), " ")
	res := make([]int64, len(b))
	for k, v := range b {
		res[k], _ = strconv.ParseInt(v, 10, 32)
	}
	return res
}

package main

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

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

func solve(n int, a []int) int {
	var sum int
	for _, x := range a {
		sum += x
	}
	if sum > n {
		return sum - n
	}
	if sum < n {
		return 1
	}
	return 0
}

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

package main

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

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

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

func process() {
	var n int64
	var sum int64

	scanf("%d\n", &n)

	for i := int64(0); i < n; i++ {
		var num int64
		scanf("%d", &num)
		sum += num
	}
	scanf("\n")
	// printf("Sum = %d\n", sum)
	if sum < n {
		printf("1\n")
	} else {
		printf("%d\n", sum-n)
	}
}

func main() {
	defer writer.Flush()

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

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

}

package main

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

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

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

func (io *IO) ReadInt64() int64 {
	var res int64
	fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

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

func (io *IO) ReadPairInt64() (int64, int64) {
	var a, b int64
	fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

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

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

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

func main() {
	io := NewIO(os.Stdin, os.Stdout)
	t := io.ReadInt()
	for ; t > 0; t-- {
		n := io.ReadInt()
		a := io.ReadIntSlice(n)
		var sum int
		for _, v := range a {
			sum += int(v)
		}
		if sum >= len(a) {
			fmt.Fprintln(os.Stdout, sum - len(a))
		} else {
			fmt.Fprintln(os.Stdout, 1)
		}
	}
}

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

var t int

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

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

		}
		if sum == n {
			fmt.Println(0)
		}
		if sum > n {
			fmt.Println(sum - n)
		}
		if sum < n {
			fmt.Println(1)
		}

	}

}

package main

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

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

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

	var n, a int
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		sum := 0
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a)
			sum += a
		}

		if sum < n {
			fmt.Fprintln(writer, 1)
			continue
		}

		if sum == n {
			fmt.Fprintln(writer, 0)
			continue
		}

		fmt.Fprintln(writer, sum-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 -= 1 {
		var n int
		fmt.Fscan(in, &n)

		a := make([]int, n)

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

		var sum int = 0

		for i := 0; i < n; i += 1 {
			sum += a[i]
		}

		if sum == n {
			fmt.Fprintln(out, 0)
			continue
		}

		if sum > n {
			fmt.Fprintln(out, sum - n)
		} else {
			fmt.Fprintln(out, 1)
		}
	}
}

package main

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

func init() {
	log.SetFlags(0)
	log.SetOutput(ioutil.Discard)
}

func solve(a []int) int {
	log.Printf("a = %#v\n", a)
	sum := 0
	for _, v := range a {
		sum += v
	}
	if sum >= len(a) {
		return sum - len(a)
	}
	return 1
}

func main() {
	log.Println("start")

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

	num := 0
	fmt.Fscan(in, &num)
	for i := 0; i < num; i++ {
		size := 0
		fmt.Fscan(in, &size)
		a := make([]int, size)
		for i := 0; i < size; i++ {
			fmt.Fscan(in, &a[i])
		}
		fmt.Printf("%d\n", solve(a))

	}
	log.Println("__end__")
}

package main

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

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

	var t int

	fmt.Fscan(r, &t)

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

		a := make([]int, n)

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

		fmt.Println(solve(a, n))
	}
}

func solve(a []int, n int) int {
	var s int

	for i := 0; i < n; i++ {
		s += a[i]
	}

	if s >= 0 {
		if s >= (n) {
			return s - n

		} else {
			return 1
		}
	} else {
		return 1
	}
}

package main

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

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

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

    for i := 0; i < tests; i += 1 {
        var n int
        fmt.Fscanf(reader, "%d ", &n)

        sum := 0
        for j := 0; j < n; j += 1 {
            var num int
            fmt.Fscanf(reader, "%d ", &num)
            sum += num
        }

        fmt.Fprintln(writer, "SUM IS", sum)

        if sum < n {
            fmt.Fprintln(writer, 1)
        } else {
            fmt.Fprintln(writer, sum - n)
        }
    }
}

package main

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

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

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

    for i := 0; i < tests; i += 1 {
        var n int
        fmt.Fscanf(reader, "%d ", &n)

        sum := 0
        for j := 0; j < n; j += 1 {
            var num int
            fmt.Fscanf(reader, "%d ", &num)
            sum += num
        }

        if sum < n {
            fmt.Fprintln(writer, 1)
        } else {
            fmt.Fprintln(writer, sum - n)
        }
    }
}

package main

import (
    "fmt"
)

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

    for i := 0; i < tests; i += 1 {
        var n int
        fmt.Scanf("%d\n", &n)

        sum := 0
        for j := 0; j < n; j += 1 {
            var num int
            fmt.Scanf("%d", &num)
            sum += num
        }

        var needed int
        if sum < n {
            needed = 1
        } else {
            needed = sum - n
        }
        fmt.Println(needed)
    }
}

package main

import (
    "fmt"
)

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

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

        sum := 0
        for j := 0; j < n; j += 1 {
            var num int
            fmt.Scanf("%d", &num)
            fmt.Println("read", num)
            sum += num
        }

        var needed int
        if sum < n {
            needed = 1
        } else {
            needed = sum - n
        }
        fmt.Println(needed)
    }
}

package main

import (
    "fmt"
)

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

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

        sum := 0
        for j := 0; j < n; j += 1 {
            var num int
            fmt.Scanf("%d", &num)
            sum += num
        }

        var needed int
        if sum < n {
            needed = 1
        } else {
            needed = sum - n
        }
        fmt.Println(needed)
    }
}

package main

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

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

	for t > 0 {
		var n int64
		fmt.Fscanf(r, "%d\n", &n)
		s := make([]int64, n)
		for i := 0; int64(i) < n; i++ {
			fmt.Fscanf(r, "%d ", &s[i])
		}
		fmt.Fscanf(r, "\n")
		fmt.Println(solve(s))
		t--
	}
}

func solve(s []int64) int64 {
	var sum int64
	for _, v := range s {
		sum += v
	}
	if float64(sum)/float64(len(s)) == 1 {
		return 0
	}
	if sum == 0 {
		return 1
	}
	if sum < 0 {
		return 1
	}
	return sum - int64(len(s))
}

package main

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

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

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

func solve(s []int) int {
	sum := 0
	for _, v := range s {
		sum += v
	}
	if float64(sum)/float64(len(s)) == 1 {
		return 0
	}
	if sum == 0 {
		return 1
	}
	if sum < 0 {
		return 1
	}
	return sum - len(s)
}

package main

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

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

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

func solve(s []int) int {
	sum := 0
	for _, v := range s {
		sum += v
	}
	if float64(sum)/float64(len(s)) == 1 {
		return 0
	}
	if sum == 0 {
		return 0
	}
	if sum < 0 {
		return 1
	}
	v := math.Abs(float64(sum))
	return int(v) - len(s)
}

package main

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

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

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

func solve(s []int) int {
	sum := 0
	for _, v := range s {
		sum += v
	}
	if float64(sum)/float64(len(s)) == 1 {
		return 0
	}
	v := math.Abs(float64(sum))
	return int(v) - len(s)
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n,sum int
		fmt.Scan(&n)
		var list []int = make([]int,n)
		for j:=0;j<n;j++{
			fmt.Scan(&list[j])
			sum+=list[j]
		}
		if sum <= 0 {
			fmt.Println(1)
		}else{
			fmt.Println(sum-n)
		}
	}
}
func abs(x int) int {
	var result int
	if x > 0 {
		result = x
	} else {
		if x < 0 {
			result = x*-1
		}
	}
	return result
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n,sum int
		fmt.Scan(&n)
		var list []int = make([]int,n)
		for j:=0;j<n;j++{
			fmt.Scan(&list[j])
			sum+=list[j]
		}
		if sum-n <= 0 {
			fmt.Println(1)
		}else{
			fmt.Println(sum-n)
		}
	}
}
func abs(x int) int {
	var result int
	if x > 0 {
		result = x
	} else {
		if x < 0 {
			result = x*-1
		}
	}
	return result
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n,sum int
		fmt.Scan(&n)
		var list []int = make([]int,n)
		for j:=0;j<n;j++{
			fmt.Scan(&list[j])
			sum+=list[j]
		}
		fmt.Println(abs(sum)-n)
	}
}
func abs(x int) int {
	var result int
	if x > 0 {
		result = x
	} else {
		if x < 0 {
			result = x*-1
		}
	}
	return result
}

package main

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

func sum(arr []int32) int32 {
	total := int32(0)
	for _, value := range arr {
		total += value
	}
	return total
}

func solve(n int32, arr []int32) int32 {
	total := sum(arr)
	if total < n {
		total = n - total
		if total%10000 != 0 {
			return total/10000 + 1
		} else {
			return total / 10000
		}
	} else {
		return total - n
	}
}

func arrayScanf(in *bufio.Reader, n int32, arr *[]int32) {
	m := int32(0)
	for i := int32(0); i < n; i++ {
		if i > 0 {
			fmt.Fscanf(in, " ")
		}
		fmt.Fscanf(in, "%d", &m)
		*arr = append(*arr, m)
	}
	fmt.Fscanf(in, "\n")
}

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

	tt := int32(0)
	fmt.Fscanf(in, "%d\n", &tt)
	for tt > 0 {
		n := int32(0)
		a := []int32{}
		fmt.Fscanf(in, "%d\n", &n)
		arrayScanf(in, n, &a)
		fmt.Fprintf(out, "%d\n", solve(n, a))
		tt--
	}
	out.Flush()
}

package main

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

func sum(arr []int32) int32 {
	total := int32(0)
	for _, value := range arr {
		total += value
	}
	return total
}

func solve(n int32, arr []int32) int32 {
	total := sum(arr)
	if total <= 0 {
		total = 0 - total
		if total%10000 != 0 {
			return total/10000 + 1
		} else {
			return total / 10000
		}
	} else {
		return total - n
	}
}

func arrayScanf(in *bufio.Reader, n int32, arr *[]int32) {
	m := int32(0)
	for i := int32(0); i < n; i++ {
		if i > 0 {
			fmt.Fscanf(in, " ")
		}
		fmt.Fscanf(in, "%d", &m)
		*arr = append(*arr, m)
	}
	fmt.Fscanf(in, "\n")
}

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

	tt := int32(0)
	fmt.Fscanf(in, "%d\n", &tt)
	for tt > 0 {
		n := int32(0)
		a := []int32{}
		fmt.Fscanf(in, "%d\n", &n)
		arrayScanf(in, n, &a)
		fmt.Fprintf(out, "%d\n", solve(n, a))
		tt--
	}
	out.Flush()
}

package main

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

func sum(arr []int32) int32 {
	total := int32(0)
	for _, value := range arr {
		total += value
	}
	return total
}

func solve(n int32, arr []int32) int32 {
	total := sum(arr)
	if total <= 0 {
		return 1
	} else {
		return total - n
	}
}

func arrayScanf(in *bufio.Reader, n int32, arr *[]int32) {
	m := int32(0)
	for i := int32(0); i < n; i++ {
		if i > 0 {
			fmt.Fscanf(in, " ")
		}
		fmt.Fscanf(in, "%d", &m)
		*arr = append(*arr, m)
	}
	fmt.Fscanf(in, "\n")
}

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

	tt := int32(0)
	fmt.Fscanf(in, "%d\n", &tt)
	for tt > 0 {
		n := int32(0)
		a := []int32{}
		fmt.Fscanf(in, "%d\n", &n)
		arrayScanf(in, n, &a)
		fmt.Fprintf(out, "%d\n", solve(n, a))
		tt--
	}
	out.Flush()
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n, sum int
		_, _ = fmt.Fscan(in, &n)

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

			sum += temp
		}

		if sum == n {
			fmt.Println(0)
			continue
		}

		if sum < 1 {
			fmt.Println(1)
			continue
		}

		fmt.Println(sum - n)
	}
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n, sum int
		_, _ = fmt.Fscan(in, &n)

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

			sum += temp
		}

		if sum/n == 1 && sum%n == 0 {
			fmt.Println(0)
			continue
		}

		if sum < 1 {
			fmt.Println(1)
			continue
		}

		fmt.Println(sum - n)
	}
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n, sum int
		_, _ = fmt.Fscan(in, &n)

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

			sum += temp
		}

		if sum == 1 {
			fmt.Println(0)
			continue
		}

		if sum < 1 {
			fmt.Println(1)
			continue
		}

		fmt.Println(sum - n)
	}
}

package main

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

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

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

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

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

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

/**
 Run solve the problem CF1537A
 Date: 21/08/21
 User: pepradere
 URL: https://codeforces.com/problemset/problem/1529/A
 Problem: CF1537A
**/
func (in *CF1537A) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		n := in.NextInt()
		sum := 0
		for i := 0; i < n; i++ {
			num := in.NextInt()
			sum += num
		}
		size := n

		ans := 0
		if sum < 0 {
			ans = 1
			sum = size
		}
		if size > sum {
			ans = size - sum
		} else if size < sum {
			ans = sum - size
		}

		fmt.Println(ans)
	}

}

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

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

package main

import "fmt"

var t int
var n int

func main() {
	fmt.Scan(&t)
	for t > 0 {
		sum := 0
		var x int
		fmt.Scan(&n)
		for i := 1; i <= n; i++ {
			fmt.Scan(&x)
			sum += x
		}
		if sum == n {
			fmt.Println(0)
		} else {
			if sum <= 0 {
				fmt.Println(1)
			} else {
				fmt.Println(sum - n)
			}
		}
		t--
	}
}

package main

import "fmt"

var t int
var n int

func main() {
	fmt.Scan(&t)
	for t > 0 {
		sum := 0
		var x int
		fmt.Scan(&n)
		for i := 1; i <= n; i++ {
			fmt.Scan(&x)
			sum += x
		}
		if sum == n {
			fmt.Println(0)
		} else {
			if sum < 0 {
				fmt.Println(1)
			} else {
				fmt.Println(sum - n)
			}
		}
		t--
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a, b int
		fmt.Scan(&a)
		sum := 0
		for j := 0; j < a; j++ {
			fmt.Scan(&b)
			sum += b
		}
		if sum-b < 0 {
			fmt.Println("1")
		} else {
			fmt.Println(sum - b)
		}
	}
}

package main

import "fmt"

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

	for i:= 0; i < n; i++ {
		fmt.Scanf("%d", &m)
		k = 0
		l = 0
		for j := 0; j < m; j++ {
			fmt.Scanf("%d", &val)
			k++
			l += val
		}

		if k <= l {
			fmt.Println(l - k)
		} else {
			fmt.Println(1)
		}
	}
}

package main

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

func main() {
	var test int
	fmt.Scanf("%d", &test)
	scanner := bufio.NewScanner(os.Stdin)
	i := 0
	for scanner.Scan() {
	    m := scanner.Text()
	    if i%2 != 0{
	        res2 := strings.Split(m, " ")
	        var length int64
	        length = int64(len(res2))
		var add int64
		for _,j:= range res2 {
		    i,_ := strconv.ParseInt(j, 10, 64)
		    add+=i
		}
		if add >= length{
		    fmt.Println(add-length)
		}else{
		    fmt.Println(1)
		}
	    }
	    i++
	}

}


Roma (a popular Russian name that means 'Roman') loves the Little Lvov Elephant's lucky numbers.Let us remind you that lucky numbers are positive integers whose decimal representation only contains lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Roma's got n positive integers. He wonders, how many of those integers have not more than k lucky digits? Help him, write the program that solves the problem.

The first line contains two integers n, k (1 ≤ n, k ≤ 100). The second line contains n integers ai (1 ≤ ai ≤ 109) — the numbers that Roma has.  The numbers in the lines are separated by single spaces.

In a single line print a single integer — the answer to the problem.

NoteIn the first sample all numbers contain at most four lucky digits, so the answer is 3.In the second sample number 447 doesn't fit in, as it contains more than two lucky digits. All other numbers are fine, so the answer is 2.

package main
import (
	"fmt"
	//"unicode/utf8"
	//"strconv"
)

func main() {
	var n,k,a,cnt int
	ans:=0
	fmt.Scan(&n,&k)
	for i:=0;i<n;i++ {
		cnt=0
		fmt.Scan(&a)
		for ;a>0; {
			if( a%10==4 || a%10==7) {
				cnt++
			}
			a/=10
		}
		if cnt<=k {
			ans++
		}
	}
	fmt.Println(ans)
}

package main

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

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

	var result int = 0

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; scanner.Scan(); i++ {
		a, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}
		if no_more_than_k(a, k) {
			result++
		}
	}

	fmt.Println(result)
}

func no_more_than_k(a, k int) bool {
	cnt := 0
	for a > 0 {
		d := a % 10
		if d == 4 || d == 7 {
			cnt++
			if cnt > k {
				return false
			}
		}
		a = a / 10
	}
	return true
}

package main

import "fmt"

func main() {
    var n,k int
    var a string
    fmt.Scan(&n,&k)
    ans := 0
    for i := 0; i < n; i++ {
        fmt.Scan(&a)
        cnt := 0
        for _, v := range a {
            if (v == '4') || (v == '7') { cnt++ }
        }
        if cnt <= k { ans++ }
    }
    fmt.Println(ans)
}

// 262A-mic
package main

import (
	"fmt"
)

func main() {
	var n, k, cou, m int
	var num string
	fmt.Scan(&n, &k)
	for i := 0; i < n; i++ {
		fmt.Scan(&num)
		for s := 0; s < len(num); s++ {
			if num[s] == '4' || num[s] == '7' {
				cou++
			}
		}
		if cou <= k {
			m++
		}
		cou = 0
	}
	fmt.Println(m)
}

package main
import "fmt"
func main () {
    var n,m,c,z int
    c=0
    z=0
    var t []byte
    fmt.Scan(&n,&m)
    for i:=0; i<n; i++ {
        fmt.Scan(&t)
        for _,j := range t {
            if j==52 || j==55 {
                z++
            }
        }
        if z<=m {
            c++
        }
        z=0
    }
    fmt.Println(c)
}

package main

import (
	"fmt"
)

func get_lucky_digits_num(num string) int {
	ret := 0
	for i := 0; i < len(num); i++ {
		if num[i] == '4' || num[i] == '7' {
			ret++
		}
	}

	return ret
}

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

	var num string
	ans := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&num)
		if get_lucky_digits_num(num) <= k {
			ans++
		}
	}

	fmt.Println(ans)
}


While Mike was walking in the subway, all the stuff in his back-bag dropped on the ground. There were several fax messages among them. He concatenated these strings in some order and now he has string s.  He is not sure if this is his own back-bag or someone else's. He remembered that there were exactly k messages in his own bag, each was a palindrome string and all those strings had the same length.He asked you to help him and tell him if he has worn his own back-bag. Check if the given string s is a concatenation of k palindromes of the same length.

The first line of input contains string s containing lowercase English letters (1 ≤ |s| ≤ 1000). The second line contains integer k (1 ≤ k ≤ 1000).

Print "YES"(without quotes) if he has worn his own back-bag or "NO"(without quotes) otherwise.

NotePalindrome is a string reading the same forward and backward.In the second sample, the faxes in his back-bag can be "saddas" and "tavvat".

package main

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

var (
	ss string
)

func main() {
	//fin, _ := os.Open("in.txt")
	in := bufio.NewScanner(os.Stdin)
	//in := bufio.NewScanner(fin)
	for in.Scan() {
		ss = in.Text()
		//fmt.Fscan(fin, &k)
		in.Scan()
		k, _ := strconv.Atoi(in.Text())
		//fmt.Println(ss, k)
		l := len(ss)
		if l == k {
			fmt.Println("YES")
		} else if l%k != 0 {
			fmt.Println("NO")
		} else {
			f := l / k
			flag := true
			for i := 0; i < l; i += f {
				if check(i, i+f-1) != true {
					flag = false
					break
				}
			}
			if flag == true {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}
	}
}

func check(s, t int) bool {
	for i, j := s, t; i < j; i, j = i+1, j-1 {
		if ss[i] != ss[j] {
			return false
		}
	}
	return true
}

package main

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

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

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

	s := next()
	k := nextInt()

	if len(s)%k != 0 {
		println("NO")
		return
	}

	n := len(s) / k

	for i := 0; i < k; i++ {
		begin, end := i*n, (i+1)*n
		if !isPalindrome(s[begin:end]) {
			println("NO")
			return
		}
	}

	println("YES")
}

func isPalindrome(s string) bool {
	for i := 0; i < len(s)/2; i++ {
		if s[i] != s[len(s)-i-1] {
			return false
		}
	}

	return true
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

func next() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  s := getS()
  k := getI()
  feasible := false
  if len(s)%k == 0 {
    feasible = true
    span := len(s)/k
    for i := span; i <= len(s); i += span {
      for j, k := i-span, i-1; j < k; j, k = j+1, k-1 {
        if s[j] != s[k] {
          feasible = false
          break
        }
      }
      if !feasible {
        break
      }
    }
  }
  result := "NO"
  if feasible {
    result = "YES"
  }
  writer.WriteString(fmt.Sprintf("%s\n", result))
}

package main

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

func main() {
	var s string
	var k int
	re := regexp.MustCompile(`\r?\n`)

	reader := bufio.NewReader(os.Stdin)
	if _s, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		s = re.ReplaceAllString(_s, "")
	}

	if _k, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		_k = re.ReplaceAllString(_k, "")
		_vk, err := strconv.Atoi(_k)
		if err != nil {
			return
		}
		k = _vk
	}

	var ok bool = true
	l := len(s)
	if l%k != 0 {
		ok = false
	} else {
		n := l / k
		for i := 0; i < k; i++ {
			for j := 0; j < n/2; j++ {
				if s[n*i+j] != s[n*i+n-j-1] {
					ok = false
					break
				}
			}
			if !ok {
				break
			}
		}
	}

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

package main

import (
  "fmt"
  "os"
)

func main(){
  var s string
  var k int
  fmt.Scan(&s, &k)
  if len(s) % k != 0 {
    fmt.Println("NO")
  }else{
    l := len(s)/k
    for i := 0;i < k;i++ {
      for j := 0;j < l; j++ {
        if s[j+i*l] != s[l-j-1+i*l] {
          fmt.Println("NO")
          os.Exit(0)
        }
      }
    }
    fmt.Println("YES")
  }
}

package main

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

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

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

func getLine() string {
	s, _ := reader.ReadString('\n')
	if strings.HasSuffix(s, "\r\n") {
		s = s[:len(s)-2]
	} else if strings.HasSuffix(s, "\n") {
		s = s[:len(s)-1]
	}
	return s
}
func getLine2Int() (n int) {
	scanf("%d\n", &n)
	return
}
func getLine2Int2() (a, b int) {
	scanf("%d %d\n", &a, &b)
	return
}
func getLine2Ints(n int) []int {
	ans := make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d ", &ans[i])
	}
	scanf("%d\n", &ans[n-1])
	return ans
}

func pcheck(i bool) {
	if i {
		printf("YES\n")
	} else {
		printf("NO\n")
	}
}

var debug = true

func see(a interface{}) {
	if debug {
		printf("DEBUG:%v\n", a)
	}
}

func checks(s []byte) bool {
	for i := 0; i < len(s)-i; i++ {
		if s[i] != s[len(s)-i-1] {
			return false
		}
	}
	return true
}

func main() {
	defer writer.Flush()

	s := getLine()
	k := getLine2Int()
	ok := true
	if len(s)%k != 0 {
		ok = false
	}
	dex := len(s) / k
	for i := 0; ok && i < len(s); i += len(s) / k {
		ok = checks([]byte(s[i : i+dex]))
	}
	pcheck(ok)
}

package main

import (
	"fmt"
)

func pal(arr []rune) bool {
	for i := 0; i < len(arr)/2; i++ {
		if arr[i] != arr[len(arr)-i-1] {
			return false
		}
	}
	return true
}

func main() {
	var str string
	var k int
	fmt.Scan(&str, &k)

	if len(str)%k != 0 {
		fmt.Println("NO")
		return
	}

	isPal := true
	s := []rune(str)
	size := len(str) / k

	for i := 0; i < k && isPal; i++ {
		isPal = isPal && pal(s[i*size:i*size+size])
	}

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

}

package main

import (
	"fmt"
)

func pal(arr []rune) bool {
  for i:=0; i< len(arr)/2;i++ {
    if arr[i] != arr[len(arr)-i-1] {
      return false
    }
  }
  return true
}

func main() {
  var str string
  var k int
  fmt.Scan(&str, &k)

  if len(str) % k != 0 {
    fmt.Println("NO")
    return
  }

  isPal := true
  s := []rune(str)
  size := len(str)/k

  for i:=0; i < k && isPal ; i++ {
    isPal = isPal && pal(s[i*size:i*size+size])
  }

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

}

package main

import (
	"fmt"
)

func check(s string, l int) bool {
	for i := 0; i < l/2; i++ {
		if s[i] != s[l-1-i] {
			return false
		}
	}

	return true
}

func solve(s string, k int) bool {
	length := len(s)
	if length%k != 0 {
		return false
	}

	d := length / k
	for i := 0; i < length; i += d {
		if !check(s[i:i+d], d) {
			return false
		}
	}

	return true
}

func main() {
	var s string
	var k int
	fmt.Scan(&s)
	fmt.Scan(&k)

	if solve(s, k) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

import "fmt"

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

func isPalindrome(s string, l, r int) bool {
  for l < r {
    if s[l] != s[r] {
      return false
    }
    l++
    r--
  }

  return true
}

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

  N := len(s) / K

  ret := true

  if len(s) % K != 0 {
    ret = false
  }

  for k := 0; ret && k < K; k++ {
    if !isPalindrome(s, k * N, k * N + N - 1) {
      ret = false
    }
  }

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

package main

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

var (
	ss string
)

func main() {
	//fin, _ := os.Open("in.txt")
	in := bufio.NewScanner(os.Stdin)
	//in := bufio.NewScanner(fin)
	for in.Scan() {
		ss = in.Text()
		//fmt.Fscan(fin, &k)
		in.Scan()
		k, _ := strconv.Atoi(in.Text())
		fmt.Println(ss, k)
		l := len(ss)
		if l == k {
			fmt.Println("YES")
		} else {
			f := l / k
			flag := true
			for i := 0; i < l; i += f {
				if check(i, i+f-1) != true {
					flag = false
					break
				}
			}
			if flag == true {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}
	}
}

func check(s, t int) bool {
	for i, j := s, t; i < j; i, j = i+1, j-1 {
		if ss[i] != ss[j] {
			return false
		}
	}
	return true
}

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  s := getS()
  k := getI()
  feasible := true
  if len(s)%k == 0 {
    span := len(s)/k
    for i := span; i <= len(s); i += span {
      for j, k := i-span, i-1; j < k; j, k = j+1, k-1 {
        if s[j] != s[k] {
          feasible = false
          break
        }
      }
      if !feasible {
        break
      }
    }
  }
  result := "NO"
  if feasible {
    result = "YES"
  }
  writer.WriteString(fmt.Sprintf("%s\n", result))
}

package main

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

func main() {
	var s string
	var k int

	reader := bufio.NewReader(os.Stdin)
	if _s, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		s = _s
	}

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

	l := len(s)
	if l > 1 && s[l-2] == '\r' {
		l -= 2
	} else if s[l-1] == '\n' {
		l -= 1
	}

	var ok bool = true
	if l%k != 0 {
		ok = false
	} else {
		n := l / k
		for i := 0; i < k; i++ {
			for j := 0; j < n/2; j++ {
				if s[n*i+j] != s[n*i+n-j-1] {
					ok = false
					break
				}
			}
			if !ok {
				break
			}
		}
	}

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

package main

import "fmt"

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

func isPalindrome(s string, l, r int) bool {
  for l < r {
    if s[l] != s[r] {
      return false
    }
    l++
    r--
  }

  return true
}

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

  N := len(s) / K

  ret := true

  for k := 0; k < K; k++ {
    if !isPalindrome(s, k * N, k * N + N - 1) {
      ret = false
      break
    }
  }

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


A positive integer is called composite if it can be represented as a product of two positive integers, both greater than $$$1$$$. For example, the following numbers are composite: $$$6$$$, $$$4$$$, $$$120$$$, $$$27$$$. The following numbers aren't: $$$1$$$, $$$2$$$, $$$3$$$, $$$17$$$, $$$97$$$.Alice is given a sequence of $$$n$$$ composite numbers $$$a_1,a_2,\ldots,a_n$$$.She wants to choose an integer $$$m \le 11$$$ and color each element one of $$$m$$$ colors from $$$1$$$ to $$$m$$$ so that:  for each color from $$$1$$$ to $$$m$$$ there is at least one element of this color;  each element is colored and colored exactly one color;  the greatest common divisor of any two elements that are colored the same color is greater than $$$1$$$, i.e. $$$\gcd(a_i, a_j)>1$$$ for each pair $$$i, j$$$ if these elements are colored the same color. Note that equal elements can be colored different colors — you just have to choose one of $$$m$$$ colors for each of the indices from $$$1$$$ to $$$n$$$.Alice showed already that if all $$$a_i \le 1000$$$ then she can always solve the task by choosing some $$$m \le 11$$$.Help Alice to find the required coloring. Note that you don't have to minimize or maximize the number of colors, you just have to find the solution with some $$$m$$$ from $$$1$$$ to $$$11$$$.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then the descriptions of the test cases follow. The first line of the test case contains a single integer $$$n$$$ ($$$1 \le n \le 1000$$$) — the amount of numbers in a sequence $$$a$$$. The second line of the test case contains $$$n$$$ composite integers $$$a_1,a_2,\ldots,a_n$$$ ($$$4 \le a_i \le 1000$$$). It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$10^4$$$.

For each test case print $$$2$$$ lines. The first line should contain a single integer $$$m$$$ ($$$1 \le m \le 11$$$) — the number of used colors. Consider colors to be numbered from $$$1$$$ to $$$m$$$. The second line should contain any coloring that satisfies the above conditions. Print $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le m$$$), where $$$c_i$$$ is the color of the $$$i$$$-th element. If there are multiple solutions then you can print any of them. Note that you don't have to minimize or maximize the number of colors, you just have to find the solution with some $$$m$$$ from $$$1$$$ to $$$11$$$. Remember that each color from $$$1$$$ to $$$m$$$ should be used at least once. Any two elements of the same color should not be coprime (i.e. their GCD should be greater than $$$1$$$).

NoteIn the first test case, $$$\gcd(6,10)=2$$$, $$$\gcd(6,15)=3$$$ and $$$\gcd(10,15)=5$$$. Therefore, it's valid to color all elements the same color. Note that there are other colorings which satisfy Alice's requirement in this test case.In the second test case there is only one element of each color, so the coloring definitely satisfies Alice's requirement.

package main

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

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

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

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

	return arr, nil
}

var primeNumbers = []int{
	2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31,
}

func main() {
	defer writer.Flush()

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

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

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

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

	colors := make([]int, len(numbers))
	colorsByLCD := map[int]int{}
	maxColor := 0
NUMBERS:
	for i, number := range numbers {
		for _, prime := range primeNumbers {
			if number%prime == 0 {
				color, ok := colorsByLCD[prime]
				if !ok {
					maxColor++
					color = maxColor
					colorsByLCD[prime] = color
				}
				colors[i] = color
				continue NUMBERS
			}
		}
	}
	printf("%d\n", maxColor)
	printf("%d", colors[0])
	for i := 1; i < len(colors); i++ {
		printf(" %d", colors[i])
	}
	printf("\n")
}

package main

import "fmt"

var primes []int

func main() {
	primes = primeNumbers(1000)
	// var t int = 1
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		solveTestCase()
	}
}

func solveTestCase() {
	array := readIntArray(readInt())

	primeToIndex := make(map[int][]int, len(primes))
	indexToPrimes := make([][]int, len(array))
	for index, value := range array {
		indexToPrimes[index] = setOfDivisorPrimes(index, value, primeToIndex)
	}

	colored := make([]int, len(array))
	color := 1

	for _, prime := range primes[:11] {
		if list, ok := primeToIndex[prime]; ok {
			used := false
			for _, v := range list {
				if colored[v] == 0 {
					colored[v] = color
					used = true
				}
			}
			if used {
				color++
			}
		}
	}
	/*
		for i, v := range indexToPrimes {
			fmt.Printf("\t%d: %d: ", i, array[i])
			for _, vi := range v {
				fmt.Print(" ", vi)
			}
			fmt.Println()
		}

		for index := range array {
			if colored[index] == 0 {
				colorPath(index, color, indexToPrimes, primeToIndex, colored)
				color++
			}
		}
	*/
	fmt.Println(color - 1)
	for _, e := range colored {
		fmt.Print(e, " ")
	}
	fmt.Println()

	// fmt.Println(indexToPrimes)
	// fmt.Println(primes[:50])
	// fmt.Println(primeToIndex)
}

func colorPath(index int, color int, indexToPrimes [][]int, primeToIndex map[int][]int, colored []int) {
	colored[index] = color

	for _, prime := range indexToPrimes[index] {
		for _, value := range primeToIndex[prime] {
			if colored[value] == 0 {
				colorPath(value, color, indexToPrimes, primeToIndex, colored)
			}
		}
	}

}

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

func setOfDivisorPrimes(index int, e int, primeToIndex map[int][]int) []int {
	result := []int{}
	for _, prime := range primes {
		if e == 1 {
			break
		}

		if e%prime == 0 {
			result = append(result, prime)

			value := primeToIndex[prime]
			value = append(value, index)
			primeToIndex[prime] = value

			for e%prime == 0 {
				e /= prime
			}
		}
	}

	return result
}

func readInt() int {
	// return 23
	var e int
	fmt.Scan(&e)
	return e
}

func readIntArray(size int) []int {
	// result := []int{437, 519, 865, 808, 909, 391, 194, 291, 237, 395, 323, 365, 511, 497, 781, 737, 871, 559, 731, 697, 779, 841, 961}
	result := make([]int, size)
	for i := 0; i < size; i++ {
		fmt.Scan(&result[i])
	}
	return result
}

func primeNumbers(n int) []int {
	notPrime := make([]bool, n+1)
	for i := 2; i <= n; i++ {
		if !notPrime[i] {
			for j := i * i; j <= n; j += i {
				notPrime[j] = true
			}
		}
	}

	count := 0
	for _, v := range notPrime[2:] {
		if !v {
			count++
		}
	}
	result := make([]int, 0, count)
	for i, v := range notPrime[2:] {
		if !v {
			result = append(result, i+2)
		}
	}

	return result
}

/*
	0: 437:  19 23
	1: 519:  3 173
	2: 865:  5 173
	3: 808:  2 101
	4: 909:  3 101
	5: 391:  17 23
	6: 194:  2 97
	7: 291:  3 97
	8: 237:  3 79
	9: 395:  5 79
	10: 323:  17 19
	11: 365:  5 73
	12: 511:  7 73
	13: 497:  7 71
	14: 781:  11 71
	15: 737:  11 67
	16: 871:  13 67
	17: 559:  13 43
	18: 731:  17 43
	19: 697:  17 41
	20: 779:  19 41
	21: 841:  29
	22: 961:  31
*/

package main

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

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

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

	p := []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31}

	for t := in(); t > 0; t-- {
		n := in()
		a := make([]int, n)

		for i := range a {
			a[i] = in()
		}

		b := make([]int, n)

		cnt := 0

		for i := range p {
			okay := false
			for j := range a {
				if b[j] == 0 && a[j]%p[i] == 0 {
					b[j] = cnt + 1
					okay = true
				}
			}

			if okay {
				cnt++
			}
		}

		fmt.Println(cnt)

		for i := range b {
			fmt.Print(b[i], " ")
		}

		fmt.Println()
	}

}

/*
URL:
https://codeforces.com/problemset/problem/1332/B
*/

package main

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

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

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

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

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

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

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

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t int

	n int
	A []int

	P []int
)

func main() {
	_, P = sieve(50)

	t = ReadInt()
	for i := 0; i < t; i++ {
		n = ReadInt()
		A = ReadIntSlice(n)

		solve()
	}
}

func solve() {
	B := make([]int, n)

	for i := 0; i < 11; i++ {
		p := P[i]

		for j := 0; j < n; j++ {
			if A[j]%p == 0 && B[j] == 0 {
				B[j] = i + 1
			}
		}
	}

	pressed, _, _ := ZaAtsu1Dim(B, 1)
	fmt.Println(Max(pressed...))
	fmt.Println(PrintIntsLine(pressed...))
}

// ZaAtsu1Dim returns 3 values.
// pressed: pressed slice of the original slice
// orgToPress: map for translating original value to pressed value
// pressToOrg: reverse resolution of orgToPress
// O(nlogn)
func ZaAtsu1Dim(org []int, initVal int) (pressed []int, orgToPress, pressToOrg map[int]int) {
	pressed = make([]int, len(org))
	copy(pressed, org)
	sort.Sort(sort.IntSlice(pressed))

	orgToPress = make(map[int]int)
	for i := 0; i < len(org); i++ {
		if i == 0 {
			orgToPress[pressed[0]] = initVal
			continue
		}

		if pressed[i-1] != pressed[i] {
			initVal++
			orgToPress[pressed[i]] = initVal
		}
	}

	for i := 0; i < len(org); i++ {
		pressed[i] = orgToPress[org[i]]
	}

	pressToOrg = make(map[int]int)
	for k, v := range orgToPress {
		pressToOrg[v] = k
	}

	return
}

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

// エラトステネスの篩: O(NloglogN)
// n以下の素数の数と素数のスライスを返す
func sieve(n int) (int, []int) {
	// var prime [2000000 + 5]int
	prime := []int{}
	var isPrime [2000000 + 5 + 1]bool

	p := 0
	for i := 0; i <= n; i++ {
		isPrime[i] = true
	}
	isPrime[0], isPrime[1] = false, false

	for i := 2; i <= n; i++ {
		// iがtrueで残っている場合は素数認定し、自分より大きい倍数を取り除いていく
		if isPrime[i] {
			// prime[p] = i
			prime = append(prime, i)
			p++

			// 倍数の除去
			for j := 2 * i; j <= n; j += i {
				isPrime[j] = false
			}
		}
	}

	return p, prime
}

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

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

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

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

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

	return string(res)
}

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

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

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

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1332B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	ps := [...]int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31}

	var t, n, v int
	for Fscan(in, &t); t > 0; t-- {
		c := map[int]int{}
		Fscan(in, &n)
		ans := make([]interface{}, n)
		for i := range ans {
			Fscan(in, &v)
			for _, p := range ps {
				if v%p == 0 {
					if c[p] == 0 {
						c[p] = len(c) + 1
					}
					ans[i] = c[p]
					break
				}
			}
		}
		Fprintln(out, len(c))
		Fprintln(out, ans...)
	}
}

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

package main

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

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

type writerImpl struct {
    *bufio.Writer
}

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

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

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

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

type wordScannerImpl struct {
    *bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
    s := bufio.NewScanner(reader)
    s.Split(bufio.ScanWords)
    return &wordScannerImpl{Scanner: s}
}

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

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

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

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

func main() {
    defer writer.Flush()
    t := reader.NextInt64()
    for ; t > 0; t-- {
        n := reader.NextInt64()
        aa := []int64{}
        for ; n > 0; n-- {
            aa = append(aa, reader.NextInt64())
        }
        uColors, colors := sol(aa)
        writer.Printf("%d\n", uColors)
        for _, v := range colors {
            writer.Printf("%d ", v)
        }
        writer.Printf("\n")
    }
}

var primes = []int64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31}

func sol(aa []int64) (int64, []int64) {
    res := make([]int64, len(aa))
    for i := range aa {
        for _, p := range primes {
            if aa[i] % p == 0 {
                res[i] = p
                break
            }
        }
    }

    counter := int64(0)
    m := map[int64]int64{}
    for _, r := range res {
        if m[r] == 0 {
            counter++
            m[r] = counter
        }
    }
    for i := range res {
        res[i] = m[res[i]]
    }
    return counter, res
}

package main

import "fmt"

var primes []int

func main() {
	primes = primeNumbers(1000)
	// var t int = 1
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		solveTestCase()
	}
}

func solveTestCase() {
	array := readIntArray(readInt())

	primeToIndex := make(map[int][]int, len(primes))
	indexToPrimes := make([][]int, len(array))
	for index, value := range array {
		indexToPrimes[index] = setOfDivisorPrimes(index, value, primeToIndex)
	}

	colored := make([]int, len(array))
	color := 0

	for _, prime := range primes[:11] {
		if list, ok := primeToIndex[prime]; ok {
			color++
			for _, v := range list {
				colored[v] = color
			}
		}
	}
	/*
		for i, v := range indexToPrimes {
			fmt.Printf("\t%d: %d: ", i, array[i])
			for _, vi := range v {
				fmt.Print(" ", vi)
			}
			fmt.Println()
		}

		for index := range array {
			if colored[index] == 0 {
				colorPath(index, color, indexToPrimes, primeToIndex, colored)
				color++
			}
		}
	*/
	fmt.Println(color)
	for _, e := range colored {
		fmt.Print(e, " ")
	}
	fmt.Println()

	// fmt.Println(indexToPrimes)
	// fmt.Println(primes[:50])
	// fmt.Println(primeToIndex)
}

func colorPath(index int, color int, indexToPrimes [][]int, primeToIndex map[int][]int, colored []int) {
	colored[index] = color

	for _, prime := range indexToPrimes[index] {
		for _, value := range primeToIndex[prime] {
			if colored[value] == 0 {
				colorPath(value, color, indexToPrimes, primeToIndex, colored)
			}
		}
	}

}

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

func setOfDivisorPrimes(index int, e int, primeToIndex map[int][]int) []int {
	result := []int{}
	for _, prime := range primes {
		if e == 1 {
			break
		}

		if e%prime == 0 {
			result = append(result, prime)

			value := primeToIndex[prime]
			value = append(value, index)
			primeToIndex[prime] = value

			for e%prime == 0 {
				e /= prime
			}
		}
	}

	return result
}

func readInt() int {
	// return 23
	var e int
	fmt.Scan(&e)
	return e
}

func readIntArray(size int) []int {
	// result := []int{437, 519, 865, 808, 909, 391, 194, 291, 237, 395, 323, 365, 511, 497, 781, 737, 871, 559, 731, 697, 779, 841, 961}
	result := make([]int, size)
	for i := 0; i < size; i++ {
		fmt.Scan(&result[i])
	}
	return result
}

func primeNumbers(n int) []int {
	notPrime := make([]bool, n+1)
	for i := 2; i <= n; i++ {
		if !notPrime[i] {
			for j := i * i; j <= n; j += i {
				notPrime[j] = true
			}
		}
	}

	count := 0
	for _, v := range notPrime[2:] {
		if !v {
			count++
		}
	}
	result := make([]int, 0, count)
	for i, v := range notPrime[2:] {
		if !v {
			result = append(result, i+2)
		}
	}

	return result
}

/*
	0: 437:  19 23
	1: 519:  3 173
	2: 865:  5 173
	3: 808:  2 101
	4: 909:  3 101
	5: 391:  17 23
	6: 194:  2 97
	7: 291:  3 97
	8: 237:  3 79
	9: 395:  5 79
	10: 323:  17 19
	11: 365:  5 73
	12: 511:  7 73
	13: 497:  7 71
	14: 781:  11 71
	15: 737:  11 67
	16: 871:  13 67
	17: 559:  13 43
	18: 731:  17 43
	19: 697:  17 41
	20: 779:  19 41
	21: 841:  29
	22: 961:  31
*/

package main

import "fmt"

var primes []int

func main() {
	primes = primeNumbers(1000)
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		solveTestCase()
	}
}

func solveTestCase() {
	array := readIntArray(readInt())

	primeToIndex := make(map[int][]int, len(primes))
	indexToPrimes := make([][]int, len(array))
	for index, value := range array {
		indexToPrimes[index] = setOfDivisorPrimes(index, value, primeToIndex)
	}

	colored := make([]int, len(array))
	color := 1
	for index := range array {
		if colored[index] == 0 {
			colorPath(index, color, indexToPrimes, primeToIndex, colored)
			color++
		}
	}

	fmt.Println(colored)

	// fmt.Println(indexToPrimes)
	// fmt.Println()
	// fmt.Println(primeToIndex)
}

func colorPath(index int, color int, indexToPrimes [][]int, primeToIndex map[int][]int, colored []int) {
	colored[index] = color

	for _, prime := range indexToPrimes[index] {
		for _, value := range primeToIndex[prime] {
			if colored[value] == 0 {
				colorPath(value, color, indexToPrimes, primeToIndex, colored)
			}
		}
	}

}

func setOfDivisorPrimes(index int, e int, primeToIndex map[int][]int) []int {
	result := []int{}
	for _, prime := range primes {
		if e%prime == 0 {
			result = append(result, prime)

			value := primeToIndex[prime]
			value = append(value, index)
			primeToIndex[prime] = value

			for e%prime == 0 {
				e /= prime
			}
		}
	}

	return result
}

func readInt() int {
	// return 5
	var e int
	fmt.Scan(&e)
	return e
}

func readIntArray(size int) []int {
	// result := []int{4, 6, 69, 25, 343}
	result := make([]int, size)
	for i := 0; i < size; i++ {
		fmt.Scan(&result[i])
	}
	return result
}

func primeNumbers(n int) []int {
	notPrime := make([]bool, n+1)
	for i := 2; i <= n; i++ {
		if !notPrime[i] {
			for j := i * i; j <= n; j += i {
				notPrime[j] = true
			}
		}
	}

	count := 0
	for _, v := range notPrime[2:] {
		if !v {
			count++
		}
	}
	result := make([]int, 0, count)
	for i, v := range notPrime[2:] {
		if !v {
			result = append(result, i+2)
		}
	}

	return result
}

package main

import "fmt"

var primes []int

func main() {
	primes = primeNumbers(1000)
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		solveTestCase()
	}
}

func solveTestCase() {
	array := readIntArray(readInt())

	primeToIndex := make(map[int][]int, len(primes))
	indexToPrimes := make([][]int, len(array))
	for index, value := range array {
		indexToPrimes[index] = setOfDivisorPrimes(index, value, primeToIndex)
	}

	colored := make([]int, len(array))
	color := 1
	for index := range array {
		if colored[index] == 0 {
			colorPath(index, color, indexToPrimes, primeToIndex, colored)
			color++
		}
	}

	fmt.Println(color - 1)
	for _, e := range colored {
		fmt.Print(e, " ")
	}
	fmt.Println()

	// fmt.Println(indexToPrimes)
	// fmt.Println()
	// fmt.Println(primeToIndex)
}

func colorPath(index int, color int, indexToPrimes [][]int, primeToIndex map[int][]int, colored []int) {
	colored[index] = color

	for _, prime := range indexToPrimes[index] {
		for _, value := range primeToIndex[prime] {
			if colored[value] == 0 {
				colorPath(value, color, indexToPrimes, primeToIndex, colored)
			}
		}
	}

}

func setOfDivisorPrimes(index int, e int, primeToIndex map[int][]int) []int {
	result := []int{}
	for _, prime := range primes {
		if e%prime == 0 {
			result = append(result, prime)

			value := primeToIndex[prime]
			value = append(value, index)
			primeToIndex[prime] = value

			for e%prime == 0 {
				e /= prime
			}
		}
	}

	return result
}

func readInt() int {
	// return 5
	var e int
	fmt.Scan(&e)
	return e
}

func readIntArray(size int) []int {
	// result := []int{4, 6, 69, 25, 343}
	result := make([]int, size)
	for i := 0; i < size; i++ {
		fmt.Scan(&result[i])
	}
	return result
}

func primeNumbers(n int) []int {
	notPrime := make([]bool, n+1)
	for i := 2; i <= n; i++ {
		if !notPrime[i] {
			for j := i * i; j <= n; j += i {
				notPrime[j] = true
			}
		}
	}

	count := 0
	for _, v := range notPrime[2:] {
		if !v {
			count++
		}
	}
	result := make([]int, 0, count)
	for i, v := range notPrime[2:] {
		if !v {
			result = append(result, i+2)
		}
	}

	return result
}

/*
URL:
https://codeforces.com/problemset/problem/1332/B
*/

package main

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

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

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

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

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

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

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

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t int

	n int
	A []int

	P []int
)

func main() {
	_, P = sieve(50)

	t = ReadInt()
	for i := 0; i < t; i++ {
		n = ReadInt()
		A = ReadIntSlice(n)

		solve()
	}
}

func solve() {
	B := make([]int, n)

	for i := 0; i < 11; i++ {
		p := P[i]

		for j := 0; j < n; j++ {
			if A[j]%p == 0 && B[j] == 0 {
				B[j] = i + 1
			}
		}
	}

	fmt.Println(Max(B...))
	fmt.Println(PrintIntsLine(B...))
}

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

// エラトステネスの篩: O(NloglogN)
// n以下の素数の数と素数のスライスを返す
func sieve(n int) (int, []int) {
	// var prime [2000000 + 5]int
	prime := []int{}
	var isPrime [2000000 + 5 + 1]bool

	p := 0
	for i := 0; i <= n; i++ {
		isPrime[i] = true
	}
	isPrime[0], isPrime[1] = false, false

	for i := 2; i <= n; i++ {
		// iがtrueで残っている場合は素数認定し、自分より大きい倍数を取り除いていく
		if isPrime[i] {
			// prime[p] = i
			prime = append(prime, i)
			p++

			// 倍数の除去
			for j := 2 * i; j <= n; j += i {
				isPrime[j] = false
			}
		}
	}

	return p, prime
}

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

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

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

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

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

	return string(res)
}

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

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

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

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1332B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	p := [...]int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31}

	var t, n, v int
	for Fscan(in, &t); t > 0; t-- {
		c := 0
		used := make([]bool, len(p))
		Fscan(in, &n)
		ans := make([]interface{}, n)
		for i := range ans {
			Fscan(in, &v)
			for j, pi := range p {
				if v%pi == 0 {
					if !used[j] {
						used[j] = true
						c++
					}
					ans[i] = c
					break
				}
			}
		}
		Fprintln(out, c)
		Fprintln(out, ans...)
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1332B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	gcd := func(a, b int) int {
		for a != 0 {
			a, b = b%a, a
		}
		return b
	}

	var t, n int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		ans := make([]interface{}, n)
		c := 0
		for i, x := range a {
			if ans[i] == nil {
				c++
				for j := i; j < n; j++ {
					if gcd(a[j], x) > 1 {
						ans[j] = c
					}
				}
			}
		}
		Fprintln(out, c)
		Fprintln(out, ans...)
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1332B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	gcd := func(a, b int) int {
		for a != 0 {
			a, b = b%a, a
		}
		return b
	}

	var t, n int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		ans := make([]interface{}, n)
		c := 0
		for i, x := range a {
			if ans[i] == nil {
				c++
				for j, y := range a {
					if gcd(x, y) > 1 {
						ans[j] = c
					}
				}
			}
		}
		Fprintln(out, c)
		Fprintln(out, ans...)
	}
}

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

package main

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

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

type writerImpl struct {
    *bufio.Writer
}

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

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

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

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

type wordScannerImpl struct {
    *bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
    s := bufio.NewScanner(reader)
    s.Split(bufio.ScanWords)
    return &wordScannerImpl{Scanner: s}
}

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

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

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

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

func main() {
    defer writer.Flush()
    t := reader.NextInt64()
    for ; t > 0; t-- {
        n := reader.NextInt64()
        aa := []int64{}
        for ; n > 0; n-- {
            aa = append(aa, reader.NextInt64())
        }
        uColors, colors := sol(aa)
        writer.Printf("%d\n", uColors)
        for _, v := range colors {
            writer.Printf("%d ", v)
        }
        writer.Printf("\n")
    }
}

var primes = []int64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31}

func sol(aa []int64) (int, []int) {
    colors := map[int]bool{}
    res := make([]int, len(aa))
    for i := range aa {
        for pi, p := range primes {
            if aa[i] % p == 0 {
                colors[pi+1] = true
                res[i] = pi+1
                break
            }
        }
    }
    return len(colors), res
}

package main

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

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

type writerImpl struct {
    *bufio.Writer
}

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

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

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

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

type wordScannerImpl struct {
    *bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
    s := bufio.NewScanner(reader)
    s.Split(bufio.ScanWords)
    return &wordScannerImpl{Scanner: s}
}

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

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

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

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

func main() {
    defer writer.Flush()
    t := reader.NextInt64()
    for ; t > 0; t-- {
        n := reader.NextInt64()
        aa := []int64{}
        for ; n > 0; n-- {
            aa = append(aa, reader.NextInt64())
        }
        uColors, colors := sol(aa)
        writer.Printf("%d\n", uColors)
        for _, v := range colors {
            writer.Printf("%d ", v)
        }
        writer.Printf("\n")
    }
}

var primes = []int64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31}

func sol(aa []int64) (int, []int) {
    colors := map[int]bool{}
    res := make([]int, len(aa))
    for i := range aa {
        for pi, p := range primes {
            if aa[i] % p == 0 {
                colors[pi+1] = true
                res[i] = pi+1
                break
            }
        }
    }
    return 11, res
}


You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, such that equality holds.

The only line of the input contains a rebus. It's guaranteed that it contains no more than 100 question marks, integer n is positive and doesn't exceed 1 000 000, all letters and integers are separated by spaces, arithmetic operations are located only between question marks.

The first line of the output should contain "Possible" (without quotes) if rebus has a solution and "Impossible" (without quotes) otherwise. If the answer exists, the second line should contain any valid rebus with question marks replaced by integers from 1 to n. Follow the format given in the samples.

package main

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

func parseRawInput(s string) (i, j, n int) {
	var c, length int = 0, len(s)

	i, j = 1, 0
	for c < length {
		if s[c] == '+' {
			i++
		} else if s[c] == '-' {
			j++
		} else if s[c] == '=' {
			break
		}
		c++
	}
	n, _ = strconv.Atoi(strings.TrimSpace(s[c+1:]))
	return
}

func result(i, j, n int) (is, js []int, flag bool) {
	flag = false

	for c := 1; c <= n; c++ {
		if i <= j*c+n {
			v := (n + j*c) / i
			d := (n + j*c) % i

			for cc := 0; cc < i; cc++ {
				vv := v
				if cc < d && d != 0 {
					vv += 1
				}
				is = append(is, vv)
			}

			for cc := 0; cc < j; cc++ {
				js = append(js, c)
			}

			if is[0] <= n {
				flag = true
			}
			break
		} else if j == 0 {
			break
		}
	}
	return
}

func bingo(s string, is, js []int, flag bool) {
	if flag == false {
		fmt.Println("Impossible")
	} else {
		fmt.Println("Possible")

		buf := bytes.NewBufferString("")
		var plus bool = true
		var i, j int = 0, 0
		for c := 0; c < len(s); c++ {
			if s[c] == '?' {
				if plus {
					buf.WriteString(strconv.Itoa(is[i]))
					i++
				} else {
					buf.WriteString(strconv.Itoa(js[j]))
					j++
				}
			} else {
				if s[c] == '+' {
					plus = true
				} else if s[c] == '-' {
					plus = false
				}
				buf.WriteByte(s[c])
			}
		}
		fmt.Println(buf.String())
	}
}

func main() {
	var s string
	inputReader := bufio.NewReader(os.Stdin)
	s, _ = inputReader.ReadString('\n')
	i, j, n := parseRawInput(s)
	//fmt.Println(i, j, n)
	is, js, flag := result(i, j, n)
	bingo(s, is, js, flag)

}

package main

import "fmt"

func main() {
	var q, op string
	var plus, minus, n int
	plus++
	ops := []string{"+"}
	for n == 0 {
		fmt.Scan(&q, &op)
		if op != "=" {
			ops = append(ops, op)
		}
		switch op {
		case "+":
			plus++
		case "-":
			minus++
		case "=":
			fmt.Scan(&n)
		default:
			panic(op)
		}
	}
	min := -n*minus + plus
	max := n*plus - minus
	if n < min || n > max {
		fmt.Println("Impossible")
		return
	}
	fmt.Println("Possible")
	cur := plus - minus
	for i := range ops {
		if i > 0 {
			fmt.Print(" " + ops[i] + " ")
		}
		num := 1
		switch {
		case cur < n:
			if ops[i] == "+" {
				add := n - cur
				if add > n-1 {
					add = n - 1
				}
				cur += add
				num += add
			}
		case cur > n:
			if ops[i] == "-" {
				sub := cur - n
				if sub > n-1 {
					sub = n - 1
				}
				cur -= sub
				num += sub
			}
		}
		fmt.Print(num)
	}
	fmt.Println(" = ", n)
}

package main

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

func parseRawInput(s string) (i, j, n int) {
	var c, length int = 0, len(s)

	i, j = 1, 0
	for c < length {
		if s[c] == '+' {
			i++
		} else if s[c] == '-' {
			j++
		} else if s[c] == '=' {
			break
		}
		c++
	}
	n, _ = strconv.Atoi(strings.TrimSpace(s[c+1:]))
	return
}

func result(i, j, n int) ([]int, []int, bool) {
	var is, js []int

	flag := true
	if i <= j+n {
		v := (n + j) / i
		d := (n + j) % i

		for c := 0; c < i; c++ {
			if c < d && d != 0 {
				is = append(is, v+1)
			} else {
				is = append(is, v)
			}
		}

		for c := 0; c < j; c++ {
			js = append(js, 1)
		}

		if v <= 0 || is[0] > n {
			flag = false
		}
	} else {
		if j != 0 {
			for c := 0; c < i; c++ {
				is = append(is, 1)
			}

			v := (i - n - j) / j
			d := (i - n - j) % j
			for c := 0; c < j; c++ {
				if c < d && d != 0 {
					js = append(js, v+1+1)
				} else {
					js = append(js, v+1)
				}
			}

			if v+1 > n || v+2 > n {
				flag = false
			}
		} else {
			flag = false
		}
	}
	return is, js, flag
}

func bingo(s string, is, js []int, flag bool) {
	if flag == false {
		fmt.Println("Impossible")
	} else {
		fmt.Println("Possible")

		buf := bytes.NewBufferString("")
		var plus bool = true
		var i, j int = 0, 0
		for c := 0; c < len(s); c++ {
			if s[c] == '?' {
				if plus {
					buf.WriteString(strconv.Itoa(is[i]))
					i++
				} else {
					buf.WriteString(strconv.Itoa(js[j]))
					j++
				}
			} else {
				if s[c] == '+' {
					plus = true
				} else if s[c] == '-' {
					plus = false
				}
				buf.WriteByte(s[c])
			}
		}
		fmt.Println(buf.String())
	}
}

func main() {
	var s string
	inputReader := bufio.NewReader(os.Stdin)
	s, _ = inputReader.ReadString('\n')
	i, j, n := parseRawInput(s)
	//fmt.Println(i, j, n)
	is, js, flag := result(i, j, n)
	bingo(s, is, js, flag)

}

package main

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

func parseRawInput(s string) (i, j, n int) {
	var c, length int = 0, len(s)

	i, j = 1, 0
	for c < length {
		if s[c] == '+' {
			i++
		} else if s[c] == '-' {
			j++
		} else if s[c] == '=' {
			break
		}
		c++
	}
	n, _ = strconv.Atoi(strings.TrimSpace(s[c+1:]))
	return
}

func result(i, j, n int) ([]int, bool) {
	var is []int

	flag := true
	v := (n + j) / i
	d := (n + j) % i

	for c := 0; c < i; c++ {
		is = append(is, v)
	}
	is[0] += d

	if v <= 0 || v+d > n {
		flag = false
	}
	return is, flag
}

func bingo(s string, is []int, flag bool) {
	if flag == false {
		fmt.Println("Impossible")
	} else {
		fmt.Println("Possible")

		buf := bytes.NewBufferString("")
		var plus bool = true
		var i int = 0
		for c := 0; c < len(s); c++ {
			if s[c] == '?' {
				if plus {
					buf.WriteString(strconv.Itoa(is[i]))
					i++
				} else {
					buf.WriteByte('1')
				}
			} else {
				if s[c] == '+' {
					plus = true
				} else if s[c] == '-' {
					plus = false
				}
				buf.WriteByte(s[c])
			}
		}
		fmt.Println(buf.String())
	}
}

func main() {
	var s string
	inputReader := bufio.NewReader(os.Stdin)
	s, _ = inputReader.ReadString('\n')
	i, j, n := parseRawInput(s)
	is, flag := result(i, j, n)
	bingo(s, is, flag)

}

package main

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

func parseRawInput(s string) (i, j, n int) {
	var c, length int = 0, len(s)

	i, j = 1, 0
	for c < length {
		if s[c] == '+' {
			i++
		} else if s[c] == '-' {
			j++
		} else if s[c] == '=' {
			break
		}
		c++
	}
	n, _ = strconv.Atoi(strings.TrimSpace(s[c+1:]))
	return
}

func result(i, j, n int) ([]int, bool) {
	var is []int

	flag := true
	v := (n + j) / i
	d := (n + j) % i

	for c := 0; c < i; c++ {
		if c < d {
			is = append(is, v+1)
		} else {
			is = append(is, v)
		}
	}

	if v <= 0 || v+1 > n {
		flag = false
	}
	return is, flag
}

func bingo(s string, is []int, flag bool) {
	if flag == false {
		fmt.Println("Impossible")
	} else {
		fmt.Println("Possible")

		buf := bytes.NewBufferString("")
		var plus bool = true
		var i int = 0
		for c := 0; c < len(s); c++ {
			if s[c] == '?' {
				if plus {
					buf.WriteString(strconv.Itoa(is[i]))
					i++
				} else {
					buf.WriteByte('1')
				}
			} else {
				if s[c] == '+' {
					plus = true
				} else if s[c] == '-' {
					plus = false
				}
				buf.WriteByte(s[c])
			}
		}
		fmt.Println(buf.String())
	}
}

func main() {
	var s string
	inputReader := bufio.NewReader(os.Stdin)
	s, _ = inputReader.ReadString('\n')
	i, j, n := parseRawInput(s)
	is, flag := result(i, j, n)
	bingo(s, is, flag)

}

package main

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

func parseRawInput(s string) (i, j, n int) {
	var c, length int = 0, len(s)

	i, j = 1, 0
	for c < length {
		if s[c] == '+' {
			i++
		} else if s[c] == '-' {
			j++
		} else if s[c] == '=' {
			break
		}
		c++
	}
	n, _ = strconv.Atoi(strings.TrimSpace(s[c+1:]))
	return
}

func result(i, j, n int) ([]int, bool) {
	var is []int

	flag := true
	v := (n + j) / i
	d := (n + j) % i

	for c := 0; c < i; c++ {
		if c < d && d != 0 {
			is = append(is, v+1)
		} else {
			is = append(is, v)
		}
	}

	if v <= 0 || v+1 > n {
		flag = false
	}
	return is, flag
}

func bingo(s string, is []int, flag bool) {
	if flag == false {
		fmt.Println("Impossible")
	} else {
		fmt.Println("Possible")

		buf := bytes.NewBufferString("")
		var plus bool = true
		var i int = 0
		for c := 0; c < len(s); c++ {
			if s[c] == '?' {
				if plus {
					buf.WriteString(strconv.Itoa(is[i]))
					i++
				} else {
					buf.WriteByte('1')
				}
			} else {
				if s[c] == '+' {
					plus = true
				} else if s[c] == '-' {
					plus = false
				}
				buf.WriteByte(s[c])
			}
		}
		fmt.Println(buf.String())
	}
}

func main() {
	var s string
	inputReader := bufio.NewReader(os.Stdin)
	s, _ = inputReader.ReadString('\n')
	i, j, n := parseRawInput(s)
	is, flag := result(i, j, n)
	bingo(s, is, flag)

}

package main

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

func parseRawInput(s string) (i, j, n int) {
	var c, length int = 0, len(s)

	i, j = 1, 0
	for c < length {
		if s[c] == '+' {
			i++
		} else if s[c] == '-' {
			j++
		} else if s[c] == '=' {
			break
		}
		c++
	}
	n, _ = strconv.Atoi(strings.TrimSpace(s[c+1:]))
	return
}

func result(i, j, n int) ([]int, bool) {
	var is []int

	flag := true
	v := (n + j) / i
	d := (n + j) % i

	for c := 0; c < i; c++ {
		if c < d && d != 0 {
			is = append(is, v+1)
		} else {
			is = append(is, v)
		}
	}

	if v <= 0 || is[0] > n {
		flag = false
	}
	return is, flag
}

func bingo(s string, is []int, flag bool) {
	if flag == false {
		fmt.Println("Impossible")
	} else {
		fmt.Println("Possible")

		buf := bytes.NewBufferString("")
		var plus bool = true
		var i int = 0
		for c := 0; c < len(s); c++ {
			if s[c] == '?' {
				if plus {
					buf.WriteString(strconv.Itoa(is[i]))
					i++
				} else {
					buf.WriteByte('1')
				}
			} else {
				if s[c] == '+' {
					plus = true
				} else if s[c] == '-' {
					plus = false
				}
				buf.WriteByte(s[c])
			}
		}
		fmt.Println(buf.String())
	}
}

func main() {
	var s string
	inputReader := bufio.NewReader(os.Stdin)
	s, _ = inputReader.ReadString('\n')
	i, j, n := parseRawInput(s)
	is, flag := result(i, j, n)
	bingo(s, is, flag)

}

package main

import "fmt"

func main() {
	var q, op string
	var plus, minus, n int
	plus++
	ops := []string{"+"}
	for n == 0 {
		fmt.Scan(&q, &op)
		if op != "=" {
			ops = append(ops, op)
		}
		switch op {
		case "+":
			plus++
		case "-":
			minus++
		case "=":
			fmt.Scan(&n)
		default:
			panic(op)
		}
	}
	min := -n*minus + plus
	max := n*plus - minus
	if n < min || n > max {
		fmt.Println("Impossible")
		return
	}
	fmt.Println("Possible")
	cur := plus - minus
	for i := range ops {
		if i > 0 {
			fmt.Print(" " + ops[i] + " ")
		}
		num := 1
		switch {
		case cur < n:
			if ops[i] == "+" {
				add := n - cur
				if add > n-1 {
					add = n - 1
				}
				cur += add
				num += add
			}
		case cur > n:
			if ops[i] == "-" {
				sub := cur - n
				if sub > n-1 {
					sub = n - 1
				}
				cur -= sub
				num -= sub
			}
		}
		fmt.Print(num)
	}
	fmt.Println(" = ", n)
}