Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the swamp is very difficult, so people tramped exactly n - 1 paths. Each of these paths connects some pair of settlements and is bidirectional. Moreover, it is possible to reach any settlement from any other one by traversing one or several paths.The distance between two settlements is the minimum number of paths that have to be crossed to get from one settlement to the other one. Manao knows that the Book of Evil has got a damage range d. This means that if the Book of Evil is located in some settlement, its damage (for example, emergence of ghosts and werewolves) affects other settlements at distance d or less from the settlement where the Book resides.Manao has heard of m settlements affected by the Book of Evil. Their numbers are p1, p2, ..., pm. Note that the Book may be affecting other settlements as well, but this has not been detected yet. Manao wants to determine which settlements may contain the Book. Help him with this difficult task.

The first line contains three space-separated integers n, m and d (1 ≤ m ≤ n ≤ 100000; 0 ≤ d ≤ n - 1). The second line contains m distinct space-separated integers p1, p2, ..., pm (1 ≤ pi ≤ n). Then n - 1 lines follow, each line describes a path made in the area. A path is described by a pair of space-separated integers ai and bi representing the ends of this path.

Print a single number — the number of settlements that may contain the Book of Evil. It is possible that Manao received some controversial information and there is no settlement that may contain the Book. In such case, print 0.

NoteSample 1. The damage range of the Book of Evil equals 3 and its effects have been noticed in settlements 1 and 2. Thus, it can be in settlements 3, 4 or 5.

package main

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

var in = bufio.NewScanner(os.Stdin)

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

func main() {
	in.Split(bufio.ScanWords)
	n, m, d := readInt(), readInt(), readInt()
	p := make([]int, m)
	for i := range p {
		p[i] = readInt() - 1
	}
	edges := make([][]int, n)
	for i := 1; i < n; i++ {
		a, b := readInt()-1, readInt()-1
		edges[a] = append(edges[a], b)
		edges[b] = append(edges[b], a)
	}

	bfs := func(root int) []int {
		dist := make([]int, n)
		for i := range dist {
			dist[i] = -1
		}
		dist[root] = 0
		q := []int{root}
		for len(q) > 0 {
			v := q[0]
			q = q[1:]
			for _, u := range edges[v] {
				if dist[u] >= 0 {
					continue
				}
				dist[u] = dist[v] + 1
				q = append(q, u)
			}
		}
		return dist
	}
	dist := bfs(p[0])
	far := p[0]
	for i := range p {
		if dist[p[i]] > dist[far] {
			far = p[i]
		}
	}
	dist1 := bfs(far)

	far1 := p[0]
	for i := range p {
		if dist1[p[i]] > dist1[far1] {
			far1 = p[i]
		}
	}
	dist2 := bfs(far1)

	ans := 0
	for i := range dist {
		if dist1[i] <= d && dist2[i] <= d {
			ans++
		}
	}
	fmt.Println(ans)
}

//http://codeforces.com/problemset/problem/337/d
package main

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

var (
	graph [][]int
)

func initDist(d []int) {
	for i := range d {
		d[i] = int(1e9 + 7)
	}
}

func dfs(start int, d int, dist []int) {
	dist[start] = d

	for i := range graph[start] {
		if dist[graph[start][i]] > d+1 {
			dfs(graph[start][i], d+1, dist)
		}
	}
}

func findFurthestNode(isAffected map[int]bool, dist []int) int {
	max, maxID := 0, 0
	for i := range dist {
		if isAffected[i] && max < dist[i] {
			max = dist[i]
			maxID = i
		}
	}

	return maxID
}

func findMax(n1 int, n2 int) int {
	if n1 > n2 {
		return n1
	}

	return n2
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, m, d, s1, s2, first, second, res int
	fmt.Fscanf(r, "%d %d %d\n", &n, &m, &d)

	isAffected := map[int]bool{}
	for i := 0; i < m; i++ {
		fmt.Fscanf(r, "%d", &s1)
		isAffected[s1] = true
	}
	fmt.Fscanln(r)

	graph = make([][]int, n+1)
	for i := 1; i < n; i++ {
		fmt.Fscanf(r, "%d %d\n", &s1, &s2)
		graph[s1] = append(graph[s1], s2)
		graph[s2] = append(graph[s2], s1)
	}

	dist := make([]int, n+1)
	initDist(dist)
	dfs(1, 0, dist)
	first = findFurthestNode(isAffected, dist)

	//find distance from first to every node
	dist1 := make([]int, n+1)
	dist2 := make([]int, n+1)
	initDist(dist1)
	dfs(first, 0, dist1)

	if m == 1 {
		second = first
		dist2 = dist1
	} else {
		second = findFurthestNode(isAffected, dist1)
		initDist(dist2)
		dfs(second, 0, dist2)
	}

	for i := 1; i <= n; i++ {
		if findMax(dist1[i], dist2[i]) <= d {
			res++
		}
	}

	fmt.Fprintf(os.Stdout, "%d\n", res)
}

package main

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

const max = 10000000
const min = -max

type scanner struct {
	*bufio.Scanner
}

func (s *scanner) nextInt() int {
	s.Scan()
	v, _ := strconv.Atoi(s.Text())
	return v
}

func (s *scanner) nextInt64() int64 {
	s.Scan()
	v, _ := strconv.ParseInt(s.Text(), 10, 64)
	return v
}

type tree struct {
	g       map[int]map[int]bool
	d       map[int]int
	u       map[int]int
	sibling map[int]int
	p       map[int]bool
}

