package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	var s string
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &s)
		for i, v := range s {
			if i%2 == 0 {
				if v == 'a' {
					fmt.Printf("b")
				} else {
					fmt.Printf("a")
				}
			} else {
				if v == 'z' {
					fmt.Printf("y")
				} else {
					fmt.Printf("z")
				}
			}
		}
		fmt.Println()
	}
}

package main

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

var bytes []byte

func nextByte() byte {
	b := bytes[0]
	bytes = bytes[1:]
	return b
}

func scanInt64() int64 {
	var negative bool
	var result int64

	b := nextByte()

	for ; b < '0' || b > '9'; b = nextByte() {
		if b == '-' {
			negative = true
		}
	}

	for ; '0' <= b && b <= '9'; b = nextByte() {
		result = (result << 3) + (result << 1) + int64(b-'0')
	}

	if negative {
		return -result
	} else {
		return result
	}
}

func scanInt() int {
	return int(scanInt64())
}

func ScanString() string {
	builder := strings.Builder{}

	for b := nextByte(); b != '\r'; b = nextByte() {
		if b != '\n' {
			builder.WriteByte(b)
		}
	}

	return builder.String()
}

func init() {
	f, err := os.Open("in.txt")

	if err == nil {
		defer f.Close()
	} else {
		f = os.Stdin
	}

	bytes, _ = ioutil.ReadAll(bufio.NewReader(f))
}

func main() {
	for t := scanInt(); t > 0; t-- {
		s := []rune(ScanString())

		for i := 0; i < len(s); i++ {
			if i%2 == 0 {
				if s[i] == 'a' {
					s[i] = 'b'
				} else {
					s[i] = 'a'
				}
			} else {
				if s[i] == 'z' {
					s[i] = 'y'
				} else {
					s[i] = 'z'
				}
			}
		}

		fmt.Println(string(s))
	}
}

package main

import "fmt"
var (
	n int
	s string
)
func main() {
	fmt.Scanln(&n)
	for i := 0; i < n; i++{
		fmt.Scanln(&s)
		var ans string
		for i := 0; i < len(s); i++{
			if i & 1 > 0 {
				if s[i] == 'z'{
					ans += string('z' - 1)
				} else {
					ans += "z"
				}
			} else {
				if s[i] == 'a' {
					ans += string('a' + 1)
				} else {
					ans += "a"
				}
			}
		}
		fmt.Println(ans)
	}

}

package main

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

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

	var (
		t int
		s string
	)

	for fmt.Fscan(in, &t); t > 0; t-- {
		fmt.Fscan(in, &s)
		var ret string
		for i, si := range s {
			if i%2 == 0 {
				if si == 'a' {
					ret += "b"
				} else {
					ret += "a"
				}
			} else {
				if si == 'z' {
					ret += "y"
				} else {
					ret += "z"
				}
			}
		}
		fmt.Fprintln(out, ret)
	}
}

package main

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

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

	var T int
	var s []byte
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &s)
		for i, b := range s {
			if i&1 == 0 {
				if b > 'a' {
					b = 'a'
				} else {
					b = 'b'
				}
			} else {
				if b < 'z' {
					b = 'z'
				} else {
					b = 'y'
				}
			}
			s[i] = b
		}
		Fprintln(out, string(s))
	}
}

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

package main

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

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {

		STRING := make([]byte, 0)

		fmt.Fscan(input, &STRING)
		q := ""
		for i := 0; i < len(STRING); i++ {
			if i%2 == 0 {
				if string(STRING[i]) == "a" {
					q = q + "b"
				} else {
					q = q + "a"
				}
			} else {
				if string(STRING[i]) == "z" {
					q = q + "y"
				} else {
					q = q + "z"
				}
			}
		}
		fmt.Println(q)
	}
}

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 s string
		_, _ = fmt.Fscan(in, &s)

		ans := ""
		for i, c := range s {
			if i%2 == 0 {
				if c == 'a' {
					ans += "b"
				} else {
					ans += "a"
				}
			} else {
				if c == 'z' {
					ans += "y"
				} else {
					ans += "z"
				}
			}
		}

		fmt.Println(ans)
	}
}

package main

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

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

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

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

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

		}
		return initial
	}
}

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

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

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {

		STRING := make([]byte, 0)

		fmt.Fscan(input, &STRING)
		q := ""
		for i := 0; i < len(STRING); i++ {
			if i%2 == 0 {
				if string(STRING[i]) == "a" {
					q = q + "b"
				} else {
					q = q + "a"
				}
			} else {
				if string(STRING[i]) == "z" {
					q = q + "y"
				} else {
					q = q + "z"
				}
			}
		}
		fmt.Println(q)

	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
    "bytes"
)
var (
    input = bufio.NewReader(os.Stdin)
    output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assertion!")}
}

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)
func main() {
    var t int
	fmt.Fscanln(input, &t)
    for t > 0 {
        t--
        solve()
    }
    output.Flush()
}

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

func solve() {
    var s string
    fmt.Fscanln(input, &s)

    var buff bytes.Buffer
    for i := 0; i < len(s); i++ {
        if i & 1 == 0 {
            if s[i] == 'a' {
                buff.WriteByte('b')
            } else {
                buff.WriteByte('a')
            }
        } else {
            if s[i] == 'z' {
                buff.WriteByte('y')
            } else {
                buff.WriteByte('z')
            }
        }
    }

    fmt.Println(buff.String())
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var T int
	var s string
	c := make([]byte, 0)
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &s)
		for i := 0; i < len(s); i++ {
			if i%2 == 0 {
				if byte(s[i]) == byte('a') {
					c = append(c, 'b')
				} else {
					c = append(c, byte('a'))
				}
			} else {
				if byte(s[i]) == byte('z') {
					c = append(c, byte('y'))
				} else {
					c = append(c, byte('z'))
				}
			}
		}
		Fprintf(out, "%s\n", c)
		c = make([]byte, 0)
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1480A
Date: 8/11/21
User: pepradere
URL: https://codeforces.com/problemset/problem/1480/A
Problem: CF1480A
**/
func (in *CF1480A) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		str := in.NextString()
		sol := ""
		for i := 0; i < len(str); i++ {
			if i%2 == 0 {
				if str[i] != 'a' {
					sol += "a"
				} else {
					sol += "b"
				}
			} else {
				if str[i] != 'z' {
					sol += "z"
				} else {
					sol += "y"
				}
			}
		}
		fmt.Println(sol)
	}
}

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

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

package main

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

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	cases := getI()
	forEach(cases, func(i int64) {
		str := getS()
		forEach(int64(len(str)), func(i int64) {
			if i%2 == 0 {
				if str[i] == 'a' {
					str = str[:i] + "b" + str[i+1:]
				} else {
					str = str[:i] + "a" + str[i+1:]
				}
			} else {
				if str[i] == 'z' {
					str = str[:i] + "y" + str[i+1:]
				} else {
					str = str[:i] + "z" + str[i+1:]
				}
			}
		})
		out(string(str))
	})
}

// !------- HELPERS -------!

func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func sortInts(data []int64) {
	sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
}

func joinInts(s []int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

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

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

package main

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

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	cases := getI()
	forEach(cases, func(i int64) {
		str := []rune(getS())
		forEach(int64(len(str)), func(i int64) {
			if i%2 == 0 {
				if str[i] == 'a' {
					str[i] = 'b'
				} else {
					str[i] = 'a'
				}
			} else {
				if str[i] == 'z' {
					str[i] = 'y'
				} else {
					str[i] = 'z'
				}
			}
		})
		out(string(str))
	})
}

// !------- HELPERS -------!

func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func sortInts(data []int64) {
	sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
}

func joinInts(s []int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

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

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

package main
import(
    "fmt"
    "bufio"
    "os"
    "strings"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var word string
		fmt.Fscan(in,&word)
		list:= strings.Split(word,"")
		for j:=0;j<len(list);j+=2{
			if string(list[j]) == "a" {
				list[j]= "b"
			} else {
				list[j]= "a"
			}
		}
		for j:=1;j<len(list);j+=2{
			if string(list[j]) == "z" {
				list[j]= "y"
			} else {
				list[j]= "z"
			}
		}
		for j:=0;j<len(list);j++{
			fmt.Fprintf(out,"%v",list[j])
		}
		fmt.Fprintln(out,)
	}
}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	t      int
	s      string
)