func (t *tree) dfsu(u, parent int) {
	if t.p[parent] {
		t.u[u] = 1
	}

	if sibling, ok := t.sibling[u]; ok && sibling+2 > t.u[u] {
		t.u[u] = t.sibling[u]+2
	}

	if parent, ok := t.u[parent]; ok && parent+1 > t.u[u] {
		t.u[u] = parent+1
	}

	for v := range t.g[u] {
		if v == parent {
			continue
		}
		t.dfsu(v, u)
	}
}

func (t *tree) dfsd(u, parent int) {
	t.d[u]=min
	max1, max2 := min, min
	for v := range t.g[u] {
		if v == parent {
			continue
		}
		t.dfsd(v, u)
		dv := t.d[v]
		if dv > max1 {
			max2, max1 = max1, dv
		} else if dv > max2 {
			max2 = dv
		}
	}

	for v := range t.g[u] {
		if v == parent {
			continue
		}
		dv := t.d[v]
		if dv == max1 {
			t.sibling[v] = max2
		} else {
			t.sibling[v] = max1
		}
	}

	if t.p[u] {
		t.d[u] = 0
	}
	if max1 != min {
		t.d[u] = max1 + 1
	}
}

func (t *tree) bfs(root, deg int) map[int]int {
	var q []int
	var d []int
	v := map[int]int{}
	q = append(q, root)
	d = append(d, 0)
	for len(q) > 0 {
		u := q[0]
		du := d[0]
		q = q[1:]
		d = d[1:]
		if du > deg {
			break
		}
		if _, ok := v[u]; ok {
			continue
		}
		v[u] = du
		// fmt.Print(u, " ")
		for v := range t.g[u] {
			q = append(q, v)
			d = append(d, du+1)
		}
	}
	// fmt.Println()
	return v
}

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

	n, m, d := in.nextInt(), in.nextInt(), in.nextInt()
	_ = d

	p := map[int]bool{}
	g := map[int]map[int]bool{}
	for i := 1; i <= n; i++ {
		g[i] = map[int]bool{}
	}

	for i := 0; i < m; i++ {
		v := in.nextInt()
		p[v] = true
	}

	for i := 1; i < n; i++ {
		u, v := in.nextInt(), in.nextInt()
		g[u][v] = true
		g[v][u] = true
	}

	t := tree{
		g:       g,
		d:       map[int]int{},
		u:       map[int]int{},
		sibling: map[int]int{},
		p:       p,
	}

	// for i := 1; i <= n; i++ {
		// fmt.Print(i, " ")
		// for v := range g[i] {
			// fmt.Print(v, " ")
		// }
		// fmt.Println()
	// }

	// a := t.bfs(9, d)
	// for u, d := range a {
		// fmt.Println("9", u, d)
	// }
	// b := t.bfs(14, d)
	// for u, d := range b {
		// fmt.Println("14", u, d)
	// }
	// c := map[int]int{}
	// for i := 1; i <= n; i++ {
		// if a[i] != 0 && b[i] != 0 {
			// if a[i] > b[i] {
				// c[i] = a[i]
			// } else {
				// c[i] = b[i]
			// }
			// fmt.Print(i, " ")
		// }
	// }
	// fmt.Println()

	t.dfsd(1, -1)
	t.dfsu(1, -1)
	// for u := range c {
		// fmt.Println(u, ":", t.d[u], t.u[u], t.sibling[u], c[u])
	// }
	// fmt.Println(t.d)
	// fmt.Println(t.u)
	// fmt.Println(t.sibling)
	var cnt int
	for i := 1; i <= n; i++ {
		if t.u[i] <= d && t.d[i] <= d {
			// fmt.Println("HIHI", i, t.u[i], t.d[i])
			cnt++
		}
	}
	fmt.Println(cnt)
}

package main

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

var (
    n,m,d int
    marked []bool
    h [][]int
    dd, du []int
)

func main() {
    Scanf("%d %d %d", &n, &m, &d)
    marked = make([]bool, n+1)

    sc := bufio.NewScanner(os.Stdin)
    sc.Split(bufio.ScanWords)

    for i := 0; i < m; i++ {
        sc.Scan()
        v, _ := strconv.Atoi(sc.Text())
        marked[v] = true
    }

    h = make([][]int, n+1)
    for i := 0; i < n+1; i++ {
        h[i] = make([]int, 0, 10)
    }

    for i := 1; i < n; i++ {
        sc.Scan()
        a, _ := strconv.Atoi(sc.Text())
        sc.Scan()
        b, _ := strconv.Atoi(sc.Text())
        h[a] = append(h[a], b)
        h[b] = append(h[b], a)
    }

    dd = make ([]int, n+1)
    du = make ([]int, n+1)
    for i := 0; i < n+1; i++ {
        dd[i] = -1
        du[i] = -1
    }
    if marked[1] {
        du[1] = 0
    }

    dist_down(1, -1)
    dist_up(1, -1)

    sum := 0
    for i := 1; i < n+1; i++ {
        if dd[i] <= d && du[i] <= d {
            sum = sum + 1
        }
    }
    Println(sum)
}

func dist_down(to, from int) (int) {
    if marked[to] {
        dd[to] = 0
    }

    for _, ch := range h[to] {
        if ch != from {
            d := dist_down(ch, to)
            if d != -1 {
    	        if dd[to] < d + 1 {
                    dd[to] = d + 1
                }
            }
        }
    }
    return dd[to]
}

func dist_up(to, from int) {
    max1 := -1
    max2 := -1

    for _, ch := range h[to] {
        if ch != from {
            if dd[ch] > max1 {
    	        max2 = max1
    	        max1 = dd[ch]
            } else if dd[ch] > max2 {
    	        max2 = dd[ch]
            }
        }
    }

    for _, ch := range h[to] {
        if ch != from {
            sibling := max1
            if dd[ch] == max1 {
                sibling = max2
            }

            if sibling != -1 {
                du[ch] = sibling + 2
            }

            if du[to] != -1 {
    	        if du[to] + 1 > du[ch] {
                    du[ch] = du[to] + 1
                }
            }

            if marked[ch] {
    	        if 0 > du[ch] {
                    du[ch] = 0
                }
            }

            dist_up(ch, to)
        }
    }
}

package main

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

const (
    LOW = -123456789
)

func Init() {
}

func Solve(io *FastIO) {
    N := io.NextInt()
    M := io.NextInt()
    D := io.NextInt()
    P := io.NextIntArray(M)

    nodes := make([]*Node, N + 1)
    for i := 1; i <= N; i++ {
        nodes[i] = NewNode()
    }

    for _, u := range P {
        nodes[u].spooky = true
    }

    for i := 1; i < N; i++ {
        U := io.NextInt()
        V := io.NextInt()

        nodes[U].next[nodes[V]] = true
        nodes[V].next[nodes[U]] = true
    }

    Rootify(nodes[1], nil)
    ComputeBests(nodes[1])
    ComputeUps(nodes[1])

    ans := CountGood(nodes[1], D)
    io.Println(ans)
}

func Rootify(u, p *Node) {
    delete(u.next, p)
    for v := range u.next {
        Rootify(v, u)
    }
}

func ComputeBests(u *Node) {
    if u.spooky {
        u.down.Add(0)
    }
    for v := range u.next {
        ComputeBests(v)
        u.down.Add(1 + v.down.Best())
    }
}

func ComputeUps(u *Node) {
    for v := range u.next {
        u.down.Remove(1 + v.down.Best())
        v.up = 1 + Max(u.up, u.down.Best())
        u.down.Add(1 + v.down.Best())
        ComputeUps(v)
    }
}

func CountGood(u *Node, d int) int {
    cnt := 0
    if u.up <= d && u.down.Best() <= d {
        cnt++
    }
    for v := range u.next {
        cnt += CountGood(v, d)
    }
    return cnt
}

type Node struct {
    next map[*Node]bool
    spooky bool
    down *BestTwo
    up int
}

func NewNode() *Node {
    return &Node{
        next: make(map[*Node]bool),
        down: MakeBestTwo(),
        up: LOW,
    }
}

type BestTwo struct {
    best []int
}

func MakeBestTwo() *BestTwo {
    return &BestTwo{
        best: []int{LOW, LOW},
    }
}

func (this *BestTwo) Add(val int) {
    sort.Ints(this.best)
    this.best[0] = Max(this.best[0], val)
}

func (this *BestTwo) Remove(val int) {
    for i, v := range this.best {
        if val == v {
            this.best[i] = LOW
            return
        }
    }
}

func (this *BestTwo) Best() int {
    return Max(this.best...)
}

func Max(args ...int) int {
	max := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] > max {
			max = args[i]
		}
	}
	return max
}

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) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

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)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

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

const (
    LOW = -123456789
)

func Init() {
}

func Solve(io *FastIO) {
    N := io.NextInt()
    M := io.NextInt()
    D := io.NextInt()
    P := io.NextIntArray(M)

    nodes := make([]*Node, N + 1)
    for i := 1; i <= N; i++ {
        nodes[i] = NewNode()
    }

    for _, u := range P {
        nodes[u].spooky = true
    }

    for i := 1; i < N; i++ {
        U := io.NextInt()
        V := io.NextInt()

        nodes[U].next[nodes[V]] = true
        nodes[V].next[nodes[U]] = true
    }

    Rootify(nodes[1], nil)
    ComputeBests(nodes[1])
    ComputeUps(nodes[1])

    // for i := 1; i <= N; i++ {
    //     fmt.Printf("i = %d: %+v, %+v\n", i, nodes[i], nodes[i].down)
    // }

    ans := CountGood(nodes[1], D)
    io.Println(ans)
}

func Rootify(u, p *Node) {
    delete(u.next, p)
    for v := range u.next {
        Rootify(v, u)
    }
}

func ComputeBests(u *Node) {
    if u.spooky {
        u.down.Add(0)
    }
    for v := range u.next {
        ComputeBests(v)
        u.down.Add(1 + v.down.Best())
    }
}

func ComputeUps(u *Node) {
    for v := range u.next {
        u.down.Remove(1 + v.down.Best())
        v.up = 1 + Max(u.up, u.down.Best())
        u.down.Add(1 + v.down.Best())
        ComputeUps(v)
    }
}

func CountGood(u *Node, d int) int {
    cnt := 0
    if u.up <= d && u.down.Best() <= d {
        cnt++
    }
    for v := range u.next {
        cnt += CountGood(v, d)
    }
    return cnt
}

type Node struct {
    next map[*Node]bool
    spooky bool
    down *BestTwo
    up int
}

func NewNode() *Node {
    return &Node{
        next: make(map[*Node]bool),
        down: MakeBestTwo(),
        up: LOW,
    }
}

type BestTwo struct {
    best []int
}

func MakeBestTwo() *BestTwo {
    return &BestTwo{
        best: []int{LOW, LOW},
    }
}

func (this *BestTwo) Add(val int) {
    sort.Ints(this.best)
    this.best[0] = Max(this.best[0], val)
}

func (this *BestTwo) Remove(val int) {
    for i, v := range this.best {
        if val == v {
            this.best[i] = LOW
            return
        }
    }
}

func (this *BestTwo) Best() int {
    return Max(this.best...)
}