func solve(s string) string {
	var r []byte
	for i, y := range s {
		if i%2 == 0 {
			if y == 'a' {
				r = append(r, 'b')
			} else {
				r = append(r, 'a')
			}
		} else {
			if y == 'z' {
				r = append(r, 'y')
			} else {
				r = append(r, 'z')
			}
		}
	}
	return fmt.Sprintf("%s", r)

}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &s)
		fmt.Println(solve(s))
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var T int
	var s string
	c := make([]byte, 0)
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &s)
		for i := 0; i < len(s); i++ {
			if i%2 == 0 {
				if byte(s[i]) == byte('a') {
					c = append(c, 'b')
				} else {
					c = append(c, byte(s[i])-1)
				}
			} else {
				if byte(s[i]) == byte('z') {
					c = append(c, byte('y'))
				} else {
					c = append(c, byte('z'))
				}
			}
		}
		Fprintf(out, "%s\n", c)
		c = make([]byte, 0)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var T int
	var s string
	c := make([]byte, 0)
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &s)
		for i := 0; i < len(s); i++ {
			if i%2 == 0 {
				if byte(s[i]) == byte('a') {
					c = append(c, 'b')
				} else {
					c = append(c, byte(s[i])-1)
				}
			} else {
				if byte(s[i]) == byte('z') {
					c = append(c, byte('y'))
				} else {
					c = append(c, byte(s[i])+1)
				}
			}
		}
		Fprintf(out, "%s\n", c)
		c = make([]byte, 0)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var T int
	var s string
	c := make([]byte, 1)
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &s)
		for i := 0; i < len(s); i++ {
			if i%2 == 0 {
				if byte(s[i]) == byte('a') {
					c = append(c, 'b')
				} else {
					c = append(c, byte(s[i])-1)
				}
			} else {
				if byte(s[i]) == byte('z') {
					c = append(c, byte('y'))
				} else {
					c = append(c, byte(s[i])+1)
				}
			}
		}
		Fprintf(out, "%s\n", c)
		c = make([]byte, 1)
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1480A
Date: 8/11/21
User: pepradere
URL: https://codeforces.com/problemset/problem/1480/A
Problem: CF1480A
**/
func (in *CF1480A) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		str := in.GetLine()
		sol := ""
		for i := 0; i < len(str)-1; i++ {
			if i%2 == 0 {
				if str[i] != 'a' {
					sol += "a"
				} else {
					sol += "b"
				}
			} else {
				if str[i] != 'z' {
					sol += "z"
				} else {
					sol += "y"
				}
			}
		}
		fmt.Println(sol)
	}
}

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

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


package main

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

const (
	MX_INT int64 = math.MaxInt64
	MN_INT int64 = math.MinInt64
)

func main() {
	for t := ScanInt64(); t > 0; t-- {
		n := ScanInt64()
		a := ScanInt64Slice(n)

		sum := int64(0)
		numOf0 := 0
		for i := int64(0); i < n; i++ {
			if a[i] == 0 {
				numOf0++
			}
			sum += a[i]
		}

		if sum == 0 && numOf0 == 0 {
			O <- "1"
		} else if sum == 0 && numOf0 != 0 {
			O <- S(numOf0)
		} else if sum != 0 && numOf0 == 0 {
			O <- "0"
		} else if sum != 0 && numOf0 != 0 {
			if sum+int64(numOf0) == int64(0) {
				O <- S(numOf0 + 1)
			} else {
				O <- S(numOf0)
			}
		}

	}
	close(O)
	oWg.Wait()
}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(writer *bufio.Writer) {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}(writer)
}

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

func ScanStringSlice(n int64) []string {
	length := int(n)
	s := make([]string, n)
	for i := 0; i < length; i++ {
		s[i] = ScanWord()
	}
	return s
}

func ScanInt64() int64 {
	intStr := ScanWord()
	i, err := strconv.ParseInt(intStr, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func ScanInt() int {
	intStr := ScanWord()
	i, err := strconv.Atoi(intStr)
	if err != nil {
		panic(err)
	}
	return i
}

func ScanInt64Slice(n int64) []int64 {
	length := int(n)
	arr := make([]int64, n)
	for i := 0; i < length; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func Mx(args ...int64) int64 {
	maxVal := MN_INT
	for _, v := range args {
		if v > maxVal {
			maxVal = v
		}
	}
	return maxVal
}

func Mn(args ...int64) int64 {
	minVal := MX_INT
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
	}
	return minVal
}

func LCM(a, b int64) int64 {
	return a / GCD(a, b) * b
}

func GCD(a, b int64) int64 {
	if (a == 0) {
		return b
	}
	return GCD(b%a, a)
}

func S(v interface{}) string {
	return fmt.Sprintf("%v", v)
}

package main

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

func main() {
	var t, n int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		data := make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &data[j])
		}
		sum := 0
		count := 0
		for j := 0; j < n; j++ {
			if data[j] == 0 {
				data[j] = 1
				count++
			}
			sum += data[j]
		}
		if sum == 0 {
			count++
		}
		fmt.Println(count)
	}
}