func Max(args ...int) int {
	max := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] > max {
			max = args[i]
		}
	}
	return max
}

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) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

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)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

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

var (
	sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
	n, m, d int
	marked  []bool
	kids    [][]int
	mxdown  []int
	mxup    []int
	mxkids  [][]int
)

func nextString() string {
  sc.Scan()
  return sc.Text()
}

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

func calcMxDown(a, par int) int {
	mxdown[a] = -1e9
	if marked[a] {
		mxdown[a] = 0
	}
	for _, b := range kids[a] {
		if b != par {
			mxdown[a] = max(mxdown[a], calcMxDown(b, a)+1)
		}
	}
	return mxdown[a]
}

func calcMxKids(a, par int) {
	var m1, m2 int = -1e9, -1e9
	for _, b := range kids[a] {
		if b != par {
			calcMxKids(b, a)
			if m1 <= mxdown[b] {
				m1, m2 = mxdown[b], m1
			} else if m2 < mxdown[b] {
				m2 = mxdown[b]
			}
		}
	}
	mxkids[a] = []int{m1, m2}
}

func calcMxUp(a, par int) {
	mxup[a] = -1e9
	if marked[a] {
		mxup[a] = 0
	}
	if par != 0 {
		mxup[a] = max(mxup[a], mxup[par]+1)
		if mxdown[a] == mxkids[par][0] {
			mxup[a] = max(mxup[a], mxkids[par][1]+2)
		} else { // <
			mxup[a] = max(mxup[a], mxkids[par][0]+2)
		}
	}
	for _, b := range kids[a] {
		if b != par {
			calcMxUp(b, a)
		}
	}
}

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

func main() {
	sc.Split(bufio.ScanWords)
	n, m, d = nextInt(), nextInt(), nextInt()
	marked = make([]bool, n+1)
	kids = make([][]int, n+1)
	for i := 1; i <= n; i++ {
		kids[i] = make([]int, 0, 10)
	}
	for i := 0; i < m; i++ {
		marked[nextInt()] = true
	}
	for i := 0; i < n-1; i++ {
		a, b := nextInt(), nextInt()
		kids[a] = append(kids[a], b)
		kids[b] = append(kids[b], a)
	}

	mxdown = make([]int, n+1)
	calcMxDown(1, 0)

	mxkids = make([][]int, n+1)
	calcMxKids(1, 0)
	mxup = make([]int, n+1)
	calcMxUp(1, 0)

	ans := 0
	for a := 1; a <= n; a++ {
		//fmt.Println(a, " : ", mxdown[a], " ", mxup[a], " ", mxkids[a])
		if mxdown[a] <= d && mxup[a] <= d {
			ans++
		}
	}
	fmt.Println(ans)
}

package main

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

var (
	sc      *bufio.Scanner = bufio.NewScanner(os.Stdin)
	n, m, d int
	marked  []bool
	kids    [][]int
	mxdown  []int
	mxup    []int
	mxkids  [][]int
)

func nextString() string {
	sc.Scan()
	return sc.Text()
}

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

func calcMxDown(a, par int) int {
	mxdown[a] = -1e9
	if marked[a] {
		mxdown[a] = 0
	}
	for _, b := range kids[a] {
		if b != par {
			mxdown[a] = max(mxdown[a], calcMxDown(b, a)+1)
		}
	}
	return mxdown[a]
}

func calcMxKids(a, par int) {
	var m1, m2 int = -1e9, -1e9
	for _, b := range kids[a] {
		if b != par {
			calcMxKids(b, a)
			if m1 <= mxdown[b] {
				m1, m2 = mxdown[b], m1
			} else if m2 < mxdown[b] {
				m2 = mxdown[b]
			}
		}
	}
	mxkids[a] = []int{m1, m2}
}

func calcMxUp(a, par int) {
	mxup[a] = -1e9
	if marked[a] {
		mxup[a] = 0
	}
	if par != 0 {
		mxup[a] = max(mxup[a], mxup[par]+1)
		if mxdown[a] == mxkids[par][0] {
			mxup[a] = max(mxup[a], mxkids[par][1]+2)
		} else { // <
			mxup[a] = max(mxup[a], mxkids[par][0]+2)
		}
	}
	for _, b := range kids[a] {
		if b != par {
			calcMxUp(b, a)
		}
	}
}

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

func main() {
	sc.Split(bufio.ScanWords)
	n, m, d = nextInt(), nextInt(), nextInt()
	marked = make([]bool, n+1)
	kids = make([][]int, n+1)
	for i := 1; i <= n; i++ {
		kids[i] = make([]int, 0, 10)
	}
	for i := 0; i < m; i++ {
		marked[nextInt()] = true
	}
	for i := 0; i < n-1; i++ {
		a, b := nextInt(), nextInt()
		kids[a] = append(kids[a], b)
		kids[b] = append(kids[b], a)
	}

	mxdown = make([]int, n+1)
	calcMxDown(1, 0)

	mxkids = make([][]int, n+1)
	calcMxKids(1, 0)
	mxup = make([]int, n+1)
	calcMxUp(1, 0)

	ans := 0
	for a := 1; a <= n; a++ {
		if mxdown[a] <= d && mxup[a] <= d {
			ans++
		}
	}
	fmt.Println(ans)
}

package main

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

var in = bufio.NewScanner(os.Stdin)

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

func main() {
	in.Split(bufio.ScanWords)
	n, m, d := readInt(), readInt(), readInt()
	p := make([]int, m)
	for i := range p {
		p[i] = readInt() - 1
	}
	edges := make([][]int, n)
	for i := 1; i < n; i++ {
		a, b := readInt()-1, readInt()-1
		edges[a] = append(edges[a], b)
		edges[b] = append(edges[b], a)
	}

	bfs := func(root int) []int {
		dist := make([]int, n)
		for i := range dist {
			dist[i] = -1
		}
		dist[root] = 0
		q := []int{root}
		for len(q) > 0 {
			v := q[0]
			q = q[1:]
			for _, u := range edges[v] {
				if dist[u] >= 0 {
					continue
				}
				dist[u] = dist[v] + 1
				q = append(q, u)
			}
		}
		return dist
	}
	dist := bfs(p[0])
	far := p[0]
	for i := range p {
		if dist[p[i]] > dist[far] {
			far = p[i]
		}
	}
	dist2 := bfs(far)
	ans := 0
	for i := range dist {
		if dist[i] <= d && dist2[i] <= d {
			ans++
		}
	}
	fmt.Println(ans)
}

package main

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

const max = 10000000
const min = -max

type scanner struct {
	*bufio.Scanner
}

func (s *scanner) nextInt() int {
	s.Scan()
	v, _ := strconv.Atoi(s.Text())
	return v
}

func (s *scanner) nextInt64() int64 {
	s.Scan()
	v, _ := strconv.ParseInt(s.Text(), 10, 64)
	return v
}

type tree struct {
	g       map[int]map[int]bool
	d       map[int]int
	u       map[int]int
	sibling map[int]int
	p       map[int]bool
}

func (t *tree) dfsu(u, parent int) {
	if t.p[parent] {
		t.u[u] = 1
	}

		if sibling, ok := t.sibling[u]; ok && sibling+2 > t.u[u] {
			t.u[u] = t.sibling[u]+2
		}

		if parent, ok := t.u[parent]; ok && parent+1 > t.u[u] {
			t.u[u] = parent+1
		}

	for v := range t.g[u] {
		if v == parent {
			continue
		}
		t.dfsu(v, u)
	}
}

func (t *tree) dfsd(u, parent int) {
	t.d[u]=min
	max1, max2 := min, min
	for v := range t.g[u] {
		if v == parent {
			continue
		}
		t.dfsd(v, u)
		dv := t.d[v]
		if dv > max1 {
			max2, max1 = max1, dv
		} else if dv > max2 {
			max2 = dv
		}
	}

	for v := range t.g[u] {
		if v == parent {
			continue
		}
		dv := t.d[v]
		if dv == max1 {
			t.sibling[v] = max2
		} else {
			t.sibling[v] = max1
		}
	}

	if t.p[u] {
		t.d[u] = 0
	} else if max1 != min {
		t.d[u] = max1 + 1
	}

	// if u == 24 {
		// fmt.Println("HI:", t.d[u], t.p[u], max1)
	// }
}

func (t *tree) bfs(root, deg int) map[int]int {
	var q []int
	var d []int
	v := map[int]int{}
	q = append(q, root)
	d = append(d, 0)
	for len(q) > 0 {
		u := q[0]
		du := d[0]
		q = q[1:]
		d = d[1:]
		if du > deg {
			break
		}
		if _, ok := v[u]; ok {
			continue
		}
		v[u] = du
		// fmt.Print(u, " ")
		for v := range t.g[u] {
			q = append(q, v)
			d = append(d, du+1)
		}
	}
	// fmt.Println()
	return v
}

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

	n, m, d := in.nextInt(), in.nextInt(), in.nextInt()
	_ = d

	p := map[int]bool{}
	g := map[int]map[int]bool{}
	for i := 1; i <= n; i++ {
		g[i] = map[int]bool{}
	}

	for i := 0; i < m; i++ {
		v := in.nextInt()
		p[v] = true
	}

	for i := 1; i < n; i++ {
		u, v := in.nextInt(), in.nextInt()
		g[u][v] = true
		g[v][u] = true
	}

	t := tree{
		g:       g,
		d:       map[int]int{},
		u:       map[int]int{},
		sibling: map[int]int{},
		p:       p,
	}

	// for i := 1; i <= n; i++ {
		// fmt.Print(i, " ")
		// for v := range g[i] {
			// fmt.Print(v, " ")
		// }
		// fmt.Println()
	// }

	// a := t.bfs(9, d)
	// for u, d := range a {
		// fmt.Println("9", u, d)
	// }
	// b := t.bfs(14, d)
	// for u, d := range b {
		// fmt.Println("14", u, d)
	// }
	// c := map[int]int{}
	// for i := 1; i <= n; i++ {
		// if a[i] != 0 && b[i] != 0 {
			// if a[i] > b[i] {
				// c[i] = a[i]
			// } else {
				// c[i] = b[i]
			// }
			// fmt.Print(i, " ")
		// }
	// }
	// fmt.Println()

	t.dfsd(1, -1)
	t.dfsu(1, -1)
	// for u := range c {
		// fmt.Println(u, ":", t.d[u], t.u[u], t.sibling[u], c[u])
	// }
	// fmt.Println(t.d)
	// fmt.Println(t.u)
	// fmt.Println(t.sibling)
	var cnt int
	for i := 1; i <= n; i++ {
		if t.u[i] <= d && t.d[i] <= d {
			// fmt.Println("HIHI", i, t.u[i], t.d[i])
			cnt++
		}
	}
	fmt.Println(cnt)
}

package main

import "container/list"
import "fmt"
import "strconv"
import "bufio"
import "os"

var (
    n,m,d int
    marked []bool
    h []*list.List
    dd, du []int
)