// A. Non-zero
/*
Guy-Manuel and Thomas have an array 𝑎 of 𝑛 integers [𝑎1,𝑎2,…,𝑎𝑛]. In one step they can add 1 to any element of the array. Formally, in one step they can choose any integer index 𝑖 (1≤𝑖≤𝑛) and do 𝑎𝑖:=𝑎𝑖+1.

If either the sum or the product of all elements in the array is equal to zero, Guy-Manuel and Thomas do not mind to do this operation one more time.

What is the minimum number of steps they need to do to make both the sum and the product of all elements in the array different from zero? Formally, find the minimum number of steps to make 𝑎1+𝑎2+ … +𝑎𝑛≠0 and 𝑎1⋅𝑎2⋅ … ⋅𝑎𝑛≠0.

Input
Each test contains multiple test cases.

The first line contains the number of test cases 𝑡 (1≤𝑡≤103). The description of the test cases follows.

The first line of each test case contains an integer 𝑛 (1≤𝑛≤100) — the size of the array.

The second line of each test case contains 𝑛
integers 𝑎1,𝑎2,…,𝑎𝑛 (−100≤𝑎𝑖≤100) — elements of the array .

Output
For each test case, output the minimum number of steps required to make both sum and product of all elements in the array different from zero.
Example
Input
4
3
2 -1 -1
4
-1 0 0 1
2
-1 2
3
0 -2 1

Output
1
2
0
2

Note
In the first test case, the sum is 0. If we add 1 to the first element, the array will be [3,−1,−1], the sum will be equal to 1 and the product will be equal to 3.

In the second test case, both product and sum are 0. If we add 1 to the second and the third element, the array will be [−1,1,1,1], the sum will be equal to 2 and the product will be equal to −1. It can be shown that fewer steps can't be enough.

In the third test case, both sum and product are non-zero, we don't need to do anything.

In the fourth test case, after adding 1 twice to the first element the array will be [2,−2,1], the sum will be 1 and the product will be −4.
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input1, _ := reader.ReadString('\n')
	t, _ := strconv.Atoi(strings.TrimSpace(input1))

	for ; t > 0; t-- {
		input2, _ := reader.ReadString('\n')
		n, _ := strconv.Atoi(strings.TrimSpace(input2))

		//Get testcases and convert it into array
		input3, _ := reader.ReadString('\n')
		arr := strings.Split(strings.TrimSpace(input3), " ")

		//Convert string array into int array
		intArr := []int{}
		total := 0
		for i := 0; i < n; i++ {
			j, _ := strconv.Atoi(arr[i])
			intArr = append(intArr, j)
		}

		sum := 0
		for i := 0; i < n; i++ {
			if intArr[i] == 0 {
				intArr[i] = 1
				total++
			}
			sum += intArr[i]
		}

		if sum == 0 {
			intArr[0]++
			total++
		}
		fmt.Println(total)
	}
}

package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

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

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	in := scanInt()
	for t := 0; t < in; t++ {
		n := scanInt()
		a := scanInts(n)

		ans := 0
		sum := 0

		for i := range a {
			if a[i] == 0 {
				ans++
				a[i] = 1
			}
			sum += a[i]
		}

		if sum == 0 {
			ans++
		}

		fmt.Println(ans)

	}
}

package main

import "fmt"

func main()  {
	var t, n int
	fmt.Scan(&t)
	for t > 0 {
		t --
		fmt.Scan(&n)
		arr := make([]int, n)
		sum, ans := 0, 0
		for i := 0 ; i < n ; i++ {
			fmt.Scan(&arr[i])
			if arr[i] == 0{
				ans ++
				arr[i] ++
			}
			sum += arr[i]
		}
		if sum == 0 {
			ans ++
		}
		fmt.Println(ans)
	}
}

package main

import "fmt"

func main() {
    var t int
    fmt.Scan(&t)
    for i := 0; i < t; i++ {
        var n int
        fmt.Scan(&n)
        a := make([]int, n)
        for j := 0; j < n; j++ {
            fmt.Scan(&a[j])
        }
        //~ fmt.Println(a)
        count := 0
        for i, v := range a {
            if v == 0 {
                a[i] = 1
                count++
            }
        }

        sum := 0
        for _, v := range a {
            sum += v
        }

        if sum == 0 {
            a[0]++
            count++
        }

        //~ fmt.Println(a, count)
        fmt.Println(count)
    }
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Scan()
    line := scanner.Text()
    t, _ := strconv.Atoi(line)
    for i := 0; i < t; i++ {
        scanner.Scan()
        line = scanner.Text()
        n, _ := strconv.Atoi(line)
        //~ t, _ := strconv.Atoi(line)
        a := make([]int, n)
        scanner.Scan()
        line = scanner.Text()
        parts := strings.Split(line, " ")
        //~ fmt.Println(n, line, parts)
        for j := 0; j < n; j++ {
            a[j], _ = strconv.Atoi(parts[j])
        }
        //~ fmt.Println(a)
        count := 0
        for i, v := range a {
            if v == 0 {
                a[i] = 1
                count++
            }
        }

        sum := 0
        for _, v := range a {
            sum += v
        }

        if sum == 0 {
            a[0]++
            count++
        }

        //~ fmt.Println(a, count)
        fmt.Println(count)
    }
}

package main

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

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

func scanf(p string, vars ...interface{}) {
	fmt.Fscanf(reader, p, vars...)
}

func printf(p string, vars ...interface{}) {
	fmt.Fprintf(writer, p, vars...)
}

func main() {
	defer writer.Flush()

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

	for t := 0; t < tests; t++ {
		var n int
		scanf("%d\n", &n)

		sum := 0
		count := 0
		for i := 0; i < n; i++ {
			var a int
			scanf("%d", &a)
			if a == 0 {
				a++
				count++
			}
			sum += a
		}

		if sum == 0 {
			count++
		}

		scanf("\n")

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

package main

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

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

	var t int
	fmt.Fscan(r, &t)
	ans := make([]string, t)
	for i := 0; i < t; i++ {
		var n, s, x int
		fmt.Fscan(r, &n)
		for j := 0; j < n; j++ {
			var a int
			fmt.Fscan(r, &a)
			s += a
			if a == 0 {
				x++
			}
		}
		if s+x == 0 {
			ans[i] = strconv.Itoa(x + 1)
		} else if s == 0 && x != 0 {
			ans[i] = strconv.Itoa(x)
		} else if x == 0 && s == 0 {
			ans[i] = "1"
		} else if s != 0 {
			ans[i] = strconv.Itoa(x)
		} else {
			ans[i] = "0"
		}
	}
	fmt.Fprintln(w, strings.Join(ans, "\n"))
}


package main

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

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

	image := make([]string, n)

	reader := bufio.NewReader(os.Stdin)
	re := regexp.MustCompile(`\r?\n`)
	for i := 0; i < n; i++ {
		if s, err := reader.ReadString('\n'); err != nil {
			if err == io.EOF {
				break
			} else {
				return
			}
		} else {
			image[i] = re.ReplaceAllString(s, "")
		}
	}

	num_faces := 0
	for i := 0; i < n-1; i++ {
		for j := 0; j < m-1; j++ {
			face := [4]bool{false, false, false, false}
			for k := i; k <= i+1; k++ {
				for l := j; l <= j+1; l++ {
					if 'f' == image[k][l] {
						face[0] = true
					} else if 'a' == image[k][l] {
						face[1] = true
					} else if 'c' == image[k][l] {
						face[2] = true
					} else if 'e' == image[k][l] {
						face[3] = true
					}
				}
			}
			if face[0] && face[1] && face[2] && face[3] {
				num_faces += 1
			}
		}
	}

	fmt.Println(num_faces)
}

package main

import (
	"fmt"
)

func check(c1, c2, c3, c4 byte) bool {
	counts := make([]int, 26, 26)
	counts[c1-'a']++
	counts[c2-'a']++
	counts[c3-'a']++
	counts[c4-'a']++

	return counts['f'-'a'] == 1 && counts['a'-'a'] == 1 && counts['c'-'a'] == 1 && counts['e'-'a'] == 1
}

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

	image := make([]string, n, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&image[i])
	}

	ans := 0
	for i := 0; i < n-1; i++ {
		for j := 0; j < m-1; j++ {
			if check(image[i][j], image[i+1][j], image[i][j+1], image[i+1][j+1]) {
				ans++
			}
		}
	}

	fmt.Println(ans)
}


package main

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

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

func main() {
	var t int
	fmt.Fscan(reader, &t)
	for i := 0; i < t; i++ {
		solve()
	}
}

func solve() {
	var n, k, c, r, p int
	c = 0
	fmt.Fscan(reader, &n, &k)
	for i := n - 1; i >= 0; i-- {
		p = c ^ i
		fmt.Fprintln(writer, p)
		c = c ^ p
		writer.Flush()
		fmt.Fscan(reader, &r)
		if r == 1 {
			break
		}
	}
}

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

func fabs(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}

func min(nums ...int64) int64 {
	l := len(nums)
	mn := nums[0]
	for i := 0; i < l; i++ {
		if nums[i] < mn {
			mn = nums[i]
		}
	}
	return mn
}

func fmin(nums ...float64) float64 {
	l := len(nums)
	mn := nums[0]
	for i := 0; i < l; i++ {
		if nums[i] < mn {
			mn = nums[i]
		}
	}
	return mn
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

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

func sint64() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sint64s(n int64) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = sint64()
	}
	return a
}

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

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		k := sint64()
		sol(n, k)
	}
}

func sol(_, k int64) {
	ans := int64(0)
	cum := int64(0)
	curr := int64(0)
	for submit(ans) != 1 { // we should get an answer before this reaches n
		curr++
		ans = xork(cum, curr, k)
		cum = xork(cum, ans, k)
	}
}

func xork(a, b, k int64) int64 {
	ret := int64(0)
	mul := int64(1)
	for !(a == 0 && b == 0) {
		rema := a % k
		remb := b % k
		ret += ((rema + remb) % k) * mul
		mul *= k
		a -= rema
		b -= remb
		a /= k
		b /= k
	}
	return ret
}

func submit(ans int64) int64 {
	printf("%d\n", ans)
	writer.Flush()
	return sint64()
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

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

func sint64() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sint64s(n int64) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = sint64()
	}
	return a
}

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

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		k := sint64()
		sol(n, k)
	}
}

func sol(n, _ int64) {
	ans := int64(0)
	curr := int64(0)
	for submit(ans) != 1 { // we should get an answer before this reaches n
		curr++
		ans = ans ^ curr
	}
}

func submit(ans int64) int64 {
	printf("%d\n", ans)
	writer.Flush()
	return sint64()
}

package main

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

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

func main() {
	var t int
	fmt.Fscan(reader, &t)
	for i := 0; i < t; i++ {
	 solve()
	}
}

func solve() {
	var n, k, c, r, p int
	c = 0
	fmt.Fscan(reader, &n, &k)
	for i := n; i >= 0; i-- {
		p = c ^ i
		fmt.Fprintln(writer, p)
		c = c ^ p
		writer.Flush()
		fmt.Fscan(reader, &r)
		if r == 1 {
			break
		}
	}
}

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

func fabs(a float64) float64 {
		if a < 0 {
			return -a
		}
		return a
}

func min(nums ...int64) int64 {
	l := len(nums)
	mn := nums[0]
	for i := 0; i < l; i++ {
		if nums[i] < mn {
			mn = nums[i]
		}
	}
	return mn
}

func fmin(nums ...float64) float64 {
	l := len(nums)
	mn := nums[0]
	for i := 0; i < l; i++ {
		if nums[i] < mn {
			mn = nums[i]
		}
	}
	return mn
}


package main

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

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

func scanf(f string, args ...interface{}) error {
	_, err := fmt.Fscanf(reader, f, args...)
	return err
}

func printf(f string, args ...interface{}) error {
	if _, err := fmt.Fprintf(writer, f, args...); err != nil {
		return err
	}
	if len(f) > 0 && f[len(f)-1] == '\n' {
		return writer.Flush()
	}
	return nil
}

func main() {
	var t int
	scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		var s string
		scanf("%s\n", &s)
		solve(s)
	}
}

func solve(s string) {
	ans := 0
	lens := []int{0}
	nums := make([]int, 0)
	iszero := true
	for _, c := range s {
		if c == '1' {
			ans++ // len(substr) == 1
			if iszero {
				nums = append(nums, 0)
				iszero = false
			}
		} else {
			if !iszero {
				ans++ // len(substr) == 2
				lens = append(lens, 0)
				iszero = true
			}
		}
		for j := range lens {
			lens[j] += 1
		}
		for j := range nums {
			if iszero {
				nums[j] <<= 1
			} else {
				nums[j] = nums[j]<<1 | 1
			}
			if nums[j] >= 3 && nums[j] <= lens[j] {
				ans++
			}
		}
		if len(nums) > 0 && nums[0] > lens[0] {
			lens = lens[1:]
			nums = nums[1:]
		}
		// printf("lens: %v\n", lens)
		// printf("nums: %v\n", nums)
	}
	printf("%d\n", ans)
}

package main

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

type point struct {
	x, y int
}

var ans int64

const (
	mod = int(1e9 + 7)
)

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

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscanf(in, "%d\n", &t)
	for ii := 0; ii < t; ii++ {
		s := ""
		fmt.Fscanf(in, "%s\n", &s)
		n := len(s)
		nextone := make([]int, n)
		last := -1
		for i := n - 1; i >= 0; i-- {
			if s[i] == '1' {
				last = i
			}
			nextone[i] = last
		}
		ans := 0
		for i := 0; i < n; i++ {
			v1 := 0
			v2 := 0
			v1 = 1
			from := nextone[i]
			if nextone[i] == -1 {
				continue
			}
			v1 = 1
			v2 = from - i + 1
			for v1 <= v2 {
				if v1 == v2 {
					ans++
				}
				from++
				if from >= n {
					break
				}
				if s[from] == '1' {
					v1 *= 2
					v1 += 1
					v2++
				} else {
					v1 *= 2
					v2++
				}
			}
		}
		fmt.Fprintf(out, "%d\n", ans)
	}
	return
}

func help(i int, n int, total int, t []int, g []int, cur int, c1, c2, c3 int, remaining int) {
	//fmt.Println(i, cur)
	if i == n {
		if cur == total {
			cal(c1, c2, c3)
		}
		return
	}
	if cur > total {
		return
	}
	if cur+remaining < total {
		return
	}
	switch g[i] {
	case 1:
		help(i+1, n, total, t, g, cur+t[i], c1+1, c2, c3, remaining-t[i])
	case 2:
		help(i+1, n, total, t, g, cur+t[i], c1, c2+1, c3, remaining-t[i])
	case 3:
		help(i+1, n, total, t, g, cur+t[i], c1, c2, c3+1, remaining-t[i])
	}
	help(i+1, n, total, t, g, cur, c1, c2, c3, remaining-t[i])
}

func cal(c1, c2, c3 int) {
	a := []int{c1, c2, c3}
	sort.Ints(a)
	tmp := int64(try(c1, c2, c3, 0))
	tmp %= int64(mod)
	for i := 1; i <= c1; i++ {
		tmp *= int64(i)
		tmp %= int64(mod)
	}
	for i := 1; i <= c2; i++ {
		tmp *= int64(i)
		tmp %= int64(mod)
	}
	for i := 1; i <= c3; i++ {
		tmp *= int64(i)
		tmp %= int64(mod)
	}
	ans += tmp
	ans %= int64(mod)
}

func try(a, b, c int, last int) int64 {
	if a == 0 && b == 0 && c == 0 {
		return 1
	}
	if a < 0 || b < 0 || c < 0 {
		return 0
	}
	if last == 0 {
		return try(a-1, b, c, 1) + try(a, b-1, c, 2) + try(a, b, c-1, 3)
	}
	if last == 1 {
		return try(a, b-1, c, 2) + try(a, b, c-1, 3)
	}
	if last == 2 {
		return try(a-1, b, c, 1) + try(a, b, c-1, 3)
	}
	return try(a-1, b, c, 1) + try(a, b-1, c, 2)
}

package main

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

func main() {
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)
	var T int
	fmt.Fscanf(reader, "%d\n", &T)
	for ; T != 0; T-- {
		var s string
		fmt.Fscanf(reader, "%s\n", &s)
		n := len(s)
		ans := 0
		last := -1
		for i := 0; i < n; i++ {
			if s[i] == '1' {
				cnt := 0
				for j := i; j < i+21 && j < n; j++ {
					cnt = cnt*2 + int(s[j]) - '0'
					if cnt > j-last {
						break
					}
					ans++
				}
				last = i
			}
		}
		fmt.Println(ans)
	}
}

package main

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

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

	var t int
	var s []byte
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &s)
		n, ans := len(s), 0
		pre1 := make([]int, n)
		p := -1
		for i, b := range s {
			pre1[i] = p
			if b == '1' {
				p = i
			}
			s[i] -= '0'
		}
		for i := range s {
			v := 0
			for j, l := i, 1; j >= 0; j-- {
				v |= int(s[j]) << (l - 1)
				if v == l {
					ans++
				}
				if l > 20 {
					if v > l && i-pre1[j] >= v {
						ans++
					}
					break
				}
				l++
			}
		}
		Fprintln(out, ans)
	}
}

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

package main

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

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1000000)

	s, _, _ := reader.ReadLine()
	t, _ := strconv.Atoi(string(s))

	for tc := 0; tc < t; tc++ {
		s, _, _ := reader.ReadLine()
		a := string(s)
		n := len(a)

		answer := 0
		zeroes := 0
		for i := 0; i < n; i++ {
			if a[i] == '1' {
				maxj := i + 20
				if maxj > n {
					maxj = n
				}

				num := 0
				for j := i; j < maxj; j++ {
					num <<= 1
					num += int(a[j] - '0')
					if j - num + 1 >= i - zeroes {
						answer++
					}
				}

				zeroes = 0
			} else if a[i] == '0' {
				zeroes++
			} else {
				os.Exit(1)
			}

		}

		fmt.Println(answer)
	}
}

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

package main

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

func countGoodSubstrings(s string, buffer int, leftPtr int, n int) int {
	value := 0
	count := 0
	rightPtr := leftPtr
	for rightPtr < n {
		c := string(s[rightPtr])
		if c == "1" {
			value = 2*value + 1
		} else {
			value *= 2
		}
		length := rightPtr - leftPtr + 1 + buffer
		if value <= length {
			count += 1
			rightPtr += 1
		} else {
			return count
		}
	}
	return count
}

func Solve(s string) int {
	n := len(s)
	leftPtr := 0
	buffer := 0
	count := 0
	for leftPtr < n {
		c := string(s[leftPtr])
		if c == "0" {
			buffer += 1
		} else {
			count += countGoodSubstrings(s, buffer, leftPtr, n)
			buffer = 0
		}
		leftPtr += 1
	}
	return count
}

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

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

package main

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

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

func scanf(f string, args ...interface{}) error {
	_, err := fmt.Fscanf(reader, f, args...)
	return err
}

func printf(f string, args ...interface{}) error {
	if _, err := fmt.Fprintf(writer, f, args...); err != nil {
		return err
	}
	if len(f) > 0 && f[len(f)-1] == '\n' {
		return writer.Flush()
	}
	return nil
}

func main() {
	var t int
	scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		var s string
		scanf("%s\n", &s)
		solve(s)
	}
}

func solve(s string) {
	ans := 0
	lens := []int{0}
	nums := make([]int, 0)
	iszero := true
	for _, c := range s {
		if c == '1' {
			ans++ // len(substr) == 1
			if iszero {
				nums = append(nums, 0)
				iszero = false
			}
		} else {
			if !iszero {
				ans++ // len(substr) == 2
				lens = append(lens, 0)
				iszero = true
			}
		}
		for j := range lens {
			lens[j] += 1
		}
		k := 0
		for j := range nums {
			if iszero {
				nums[j] <<= 1
			} else {
				nums[j] = nums[j]<<1 | 1
			}
			if nums[j] >= 3 && nums[j] <= lens[j] {
				ans++
			} else if nums[j] > lens[j] {
				k = j + 1
			}
		}
		// printf("lens: %v\n", lens)
		// printf("nums: %v\n", nums)
		lens = lens[k:]
		nums = nums[k:]
	}
	printf("%d\n", ans)
}

package main

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

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

	var t int
	var s []byte
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &s)
		n, ans := len(s), 0
		pre1 := make([]int, n)
		p := -1
		for i, b := range s {
			pre1[i] = p
			if b == '1' {
				p = i
			}
			s[i] -= '0'
		}
		for i := range s {
			v := 0
			for j, l := i, 1; j >= 0; j-- {
				v |= int(s[j]) << (l - 1)
				if v == l {
					ans++
				}
				if l > 20 {
					if v > l+1 && i-pre1[j] >= v {
						ans++
					}
					break
				}
				l++
			}
		}
		Fprintln(out, ans)
	}
}

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

package main

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

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

	s, _, _ := reader.ReadLine()
	t, _ := strconv.Atoi(string(s))

	for tc := 0; tc < t; tc++ {
		s, _, _ := reader.ReadLine()
		a := string(s)
		n := len(a)

		m := make(map[int64]bool)

		answer := 0
		zeroes := 0
		for i := 0; i < n; i++ {
			if a[i] == '1' {
				maxj := i + 20
				if maxj > n {
					maxj = n
				}

				num := 0
				for j := i; j < maxj; j++ {
					num <<= 1
					num += int(a[j] - '0')
					if j - num + 1 >= i - zeroes {
						m[int64(j) << 20 + int64(num)] = true
						answer++
					}
				}

				zeroes = 0
			} else if a[i] == '0' {
				zeroes++
			} else {
				os.Exit(1)
			}

		}

		fmt.Println(len(m))
	}
}

package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)

	s.Scan()
	t, _ := strconv.Atoi(s.Text())

	for tc := 0; tc < t; tc++ {
		s.Scan()
		a := s.Text()
		n := len(a)

		m := make(map[int64]bool)

		answer := 0
		zeroes := 0
		for i := 0; i < n; i++ {
			if a[i] == '1' {
				maxj := i + 25
				if maxj > n {
					maxj = n
				}

				num := 0
				for j := i; j < maxj; j++ {
					num <<= 1
					num += int(a[j] - '0')
					if j - num + 1 >= i - zeroes {
						m[int64(j) << 25 + int64(num)] = true
						answer++
					}
				}

				zeroes = 0
			} else if a[i] == '0' {
				zeroes++
			} else {
				os.Exit(1)
			}

		}

		fmt.Println(len(m))
	}
}

package main

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

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

	s, _, _ := reader.ReadLine()
	t, _ := strconv.Atoi(string(s))

	for tc := 0; tc < t; tc++ {
		s, _, _ := reader.ReadLine()
		a := string(s)
		n := len(a)

		// m := make(map[int64]bool)

		answer := 0
		zeroes := 0
		for i := 0; i < n; i++ {
			if a[i] == '1' {
				maxj := i + 20
				if maxj > n {
					maxj = n
				}

				num := 0
				for j := i; j < maxj; j++ {
					num <<= 1
					num += int(a[j] - '0')
					if j - num + 1 >= i - zeroes {
						// m[int64(j) << 20 + int64(num)] = true
						answer++
					}
				}

				zeroes = 0
			} else if a[i] == '0' {
				zeroes++
			} else {
				os.Exit(1)
			}

		}

		fmt.Println(answer)
	}
}

package main

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

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

	s, _ := reader.ReadString('\n')
	s = strings.Replace(s, "\n", "", -1)
	t, _ := strconv.Atoi(s)

	for tc := 0; tc < t; tc++ {
		a, _ := reader.ReadString('\n')
		a = strings.Replace(a, "\n", "", -1)
		n := len(a)

		m := make(map[int64]bool)

		answer := 0
		zeroes := 0
		for i := 0; i < n; i++ {
			if a[i] == '1' {
				maxj := i + 20
				if maxj > n {
					maxj = n
				}

				num := 0
				for j := i; j < maxj; j++ {
					num <<= 1
					num += int(a[j] - '0')
					if j - num + 1 >= i - zeroes {
						m[int64(j) << 20 + int64(num)] = true
						answer++
					}
				}

				zeroes = 0
			} else if a[i] == '0' {
				zeroes++
			} else {
				os.Exit(1)
			}

		}

		fmt.Println(len(m))
	}
}

package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)

	s.Scan()
	t, _ := strconv.Atoi(s.Text())

	for tc := 0; tc < t; tc++ {
		s.Scan()
		a := s.Text()
		n := len(a)

		m := make(map[int64]bool)

		answer := 0
		zeroes := 0
		for i := 0; i < n; i++ {
			if a[i] == '1' {
				maxj := i + 20
				if maxj > n {
					maxj = n
				}

				num := 0
				for j := i; j < maxj; j++ {
					num <<= 1
					num += int(a[j] - '0')
					if j - num + 1 >= i - zeroes {
						m[int64(j) << 20 + int64(num)] = true
						answer++
					}
				}

				zeroes = 0
			} else if a[i] == '0' {
				zeroes++
			} else {
				os.Exit(1)
			}

		}

		fmt.Println(len(m))
	}
}

package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)

	s.Scan()
	t, _ := strconv.Atoi(s.Text())

	for tc := 0; tc < t; tc++ {
		s.Scan()
		a := s.Text()
		n := len(a)

		m := make(map[int64]bool)

		answer := 0
		zeroes := 0
		for i := 0; i < n; i++ {
			if a[i] == '1' {
				maxj := i + 20
				if maxj > n {
					maxj = n
				}

				num := 0
				for j := i; j < maxj; j++ {
					num <<= 1
					num += int(a[j] - '0')
					l := j - i + 1
					if l + zeroes >= num {
						m[int64(j << 20) + int64(num)] = true
						answer++
					}
				}

				zeroes = 0
			} else if a[i] == '0' {
				zeroes++
			} else {
				os.Exit(1)
			}

		}

		fmt.Println(len(m))
	}
}

package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)

	s.Scan()
	t, _ := strconv.Atoi(s.Text())

	for tc := 0; tc < t; tc++ {
		s.Scan()
		a := s.Text()
		n := len(a)

		answer := int64(0)
		zeroes := 0;
		for i := 0; i < n; i++ {
			if a[i] == '1' {
				maxj := i + 20;
				if maxj > n {
					maxj = n;
				}

				num := 0;
				for j := i; j < maxj; j++ {
					num <<= 1;
					num += int(a[j] - '0')
					l := j - i + 1;
					if l + zeroes >= num {
						answer++;
					}
				}

				zeroes = 0;
			} else {
				zeroes++;
			}

		}

		fmt.Println(answer)
	}
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF798C(_r io.Reader, _w io.Writer) {
	gcd := func(a, b int) int {
		for a != 0 {
			a, b = b%a, a
		}
		return b
	}
	in := bufio.NewReader(_r)
	var n, c, g int
	Fscan(in, &n)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
		g = gcd(g, a[i])
		a[i] &= 1
	}
	if g == 1 {
		for i, v := range a {
			if v == 1 {
				if i+1 == n {
					c += 2
				} else if a[i+1] == 0 {
					c += 2
				} else {
					a[i+1] = 0
					c++
				}
			}
		}
	}
	Fprintln(_w, "YES")
	Fprint(_w, c)
}

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

package main

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

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.goC"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n int
	for I(&n) == nil {
		solve(n)
	}
}

func solve(n int) {
	arr := make([]int64, n)
	var g int64
	for i := range arr {
		I(&arr[i])
		if i == 0 {
			g = arr[0]
		} else {
			g = gcd(g, arr[i])
		}
	}
	O("YES\n")
	if g > 1 {
		O("0\n")
		return
	}
	var ans int64
	for i := range arr {
		if arr[i]%2 == 1 {
			if i < n-1 && arr[i+1]%2 == 1 {
				ans++
				arr[i], arr[i+1] = arr[i]-arr[i+1], arr[i]+arr[i+1]
			} else if i > 0 && arr[i-1]%2 == 1 {
				ans++
				arr[i-1], arr[i] = arr[i-1]-arr[i], arr[i-1]+arr[i]
			} else if i < n-1 {
				ans += 2
				arr[i], arr[i+1] = arr[i]-arr[i+1], arr[i]+arr[i+1]
				arr[i], arr[i+1] = arr[i]-arr[i+1], arr[i]+arr[i+1]
			} else if i > 0 {
				ans += 2
				arr[i-1], arr[i] = arr[i-1]-arr[i], arr[i-1]+arr[i]
				arr[i-1], arr[i] = arr[i-1]-arr[i], arr[i-1]+arr[i]
			}
		}
	}
	O(ans, "\n")
}

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

package main

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

func Solve(io *FastIO) {
	N := io.NextInt()
	A := io.NextLongArray(N)

	g := A[0]
	for i := 1; i < N && g > 1; i++ {
		g = GCD(g, Abs(A[i]))
	}

	if g > 1 {
		io.Printf("YES\n")
		io.Printf("0\n")
		return
	}

	moves := 0
	idx := 0
	for idx + 1 < N {
		if A[idx] % 2 != 0 {
			parity := (A[idx] + A[idx + 1]) % 2
			A[idx] = parity
			A[idx + 1] = parity
			moves++
		} else {
			idx++
		}
	}
	if A[N - 1] % 2 != 0 {
		moves += 2
	}
	io.Printf("YES\n")
	io.Printf("%d\n", moves)
}

func Abs(x int64) int64 {
	if (x < 0) {
		return -x
	} else {
		return x
	}
}

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

	r := a % b
	if r == 0 {
		return b
	}

	return GCD(b, r)
}

func GCDAll(args ...int64) int64 {
	ans := args[0]
	for i := 1; i < len(args); i++ {
		ans = GCD(ans, args[i])
	}
	return ans
}

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

func IsLineBreakChar(c byte) bool {
	switch c {
		case 0, '\n', '\r':
			return true
		default:
			return false
	}
}

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Solve(&io)
	io.FlushOutput()
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF798C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	var n, c int
	Fscan(in, &n)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
		a[i] &= 1
	}
	for i, v := range a {
		if v == 1 {
			if i+1 == n {
				c += 2
			} else if a[i+1] == 0 {
				c += 2
			} else {
				a[i+1] = 0
				c++
			}
		}
	}
	Fprintln(_w, "YES")
	Fprint(_w, c)
}

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


package main

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

func GetReaderWriter() (*bufio.Reader, *bufio.Writer) {
	l := os.Getenv("LOCAL_DEBUG")
	reader := io.Reader(os.Stdin)
	writer := io.Writer(os.Stdout)
	if l != "" {
		bs, _ := ioutil.ReadFile("in.txt")
		reader = bytes.NewBuffer(bs)
	}
	return bufio.NewReader(reader), bufio.NewWriter(writer)
}

func main() {
	reader, writer := GetReaderWriter()
	defer writer.Flush()
	var i, q, n, j int64
	_, _ = Fscanf(reader, "%d\n", &q)

	for q > 0 {
		q--
		_, _ = Fscanf(reader, "%d\n", &n)
		s := make([]string, n)
		ll := make([]int64, n)
		s0 := int64(0)
		s1 := int64(0)
		te := int64(0)
		to := int64(0)
		for i = 0; i < n; i++ {
			_, _ = Fscanf(reader, "%s\n", &s[i])
			ll[i] = int64(len(s[i]))
			for j = 0; j < int64(len(s[i])); j++ {
				if s[i][j] == '0' {
					s0++
				} else {
					s1++
				}
			}
			if len(s[i])%2 == 0 {
				te++
			} else {
				to++
			}
		}
		// sort.Slice(ll, func(i, j int) bool { return ll[i] < ll[j] })
		if to == 0 {
			if 1 == s0%2 {
				n--
			}
		}
		_, _ = Fprintf(writer, "%d\n", n)
	}
}

package main

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

/* solution */