func main() {
    fmt.Scanf("%d %d %d", &n, &m, &d)
    marked = make([]bool, n+1)

    sc := bufio.NewScanner(os.Stdin)
    sc.Split(bufio.ScanWords)

    for i := 0; i < m; i++ {
        sc.Scan()
        v,_ := strconv.Atoi(sc.Text())
        marked[v] = true
    }

    h = make([]*list.List, n+1)

    for i := 0; i < n+1; i++ {
        h[i] = list.New()
    }

    for i := 1; i < n; i++ {
        var a, b int
        fmt.Scanf("%d %d", &a, &b)
        h[a].PushBack(b)
        h[b].PushBack(a)
    }

    dd = make ([]int, n+1)
    du = make ([]int, n+1)
    for i := 0; i < n+1; i++ {
        dd[i] = -1
        du[i] = -1
    }
    if marked[1] {
        du[1] = 0
    }

    dist_down(1, -1)
    dist_up(1, -1)

    sum := 0
    for i := 1; i < n+1; i++ {
        if dd[i] <= d && du[i] <= d {
            sum = sum + 1
        }
    }
    fmt.Println(sum)
}

func dist_down(to, from int) (int) {
    if marked[to] {
        dd[to] = 0
    }

    child := h[to].Front()
    for child != nil {
        ch := child.Value.(int)

        if ch != from {
            d := dist_down(ch, to)
            if d != -1 {
    	        if dd[to] < d + 1 {
                    dd[to] = d + 1
                }
            }
        }
        child = child.Next()
    }
    return dd[to]
}

func dist_up(to, from int) {
    max1 := -1
    max2 := -1

    child := h[to].Front()
    for child != nil {
        ch := child.Value.(int)
        if ch != from {
            if dd[ch] > max1 {
    	        max2 = max1
    	        max1 = dd[ch]
            } else if dd[ch] > max2 {
    	        max2 = dd[ch]
            }
        }
        child = child.Next()
    }

    child = h[to].Front()
    for child != nil {
        ch := child.Value.(int)
        if ch != from {
            sibling := max1
            if dd[ch] == max1 {
                sibling = max2
            }

            if sibling != -1 {
                du[ch] = sibling + 2
            }

            if du[to] != -1 {
    	        if du[to] + 1 > du[ch] {
                    du[ch] = du[to] + 1
                }
            }

            if marked[ch] {
    	        if 0 > du[ch] {
                    du[ch] = 0
                }
            }

            dist_up(ch, to)
        }
        child = child.Next()
    }
}

package main

import (
	"fmt"
	"os"
)

var (
	n, m, d int
	marked  []bool
	kids    [][]int
	mxdown  []int
	mxup    []int
	mxkids  [][]int
)

func init() {
	_ = os.Open
	//os.Stdin, _ = os.Open("337D.in")
}

func calcMxDown(a, par int) int {
	mxdown[a] = -1e9
	if marked[a] {
		mxdown[a] = 0
	}
	for _, b := range kids[a] {
		if b != par {
			kidVal := calcMxDown(b, a)
			if mxdown[a] < kidVal+1 {
				mxdown[a] = kidVal + 1
			}
		}
	}
	return mxdown[a]
}

func calcMxKids(a, par int) {
	var m1, m2 int = -1e9, -1e9
	for _, b := range kids[a] {
		if b != par {
			calcMxKids(b, a)
			if m1 <= mxdown[b] {
				m1, m2 = mxdown[b], m1
			} else if m2 < mxdown[b] {
				m2 = mxdown[b]
			}
		}
	}
	mxkids[a] = []int{m1, m2}
}

func calcMxUp(a, par int) {
	mxup[a] = -1e9
	if marked[a] {
		mxup[a] = 0
	}
	if par != 0 {
		mxup[a] = mxup[par] + 1
		if mxdown[a] == mxkids[par][0] {
			mxup[a] = max(mxup[a], mxkids[par][1]+2)
		} else { // <
			mxup[a] = max(mxup[a], mxkids[par][0]+2)
		}
	}
	for _, b := range kids[a] {
		if b != par {
			calcMxUp(b, a)
		}
	}
}

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

func main() {
	fmt.Scan(&n, &m, &d)
	marked = make([]bool, n+1)
	kids = make([][]int, n+1)
	for i := 1; i <= n; i++ {
		kids[i] = make([]int, 0, 10)
	}
	for i := 0; i < m; i++ {
		var v int
		fmt.Scan(&v)
		marked[v] = true
	}
	for i := 0; i < n-1; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		kids[a] = append(kids[a], b)
		kids[b] = append(kids[b], a)
	}

	mxdown = make([]int, n+1)
	calcMxDown(1, 0)

	mxkids = make([][]int, n+1)
	calcMxKids(1, 0)
	mxup = make([]int, n+1)
	calcMxUp(1, 0)

	ans := 0
	for a := 1; a <= n; a++ {
		//fmt.Println(a, " : ", mxdown[a], " ", mxup[a], " ", mxkids[a])
		if mxdown[a] <= d && mxup[a] <= d {
			ans++
		}
	}
	fmt.Println(ans)
}


Greg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game:  The game consists of n steps.  On the i-th step Greg removes vertex number xi from the graph. As Greg removes a vertex, he also removes all the edges that go in and out of this vertex.  Before executing each step, Greg wants to know the sum of lengths of the shortest paths between all pairs of the remaining vertices. The shortest path can go through any remaining vertex. In other words, if we assume that d(i, v, u) is the shortest path between vertices v and u in the graph that formed before deleting vertex xi, then Greg wants to know the value of the following sum: . Help Greg, print the value of the required sum before each step.