func solve() {
	t := readInt()
	for i := 0; i < t; i++ {
		solveOne()
	}
}

func solveOne() {
	n := readInt()
	var zero, one, cap int
	for i := 0; i < n; i++ {
		s := read()
		if (len(s))%2 == 1 {
			cap++
		}
		for j := 0; j < len(s); j++ {
			if s[j] == '0' {
				zero = 1 - zero
			} else {
				one = 1 - one
			}
		}
	}

	cap -= zero + one
	if cap >= 0 {
		cap = 0
	} else {
		cap = -1
	}

	printInt(n + cap)

}

/* stubs */

func main() {

	var f *os.File
	if runtime.GOROOT() == "C:\\Soft\\Go" {
		f, _ = os.Open("input.txt")
		defer f.Close()
	} else {
		f = os.Stdin
	}

	writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	reader = bufio.NewScanner(f)

	const maxCapacity = 1024 * 1024
	buf := make([]byte, maxCapacity)
	reader.Buffer(buf, maxCapacity)

	reader.Split(bufio.ScanLines)

	solve()

}

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

func read() string {
	reader.Scan()
	return reader.Text()
}

func readInt() int {
	reader.Scan()
	ret, _ := strconv.Atoi(reader.Text())
	return ret
}

func print(s string) {
	writer.WriteString(s)
	writer.WriteString("\n")
}

func printInt(i int) {
	print(strconv.Itoa(i))
}

func printInt64(i int64) {
	print(strconv.FormatInt(i, 10))
}

func readInt64() int64 {
	reader.Scan()
	ret, _ := strconv.ParseInt(reader.Text(), 10, 64)
	return ret
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	q := 0
	fmt.Fscanf(in, "%d\n", &q)
	res := make([]int, q)
	var wg sync.WaitGroup
	wg.Add(q)
	for i := 0; i < q; i++ {
		n := 0
		fmt.Fscanf(in, "%d\n", &n)
		strs := make([][]byte, n)
		allEven := true
		zeros, ones := 0, 0
		for _, s := range strs {
			s, _ = in.ReadBytes('\n')
			if len(s)%2 == 1 {
				allEven = false
			}
			for _, c := range s {
				if c == '0' {
					zeros++
				}
				if c == '1' {
					ones++
				}
			}
		}
		go func(id int, z, o int, ae bool, en int) {
		  	defer wg.Done()
			if ae && z%2 == 1 {
				res[id] = en - 1
			} else {
				res[id] = en
			}
		}(i, zeros, ones, allEven, n)
	}
	wg.Wait()
	for _, s := range res {
		fmt.Println(s)
	}
}

package main

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

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

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

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

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