The first line contains integer n (1 ≤ n ≤ 500) — the number of vertices in the graph. Next n lines contain n integers each — the graph adjacency matrix: the j-th number in the i-th line aij (1 ≤ aij ≤ 105, aii = 0) represents the weight of the edge that goes from vertex i to vertex j. The next line contains n distinct integers: x1, x2, ..., xn (1 ≤ xi ≤ n) — the vertices that Greg deletes.

Print n integers — the i-th number equals the required sum before the i-th step. Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams of the %I64d specifier.

package main

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

const (
	Inf = int64(1e15)
)

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

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

	w := make2D(n, 0)
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			fmt.Fscanf(r, "%d", &w[i][j])
		}
		fmt.Fscanf(r, "\n")
	}

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

	var ans []int64
	var in []int
	d := make2D(n, Inf)
	for _, k := range vs {
		tot := int64(0)

		d[k][k] = 0
		for _, i := range in {
			for _, j := range in {
				d[k][i] = min(d[k][i], w[k][j]+d[j][i])
				d[i][k] = min(d[i][k], d[i][j]+w[j][k])
			}
			tot += d[i][k] + d[k][i]
		}
		for _, i := range in {
			for _, j := range in {
				d[i][j] = min(d[i][j], d[i][k]+d[k][j])
				tot += d[i][j]
			}
		}

		ans = append(ans, tot)
		in = append(in, k)
	}

	for i := n - 1; i >= 0; i-- {
		fmt.Printf("%d ", ans[i])
	}
	fmt.Println("")
}

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

func make2D(n int, val int64) [][]int64 {
	a := make([][]int64, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int64, n)
		for j := 0; j < n; j++ {
			a[i][j] = val
		}
	}
	return a
}

package main

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

const (
	Inf = int64(1e15)
)

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

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

	w := make2D(n, 0)
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			fmt.Fscanf(r, "%d", &w[i][j])
		}
		fmt.Fscanf(r, "\n")
	}

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

	var ans []int64
	var in []int
	d := make2D(n, Inf)
	for _, k := range vs {
		tot := int64(0)

		d[k][k] = 0
		for _, i := range in {
			for _, j := range in {
				d[k][i] = min(d[k][i], w[k][i]+d[i][j])
				d[i][k] = min(d[i][k], d[i][j]+w[j][k])
			}
			tot += d[i][k] + d[k][i]
		}
		for _, i := range in {
			for _, j := range in {
				d[i][j] = min(d[i][j], d[i][k]+d[k][j])
				tot += d[i][j]
			}
		}

		ans = append(ans, tot)
		in = append(in, k)
	}

	for i := n - 1; i >= 0; i-- {
		fmt.Printf("%d ", ans[i])
	}
	fmt.Println("")
}

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

func make2D(n int, val int64) [][]int64 {
	a := make([][]int64, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int64, n)
		for j := 0; j < n; j++ {
			a[i][j] = val
		}
	}
	return a
}


Homer has two friends Alice and Bob. Both of them are string fans. One day, Alice and Bob decide to play a game on a string $$$s = s_1 s_2 \dots s_n$$$ of length $$$n$$$ consisting of lowercase English letters. They move in turns alternatively and Alice makes the first move.In a move, a player must choose an index $$$i$$$ ($$$1 \leq i \leq n$$$) that has not been chosen before, and change $$$s_i$$$ to any other lowercase English letter $$$c$$$ that $$$c \neq s_i$$$.When all indices have been chosen, the game ends. The goal of Alice is to make the final string lexicographically as small as possible, while the goal of Bob is to make the final string lexicographically as large as possible. Both of them are game experts, so they always play games optimally. Homer is not a game expert, so he wonders what the final string will be.A string $$$a$$$ is lexicographically smaller than a string $$$b$$$ if and only if one of the following holds:   $$$a$$$ is a prefix of $$$b$$$, but $$$a \ne b$$$;  in the first position where $$$a$$$ and $$$b$$$ differ, the string $$$a$$$ has a letter that appears earlier in the alphabet than the corresponding letter in $$$b$$$.

Each test contains multiple test cases. The first line contains $$$t$$$ ($$$1 \le t \le 1000$$$)  — the number of test cases. Description of the test cases follows. The only line of each test case contains a single string $$$s$$$ ($$$1 \leq |s| \leq 50$$$) consisting of lowercase English letters.

For each test case, print the final string in a single line.

NoteIn the first test case: Alice makes the first move and must change the only letter to a different one, so she changes it to 'b'.In the second test case: Alice changes the first letter to 'a', then Bob changes the second letter to 'z', Alice changes the third letter to 'a' and then Bob changes the fourth letter to 'z'.In the third test case: Alice changes the first letter to 'b', and then Bob changes the second letter to 'y'.

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


Guy-Manuel and Thomas have an array $$$a$$$ of $$$n$$$ integers [$$$a_1, a_2, \dots, a_n$$$]. In one step they can add $$$1$$$ to any element of the array. Formally, in one step they can choose any integer index $$$i$$$ ($$$1 \le i \le n$$$) and do $$$a_i := a_i + 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 $$$a_1 + a_2 +$$$ $$$\dots$$$ $$$+ a_n \ne 0$$$ and $$$a_1 \cdot a_2 \cdot$$$ $$$\dots$$$ $$$\cdot a_n \ne 0$$$.

Each test contains multiple test cases.  The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^3$$$). The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 100$$$) — the size of the array. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-100 \le a_i \le 100$$$) — elements of the array .

NoteIn 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"
)

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