// ReadInt returns an integer.
func ReadInt() int {
	return 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
}

/*********** DP sub-functions ***********/

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

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

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

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

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

/********** 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 MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var q int
var n int
var S [][]rune

func main() {
	q = ReadInt()

	for i := 0; i < q; i++ {
		n = ReadInt()
		S = [][]rune{}
		for j := 0; j < n; j++ {
			S = append(S, ReadRuneSlice())
		}

		one, zero := 0, 0
		for j := 0; j < n; j++ {
			for k := 0; k < len(S[j]); k++ {
				if S[j][k] == '1' {
					one++
				} else {
					zero++
				}
			}
		}

		evens := []int{}
		odds := []int{}
		for j := 0; j < n; j++ {
			if len(S[j])%2 == 0 {
				evens = append(evens, len(S[j]))
			} else {
				odds = append(odds, len(S[j]))
			}
		}
		sort.Sort(sort.IntSlice(evens))
		sort.Sort(sort.IntSlice(odds))

		ans := solve(evens, odds, one, zero)
		fmt.Println(ans)
	}
}

func solve(evens, odds []int, one, zero int) int {
	ans := 0

	// 偶数から
	for i := 0; i < len(evens); i++ {
		enum := evens[i]
		for enum > 0 {
			if one < 2 && zero < 2 {
				break
			}

			enum -= 2
			if one > zero {
				one -= 2
			} else {
				zero -= 2
			}
		}

		if enum == 0 {
			ans++
		}
	}

	// 次に奇数
	for i := 0; i < len(odds); i++ {
		onum := odds[i]
		if one == 0 && zero == 0 {
			break
		}
		onum--
		if one%2 == 1 {
			one--
		} else {
			zero--
		}

		// onumは偶数が確定
		for onum > 0 {
			if one < 2 && zero < 2 {
				break
			}

			onum -= 2
			if one > zero {
				one -= 2
			} else {
				zero -= 2
			}
		}

		if onum == 0 {
			ans++
		}
	}

	return ans
}

func sub(L []int, one, zero int) int {
	ans := 0
	for j := 0; j < len(L); j++ {
		l := L[j]

		for l > 0 {
			if l >= 2 {
				l -= 2
				if one > zero {
					if one-2 < 0 {
						return ans
					}
					one -= 2
				} else {
					if zero-2 < 0 {
						return ans
					}
					zero -= 2
				}
			} else {
				l--
				if one > zero {
					if one-1 < 0 {
						return ans
					}
					one--
				} else {
					if zero-1 < 0 {
						return ans
					}
					zero--
				}
			}
		}

		ans++
	}

	return ans
}

// MODはとったか？
// 遷移だけじゃなくて最後の最後でちゃんと取れよ？

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

package main

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

type point struct {
	x, y int
}

var ans int64

const (
	mod = int(1e9 + 7)
)

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

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	tt := 1
	fmt.Fscanf(in, "%d\n", &tt)
	for ii := 0; ii < tt; ii++ {
		n := 0
		fmt.Fscanf(in, "%d\n", &n)
		s := ""
		a := make([]int, n)
		c1 := 0
		c0 := 0
		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%s\n", &s)
			a[i] = len(s)
			for j := 0; j < a[i]; j++ {
				if s[j] == '0' {
					c0++
				} else {
					c1++
				}
			}
		}
		sort.Ints(a)
		d0 := c0 / 2
		d1 := c1 / 2
		d := d0 + d1
		ans := 0
		for i := 0; i < n; i++ {
			if a[i]%2 == 0 {
				if d >= a[i]/2 {
					ans++
				}
				d -= a[i] / 2
			} else {
				ans++
			}
		}
		fmt.Fprintf(out, "%d\n", ans)
	}
	return
}

func help(i int, n int, total int, t []int, g []int, cur int, c1, c2, c3 int, remaining int) {
	//fmt.Println(i, cur)
	if i == n {
		if cur == total {
			cal(c1, c2, c3)
		}
		return
	}
	if cur > total {
		return
	}
	if cur+remaining < total {
		return
	}
	switch g[i] {
	case 1:
		help(i+1, n, total, t, g, cur+t[i], c1+1, c2, c3, remaining-t[i])
	case 2:
		help(i+1, n, total, t, g, cur+t[i], c1, c2+1, c3, remaining-t[i])
	case 3:
		help(i+1, n, total, t, g, cur+t[i], c1, c2, c3+1, remaining-t[i])
	}
	help(i+1, n, total, t, g, cur, c1, c2, c3, remaining-t[i])
}

func cal(c1, c2, c3 int) {
	a := []int{c1, c2, c3}
	sort.Ints(a)
	tmp := int64(try(c1, c2, c3, 0))
	tmp %= int64(mod)
	for i := 1; i <= c1; i++ {
		tmp *= int64(i)
		tmp %= int64(mod)
	}
	for i := 1; i <= c2; i++ {
		tmp *= int64(i)
		tmp %= int64(mod)
	}
	for i := 1; i <= c3; i++ {
		tmp *= int64(i)
		tmp %= int64(mod)
	}
	ans += tmp
	ans %= int64(mod)
}

func try(a, b, c int, last int) int64 {
	if a == 0 && b == 0 && c == 0 {
		return 1
	}
	if a < 0 || b < 0 || c < 0 {
		return 0
	}
	if last == 0 {
		return try(a-1, b, c, 1) + try(a, b-1, c, 2) + try(a, b, c-1, 3)
	}
	if last == 1 {
		return try(a, b-1, c, 2) + try(a, b, c-1, 3)
	}
	if last == 2 {
		return try(a-1, b, c, 1) + try(a, b, c-1, 3)
	}
	return try(a-1, b, c, 1) + try(a, b-1, c, 2)
}

package main

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

type WordScanner struct {
	*bufio.Scanner
}

func NewWordScanner() *WordScanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return &WordScanner{Scanner: s}
}

func (s *WordScanner) NextInt() int {
	s.Scan()
	i, _ := strconv.Atoi(s.Text())
	return i
}

func (s *WordScanner) NextInt64() int64 {
	s.Scan()
	i, _ := strconv.ParseInt(s.Text(), 10, 64)
	return i
}

func (s *WordScanner) NextString() string {
	s.Scan()
	return s.Text()
}

func main() {
	ws := NewWordScanner()
	Q := ws.NextInt()
	for ; Q > 0; Q-- {
		n := ws.NextInt()
		s := []string{}
		for ; n > 0; n-- {
			s = append(s, ws.NextString())
		}
		fmt.Println(sol(s))
	}
}

func sol(sl []string) int {
	nOnes := 0
	nZeroes := 0
	toFill := 0
	for _, s := range sl {
		if len(s)%2 == 0 {
			toFill += len(s)
		}
		for _, r := range s {
			if r == '1' {
				nOnes++
			} else {
				nZeroes++
			}
		}
	}
	totalFill := (nOnes / 2 * 2) + (nZeroes / 2 * 2)
	if totalFill >= toFill {
		return len(sl)
	}
	return len(sl) - 1
}

package main

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

const INFINITY = math.MaxInt32/2 - 1

func exec(stdin *Stdin, stdout *Stdout) {
	for q := stdin.ReadInt(); q > 0; q-- {
		s := []string{}
		for n := stdin.ReadInt(); n > 0; n-- {
			s = append(s, stdin.Read())
		}

		allEven := true
		for _, c := range s {
			if len(c)%2 != 0 {
				allEven = false
			}
		}

		zero := 0
		one := 0
		for _, c := range s {
			for _, d := range c {
				if d == '0' {
					zero++
				} else {
					one++
				}
			}
		}

		if allEven && zero%2 != 0 && one%2 != 0 {
			stdout.Println(len(s) - 1)
		} else {
			stdout.Println(len(s))
		}
	}
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), INFINITY)
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadInt64() int64 {
	n, _ := strconv.ParseInt(s.Read(), 10, 64)
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

func (s *Stdin) ReadIntSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = s.ReadInt()
	}
	return a
}

func (s *Stdin) ReadStringSlice(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = s.Read()
	}
	return a
}

func (s *Stdin) ReadFloat64Slice(n int) []float64 {
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		a[i] = s.ReadFloat64()
	}
	return a
}

func (s *Stdin) ReadInt64Slice(n int) []int64 {
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		a[i] = s.ReadInt64()
	}
	return a
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}

func Min(a int, b ...int) int {
	for _, v := range b {
		if v < a {
			a = v
		}
	}
	return a
}

func Max(a int, b ...int) int {
	for _, v := range b {
		if a < v {
			a = v
		}
	}
	return a
}

func Abs(x int) int {
	if x > 0 {
		return x
	} else {
		return x * -1
	}
}

func Pow(x, y int) int {
	z := 1
	for y > 0 {
		if y%2 == 0 {
			x *= x
			y /= 2
		} else {
			z *= x
			y -= 1
		}
	}
	return z
}

func IsPrime(x int) bool {
	if x < 2 {
		return false
	}

	for i := 2; i*i <= x; i++ {
		if x%i == 0 {
			return false
		}
	}
	return true
}

func Gcd(x, y int) int {
	if x < y {
		x, y = y, x
	}

	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func Lcm(x, y int) int {
	return x * y / Gcd(x, y)
}

func CeilDiv(x, y int) int {
	if x%y == 0 {
		return x / y
	} else {
		return x/y + 1
	}
}

func LCS(s, t string) string {
	n := len(s)
	m := len(t)
	dp := make([][]int, n+1)
	for i := 0; i <= n; i++ {
		dp[i] = make([]int, m+1)
	}

	for i := 1; i <= n; i++ {
		for j := 1; j <= m; j++ {
			if s[i-1] == t[j-1] {
				dp[i][j] = dp[i-1][j-1] + 1
			} else {
				dp[i][j] = Max(dp[i-1][j], dp[i][j-1])
			}
		}
	}

	x := n
	y := m
	u := make([]byte, dp[n][m])
	i := dp[n][m] - 1
	for x > 0 && y > 0 {
		if dp[x][y] == dp[x-1][y] {
			x--
		} else if dp[x][y] == dp[x][y-1] {
			y--
		} else {
			x--
			y--
			u[i] = s[x]
			i--
		}
	}

	return string(u)
}

// [0..n) から r個選んだ組合せを生成する。
// r < 0 の場合はすべての組合せを生成する。
func Combinations(n int, r int) [][]int {
	a := [][]int{}
	for i := uint(0); i < (1 << uint(n)); i++ {
		b := []int{}
		for j := uint(0); j < uint(n); j++ {
			if i&(uint(1)<<j) != 0 {
				b = append(b, int(j))
			}
		}

		if r < 0 || len(b) == r {
			a = append(a, b)
		}
	}
	return a
}

// [0..n)の順列を生成する。
func Permutations(n int) [][]int {
	type e struct {
		bit uint
		a   []int
	}

	q := []*e{}
	for i := 0; i < n; i++ {
		q = append(q, &e{bit: 1 << uint(i), a: []int{i}})
	}

	p := [][]int{}
	for x := 0; x < len(q); x++ {
		cur := q[x]
		if cur.bit == (1<<uint(n) - 1) {
			p = append(p, cur.a)
			continue
		}

		for i := 0; i < n; i++ {
			if cur.bit&(1<<uint(i)) != 0 {
				continue
			}

			m := len(cur.a) + 1
			b := make([]int, m)
			copy(b, cur.a)
			b[m-1] = i
			q = append(q, &e{bit: cur.bit | (1 << uint(i)), a: b})
		}
	}
	return p
}

func ReverseSlice(v interface{}) {
	if reflect.TypeOf(v).Kind() == reflect.Slice {
		slice := reflect.ValueOf(v)
		for i1, n := 0, slice.Len(); i1 < n/2; i1++ {
			i2 := n - i1 - 1
			v1 := reflect.ValueOf(slice.Index(i1).Interface())
			slice.Index(i1).Set(slice.Index(i2))
			slice.Index(i2).Set(v1)
		}
	}
}

func ReverseString(s string) string {
	t := []rune(s)
	ReverseSlice(t)
	return string(t)
}

func ToStringSlice(slice interface{}) []string {
	// 本来はerrを返却すべき。 利用する側(=自分)は引数がsliceであることを知っている。
	if reflect.TypeOf(slice).Kind() != reflect.Slice {
		panic(fmt.Sprintf("%v is not slice", slice))
	}

	src := reflect.ValueOf(slice)
	n := src.Len()
	dst := make([]string, n)
	for i := 0; i < n; i++ {
		dst[i] = fmt.Sprintf("%v", src.Index(i))
	}
	return dst
}

func CreateMatrix(x, y int) [][]int {
	matrix := make([][]int, x)
	for i := 0; i < x; i++ {
		matrix[i] = make([]int, y)
	}
	return matrix
}

func Min64(a int64, b ...int64) int64 {
	for _, v := range b {
		if v < a {
			a = v
		}
	}
	return a
}

func Max64(a int64, b ...int64) int64 {
	for _, v := range b {
		if a < v {
			a = v
		}
	}
	return a
}

func Abs64(x int64) int64 {
	if x > 0 {
		return x
	} else {
		return x * -1
	}
}

func Pow64(x, y int64) int64 {
	z := int64(1)
	for y > 0 {
		if y%2 == 0 {
			x *= x
			y /= 2
		} else {
			z *= x
			y--
		}
	}
	return z
}

func IsPrime64(x int64) bool {
	if x < 2 {
		return false
	}

	for i := int64(2); i*i <= x; i++ {
		if x%i == 0 {
			return false
		}
	}
	return true
}

func Gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}

	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func Lcm64(x, y int64) int64 {
	return x * y / Gcd64(x, y)
}

func CeilDiv64(x, y int64) int64 {
	if x%y == 0 {
		return x / y
	} else {
		return x/y + 1
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	q := 0
	fmt.Fscanf(in, "%d\n", &q)
	res := make([]int, q)
	var wg sync.WaitGroup
	wg.Add(q)
	for i := 0; i < q; i++ {
		n := 0
		fmt.Fscanf(in, "%d\n", &n)
		strs := make([][]byte, n)
		allEven := true
		zeros, ones := 0, 0
		for _, s := range strs {
			s, _ = in.ReadBytes('\n')
			if len(s)%2 == 0 {
				allEven = false
			}
			for _, c := range s {
				if c == '0' {
					zeros++
				}
				if c == '1' {
					ones++
				}
			}
		}
		go func(id int, zeros, ones int, allEven bool, n int) {
			defer wg.Done()
			if allEven && zeros%2 == 1 {
				res[id] = n - 1
			} else {
				res[id] = n
			}
		}(i, zeros, ones, allEven, n)
	}
	wg.Wait()
	for _, s := range res {
		fmt.Println(s)
	}
}

package main

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

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

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

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

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

// ReadInt returns an integer.
func ReadInt() int {
	return 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
}

/*********** DP sub-functions ***********/

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

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

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

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

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

/********** 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 MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var q int
var n int
var S [][]rune

func main() {
	q = ReadInt()

	for i := 0; i < q; i++ {
		n = ReadInt()
		S = [][]rune{}
		for j := 0; j < n; j++ {
			S = append(S, ReadRuneSlice())
		}

		one, zero := 0, 0
		L := []int{}
		for j := 0; j < n; j++ {
			for k := 0; k < len(S[j]); k++ {
				if S[j][k] == '1' {
					one++
				} else {
					zero++
				}
			}
		}

		for j := 0; j < n; j++ {
			L = append(L, len(S[j]))
		}
		// sort.Sort(sort.IntSlice(L))
		sort.Sort(sort.Reverse(sort.IntSlice(L)))

		ans := sub(L, one, zero)
		fmt.Println(ans)
	}
}

func sub(L []int, one, zero int) int {
	ans := 0
	for j := 0; j < len(L); j++ {
		l := L[j]

		for l > 0 {
			if l >= 2 {
				l -= 2
				if one > zero {
					if one-2 < 0 {
						return ans
					}
					one -= 2
				} else {
					if zero-2 < 0 {
						return ans
					}
					zero -= 2
				}
			} else {
				l--
				if one > zero {
					if one-1 < 0 {
						return ans
					}
					one--
				} else {
					if zero-1 < 0 {
						return ans
					}
					zero--
				}
			}
		}

		ans++
	}

	return ans
}

// MODはとったか？
// 遷移だけじゃなくて最後の最後でちゃんと取れよ？

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

package main

import (
	"bufio"
	"bytes"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"sort"
)

func GetReaderWriter() (*bufio.Reader, *bufio.Writer) {
	l := os.Getenv("LOCAL_DEBUG")
	reader := io.Reader(os.Stdin)
	writer := io.Writer(os.Stdout)
	if l != "" {
		bs, _ := ioutil.ReadFile("in.txt")
		reader = bytes.NewBuffer(bs)
	}
	return bufio.NewReader(reader), bufio.NewWriter(writer)
}

func main() {
	reader, writer := GetReaderWriter()
	defer writer.Flush()
	var i, q, n, j int64
	_, _ = Fscanf(reader, "%d\n", &q)

	for q > 0 {
		q--
		_, _ = Fscanf(reader, "%d\n", &n)
		s := make([]string, n)
		ll := make([]int64, n)
		s0 := int64(0)
		s1 := int64(0)
		te := int64(0)
		to := int64(0)
		for i = 0; i < n; i++ {
			_, _ = Fscanf(reader, "%s\n", &s[i])
			ll[i] = int64(len(s[i]))
			for j = 0; j < int64(len(s[i])); j++ {
				if s[i][j] == '0' {
					s0++
				} else {
					s1++
				}
			}
			if len(s[i])%2 == 0 {
				te++
			} else {
				to++
			}
		}
		sort.Slice(ll, func(i, j int) bool { return ll[i] < ll[j] })
		if te%2 == 1 && to%2 == 0 {
			if 1 == s0%2 {
				n--
			}
		}
		_, _ = Fprintf(writer, "%d\n", n)
	}
}

package main

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

func GetReaderWriter() (*bufio.Reader, *bufio.Writer) {
	l := os.Getenv("LOCAL_DEBUG")
	reader := io.Reader(os.Stdin)
	writer := io.Writer(os.Stdout)
	if l != "" {
		bs, _ := ioutil.ReadFile("in.txt")
		reader = bytes.NewBuffer(bs)
	}
	return bufio.NewReader(reader), bufio.NewWriter(writer)
}

func main() {
	reader, writer := GetReaderWriter()
	defer writer.Flush()
	var i, q, n, j int64
	_, _ = Fscanf(reader, "%d\n", &q)

	for q > 0 {
		q--
		_, _ = Fscanf(reader, "%d\n", &n)
		s := make([]string, n)
		ll := make([]int64, n)
		s0 := int64(0)
		s1 := int64(0)
		te := int64(0)
		to := int64(0)
		for i = 0; i < n; i++ {
			_, _ = Fscanf(reader, "%s\n", &s[i])
			ll[i] = int64(len(s[i]))
			for j = 0; j < int64(len(s[i])); j++ {
				if s[i][j] == '0' {
					s0++
				} else {
					s1++
				}
			}
			if len(s[i])%2 == 0 {
				te++
			} else {
				to++
			}
		}
		// sort.Slice(ll, func(i, j int) bool { return ll[i] < ll[j] })
		if to%2 == 0 {
			if 1 == s0%2 {
				n--
			}
		}
		_, _ = Fprintf(writer, "%d\n", n)
	}
}


// Codeforces 1101 B Accordion train
package main

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

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

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

var n int
var s string
var alen int

type State int
const (
	LeftNone = 0
	OpenBrack = 1
	FirstColon = 2
	VertLine = 3
	SecondColon = 4
	CloseBrack = 5
	RightNone = 6
)

func readData() {
	in = bufio.NewReader(os.Stdin)
	delim := byte('\n')
	ss, err := in.ReadString(delim)
	s = strings.Trim(ss, " \n\r")
	n = len(s)
	// fmt.Println("N=", n)
	if err != nil {
		fmt.Println("read failure", err)
		panic(err)
	}
}

func solve() {
	var inBeg,inEnd,nVert int
	state := LeftNone
	for i := 0; i<n; i++ {
		c := s[i]
		if state==LeftNone && c=='[' {
			state = OpenBrack
		} else if state==OpenBrack && c==':' {
			state = FirstColon
			inBeg = i+1
			break
		}
	}
	state = RightNone
	for i:=n-1; i>=0; i-- {
		c := s[i]
		if state==RightNone && c==']' {
			state = CloseBrack
		} else if state==CloseBrack && c==':' {
			state = SecondColon
			inEnd = i
			break
		}
	}
	// fmt.Println("inBeg,inEnd=", inBeg,inEnd)
	if inBeg==0 || inEnd==0 || inEnd <inBeg {
		alen = -1
		return
	}
	for i:=inBeg; i<inEnd; i++ {
		c := s[i]
		if c=='|' {
			nVert++;
		}
	}
	alen = 4 + nVert
}

func printRes() {
	fmt.Println(alen)
}

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

package main

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

type caseInput struct {
	BayanStr string
}

func readCaseInput(scanner *bufio.Scanner) caseInput {
	return caseInput{readString(scanner)}
}

type caseOutput struct {
	BayanLen int32
}

func writeCaseOutput(writer *bufio.Writer, out caseOutput) {
	writef(writer, "%d\n", out.BayanLen)
}

func solveCase(in caseInput) caseOutput {
	opened := false
	firstColonSeen := false
	closingColonSeen := false
	closed := false

	pipesTotal := uint32(0)
	pipesCloseable := uint32(0)
	pipesPendingClose := uint32(0)

	for _, c := range []rune(in.BayanStr) {
		if !opened {
			if c == '[' {
				opened = true
			}
			continue
		}

		if opened && !firstColonSeen {
			if c == ':' {
				firstColonSeen = true
			}
			continue
		}

		if opened && firstColonSeen {
			if c == '|' {
				pipesPendingClose += 1
			} else if c == ':' {
				pipesCloseable += pipesPendingClose
				pipesPendingClose = 0
				closingColonSeen = true
			} else if c == ']' {
				if closingColonSeen {
					closed = true
					pipesTotal = pipesCloseable
				}
			}
		}

	}

	if closed {
		return caseOutput{int32(4 + pipesTotal)}
	}
	return caseOutput{int32(-1)}
}

func solveSequential(scanner *bufio.Scanner, writer *bufio.Writer) {
	writeCaseOutput(writer, solveCase(readCaseInput(scanner)))
}

func main() {
	var scanner *bufio.Scanner
	if len(os.Args) > 1 {
		reader, err := os.Open(os.Args[1])
		if err != nil {
			panic(err)
		}
		defer reader.Close()
		scanner = bufio.NewScanner(reader)
	} else {
		scanner = bufio.NewScanner(os.Stdin)
	}
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 0, 1024*1024), 1024*1024)

	var writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	solveSequential(scanner, writer)
}

func readString(sc *bufio.Scanner) string {
	if !sc.Scan() {
		panic("failed to scan next token")
	}

	return sc.Text()
}

func writef(writer *bufio.Writer, formatStr string, values ...interface{}) {
	out := fmt.Sprintf(formatStr, values...)
	_, err := writer.WriteString(out)
	if err != nil {
		panic(err)
	}
}

// Codeforces 1101 B Accordion train
package main

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

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

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

var n int
var s string
var alen int

type State int
const (
	LeftNone = 0
	OpenBrack = 1
	FirstColon = 2
	VertLine = 3
	SecondColon = 4
	CloseBrack = 5
	RightNone = 6
)

func readData() {
	in = bufio.NewReader(os.Stdin)
	delim := byte('\n')
	ss, err := in.ReadString(delim)
	s = strings.Trim(ss, " \n\r")
	n = len(s)
	// fmt.Println("N=", n)
	if err != nil {
		fmt.Println("read failure", err)
		panic(err)
	}
}

func solve() {
	var inBeg,inEnd,nVert int
	state := LeftNone
	for i := 0; i<n; i++ {
		c := s[i]
		if state==LeftNone && c=='[' {
			state = OpenBrack
		} else if state==OpenBrack && c==':' {
			state = FirstColon
			inBeg = i+1
			break
		}
	}
	state = RightNone
	for i:=n-1; i>=0; i-- {
		c := s[i]
		if state==RightNone && c==']' {
			state = CloseBrack
		} else if state==CloseBrack && c==':' {
			state = SecondColon
			inEnd = i
			break
		}
	}
	// fmt.Println("inBeg,inEnd=", inBeg,inEnd)
	if inEnd <inBeg {
		alen = -1
		return
	}
	for i:=inBeg; i<inEnd; i++ {
		c := s[i]
		if c=='|' {
			nVert++;
		}
	}
	alen = 4 + nVert
}

func printRes() {
	fmt.Println(alen)
}

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

// Codeforces 1101 B Accordion train
package main

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

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

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

var n int
var s string
var alen int

type State int
const (
	LeftNone = 0
	OpenBrack = 1
	FirstColon = 2
	VertLine = 3
	SecondColon = 4
	CloseBrack = 5
	RightNone = 6
)

func readData() {
	in = bufio.NewReader(os.Stdin)
	delim := byte('\n')
	ss, err := in.ReadString(delim)
	s = strings.Trim(ss, " \n\r")
	n = len(s)
	// fmt.Println("N=", n)
	if err != nil {
		fmt.Println("read failure", err)
		panic(err)
	}
}

func solve() {
	var inBeg,inEnd,nVert int
	state := LeftNone
	for i := 0; i<n; i++ {
		c := s[i]
		if state==LeftNone && c=='[' {
			state = OpenBrack
		} else if state==OpenBrack && c==':' {
			state = FirstColon
			inBeg = i+1
			break
		}
	}
	state = RightNone
	for i:=n-1; i>=0; i-- {
		c := s[i]
		if state==RightNone && c==']' {
			state = CloseBrack
		} else if state==CloseBrack && c==':' {
			state = SecondColon
			inEnd = i
			break
		}
	}
	if inEnd <=inBeg {
		alen = -1
		return
	}
	for i:=inBeg; i<inEnd; i++ {
		c := s[i]
		if c=='|' {
			nVert++;
		}
	}
	alen = 4 + nVert
}

func printRes() {
	fmt.Println(alen)
}

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