The developers of Looksery have to write an efficient algorithm that detects faces on a picture. Unfortunately, they are currently busy preparing a contest for you, so you will have to do it for them. In this problem an image is a rectangular table that consists of lowercase Latin letters. A face on the image is a 2 × 2 square, such that from the four letters of this square you can make word "face". You need to write a program that determines the number of faces on the image. The squares that correspond to the faces can overlap.

The first line contains two space-separated integers, n and m (1 ≤ n, m ≤ 50) — the height and the width of the image, respectively. Next n lines define the image. Each line contains m lowercase Latin letters.

In the single line print the number of faces on the image.

NoteIn the first sample the image contains a single face, located in a square with the upper left corner at the second line and the second column:   In the second sample the image also contains exactly one face, its upper left corner is at the second row and the first column.In the third sample two faces are shown:   In the fourth sample the image has no faces on it.

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


This is the easy version of the problem. The only difference is that here $$$k=2$$$. You can make hacks only if both the versions of the problem are solved.This is an interactive problem.Every decimal number has a base $$$k$$$ equivalent. The individual digits of a base $$$k$$$ number are called $$$k$$$-its. Let's define the $$$k$$$-itwise XOR of two $$$k$$$-its $$$a$$$ and $$$b$$$ as $$$(a + b)\bmod k$$$.The $$$k$$$-itwise XOR of two base $$$k$$$ numbers is equal to the new number formed by taking the $$$k$$$-itwise XOR of their corresponding $$$k$$$-its. The $$$k$$$-itwise XOR of two decimal numbers $$$a$$$ and $$$b$$$ is denoted by $$$a\oplus_{k} b$$$ and is equal to the decimal representation of the $$$k$$$-itwise XOR of the base $$$k$$$ representations of $$$a$$$ and $$$b$$$. All further numbers used in the statement below are in decimal unless specified. When $$$k = 2$$$ (it is always true in this version), the $$$k$$$-itwise XOR is the same as the bitwise XOR.You have hacked the criminal database of Rockport Police Department (RPD), also known as the Rap Sheet. But in order to access it, you require a password. You don't know it, but you are quite sure that it lies between $$$0$$$ and $$$n-1$$$ inclusive. So, you have decided to guess it. Luckily, you can try at most $$$n$$$ times without being blocked by the system. But the system is adaptive. Each time you make an incorrect guess, it changes the password. Specifically, if the password before the guess was $$$x$$$, and you guess a different number $$$y$$$, then the system changes the password to a number $$$z$$$ such that $$$x\oplus_{k} z=y$$$. Guess the password and break into the system.

The first line of input contains a single integer $$$t$$$ ($$$1\leq t\leq 10\,000$$$) denoting the number of test cases. $$$t$$$ test cases follow. The first line of each test case contains two integers $$$n$$$ ($$$1\leq n\leq 2\cdot 10^5$$$) and $$$k$$$ ($$$k=2$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot 10^5$$$.

NoteIn the example test case, the hidden password is $$$2$$$.The first query is $$$3$$$. It is not equal to the current password. So, $$$0$$$ is returned, and the password is changed to $$$1$$$ since $$$2\oplus_2 1=3$$$.The second query is $$$4$$$. It is not equal to the current password. So, $$$0$$$ is returned, and the password is changed to $$$5$$$ since $$$1\oplus_2 5=4$$$.The third query is $$$5$$$. It is equal to the current password. So, $$$1$$$ is returned, and the job is done.Note that this initial password is taken just for the sake of explanation. When you submit, the interactor might behave differently because it is adaptive.

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


You are given a binary string $$$s$$$ (recall that a string is binary if each character is either $$$0$$$ or $$$1$$$).Let $$$f(t)$$$ be the decimal representation of integer $$$t$$$ written in binary form (possibly with leading zeroes). For example $$$f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$$$ and $$$f(000100) = 4$$$.The substring $$$s_{l}, s_{l+1}, \dots , s_{r}$$$ is good if $$$r - l + 1 = f(s_l \dots s_r)$$$.For example string $$$s = 1011$$$ has $$$5$$$ good substrings: $$$s_1 \dots s_1 = 1$$$, $$$s_3 \dots s_3 = 1$$$, $$$s_4 \dots s_4 = 1$$$, $$$s_1 \dots s_2 = 10$$$ and $$$s_2 \dots s_4 = 011$$$. Your task is to calculate the number of good substrings of string $$$s$$$.You have to answer $$$t$$$ independent queries.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of queries. The only line of each query contains string $$$s$$$ ($$$1 \le |s| \le 2 \cdot 10^5$$$), consisting of only digits $$$0$$$ and $$$1$$$. It is guaranteed that $$$\sum\limits_{i=1}^{t} |s_i| \le 2 \cdot 10^5$$$.

For each query print one integer — the number of good substrings of string $$$s$$$.

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


Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. . Mike wants to change his sequence in order to make it beautiful. In one move he can choose an index i (1 ≤ i < n), delete numbers ai, ai + 1 and put numbers ai - ai + 1, ai + ai + 1 in their place instead, in this order. He wants perform as few operations as possible. Find the minimal number of operations to make sequence A beautiful if it's possible, or tell him that it is impossible to do so. is the biggest non-negative number d such that d divides bi for every i (1 ≤ i ≤ n).

The first line contains a single integer n (2 ≤ n ≤ 100 000) — length of sequence A. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — elements of sequence A.

Output on the first line "YES" (without quotes) if it is possible to make sequence A beautiful by performing operations described above, and "NO" (without quotes) otherwise. If the answer was "YES", output the minimal number of moves needed to make sequence A beautiful.

NoteIn the first example you can simply make one move to obtain sequence [0, 2] with .In the second example the gcd of the sequence is already greater than 1.

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