package main

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

var v [][]int

func DFS(node int, flag *[]int) (int, int){
  (*flag)[node] = 1
  nodes := 1
  edges := 0
  for i := 0; i < len(v[node]); i++ {
    next := v[node][i]
    if (*flag)[next] == 0 {
      nn, ne := DFS(next, flag)
      nodes += nn
      edges += ne
    }
    edges++
  }
  return nodes, edges
}

func main() {
  var n, m, k int
  in := bufio.NewReader(os.Stdin)
  fmt.Fscan(in, &n, &m, &k)
  govs := make([]int, k)
  for i := 0; i < k; i++ {
    fmt.Fscan(in, &govs[i])
    govs[i]--
  }
  v = make([][]int, n)
  for i := 0; i < m; i++ {
    var from, to int
    fmt.Fscan(in, &from, &to)
    from--
    to--
    v[from] = append(v[from], to)
    v[to] = append(v[to], from)
  }
  ans := 0
  maxnode := 0
  left := n
  lefte := m
  for i := 0; i < k; i++ {
    flag := make([]int, n)
    nodes, edges := DFS(govs[i], &flag)
    if nodes > maxnode {
      maxnode = nodes
    }
    lefte -= edges / 2
    left -= nodes
    ans += (nodes * (nodes - 1) - edges) / 2
  }
  ans += (left * (left - 1)) / 2 - lefte
  ans += left * maxnode
  fmt.Println(ans)
}

package main

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

type component struct {
	nodes, edges int
}

var n, m, k int
var graph [][]int
var specials map[int]bool
var used []bool
var components []component

func bfs(v int) component {
	nodes := 0
	edges := 0
	q := []int{v}
	used[v] = true

	for len(q) > 0 {
		nodes++
		t := q[0]
		q = q[1:]
		for _, vnext := range graph[t] {
			edges++
			if !used[vnext] {
				q = append(q, vnext)
				used[vnext] = true
			}
		}
	}

	return component{
		nodes: nodes,
		edges: edges / 2,
	}
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d %d\n", &n, &m, &k)
	specials = make(map[int]bool)
	graph = make([][]int, n + 1)
	used = make([]bool, n + 1)
	components = make([]component, n + 1)
	for i := 0; i < k; i++ {
		var tmp int
		fmt.Fscanf(buf, "%d", &tmp)
		specials[tmp] = true
	}
	fmt.Fscanf(buf, "\n")
	for i := 0; i < m; i++ {
		var v1, v2 int
		fmt.Fscanf(buf, "%d %d\n", &v1, &v2)
		graph[v1] = append(graph[v1], v2)
		graph[v2] = append(graph[v2], v1)
	}

	maxNodesInComponent := 0
	componentSpecial := 0
	ans := 0
	for v, _ := range specials {
		components[v] = bfs(v)
		if components[v].nodes > maxNodesInComponent {
			maxNodesInComponent = components[v].nodes
			componentSpecial = v
		}
		ans += components[v].nodes * (components[v].nodes - 1) / 2 - components[v].edges
	}

	for i := 1; i <= n; i++ {
		if !specials[i] && !used[i] {
			c := bfs(i)
			ans += c.nodes * (c.nodes - 1) / 2 - c.edges
			ans += c.nodes * components[componentSpecial].nodes
			components[componentSpecial].nodes += c.nodes
		}
	}
	fmt.Println(ans)
}

package main

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

func solve() {
    n, m, k := readInt(), readInt(), readInt()
    c := readIntArray(k)
    a := make([][]int, n)
    for i := 0; i < m; i++ {
        u, v := readInt()-1, readInt()-1
        a[u] = append(a[u], v)
        a[v] = append(a[v], u)
    }

    was := make([]bool, n)
    govs := make([][]int, n)
    mxGov, mxCnt := 0, 0
    for _, gov := range c {
        gov--
        q := []int{gov}
        was[gov] = true
        for len(q) > 0 {
            cur := q[0]
            q, govs[gov] = q[1:], append(govs[gov], cur)
            for _, v := range a[cur] {
                if !was[v] {
                    was[v] = true
                    q = append(q, v)
                }
            }
        }
        if ln := len(govs[gov]); ln > mxCnt {
            mxCnt = ln
            mxGov = gov
        }
    }

    free := []int{}
    for v, b := range was {
        if !b {
            free = append(free, v)
        }
    }

    ans := 0
    for gov, l := range govs {
        if gov == mxGov {
            l = append(l, free...)
        }

        has := 0
        for _, v := range l {
            has += len(a[v])
        }
        has /= 2

        cnt := len(l)
        ans += cnt*(cnt-1)/2 - has
    }
    fmt.Println(ans)
}

// Helpers

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math

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

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

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

// IO

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

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

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

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

// Sort

type Ints64 []int64

func (a Ints64) Len() int           { return len(a) }
func (a Ints64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Ints64) Less(i, j int) bool { return a[i] < a[j] }

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

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

func solve() {
    n, m, k := readInt(), readInt(), readInt()
    c := readIntArray(k)
    a := make([][]int, n)
    for i := 0; i < m; i++ {
        u, v := readInt()-1, readInt()-1
        a[u] = append(a[u], v)
        a[v] = append(a[v], u)
    }

    was := make([]bool, n)
    govs := make([][]int, n)
    mxGov, mxCnt := 0, 0
    for _, gov := range c {
        gov--
        q := []int{gov}
        was[gov] = true
        for len(q) > 0 {
            cur := q[0]
            q, govs[gov] = q[1:], append(govs[gov], cur)
            for _, v := range a[cur] {
                if !was[v] {
                    was[v] = true
                    q = append(q, v)
                }
            }
        }
        if ln := len(govs[gov]); ln > mxCnt {
            mxCnt = ln
            mxGov = gov
        }
    }

    free := 0
    for _, b := range was {
        if !b {
            free++
        }
    }

    ans := 0
    for gov, l := range govs {
        cnt := len(l)
        if gov == mxGov {
            cnt += free
        }

        has := 0
        for _, v := range l {
            has += len(a[v])
        }
        has /= 2

        ans += cnt*(cnt-1) / 2 - has
    }
    fmt.Println(ans)
}

// Helpers

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math

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

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

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

// IO

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

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

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

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

// Sort

type Ints64 []int64

func (a Ints64) Len() int           { return len(a) }
func (a Ints64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Ints64) Less(i, j int) bool { return a[i] < a[j] }

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

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

func DFS(node int, flag *[]int, v *[][]int) (int, int){
  (*flag)[node] = 1
  nodes := 1
  edges := 0
  for i := 0; i < len((*v)[node]); i++ {
    next := (*v)[node][i]
    if (*flag)[next] == 0 {
      nn, ne := DFS(next, flag, v)
      nodes += nn
      edges += ne
    }
    edges++
  }
  return nodes, edges
}

func main() {
  var n, m, k int
  in := bufio.NewReader(os.Stdin)
  fmt.Fscan(in, &n, &m, &k)
  govs := make([]int, k)
  for i := 0; i < k; i++ {
    fmt.Fscan(in, &govs[i])
    govs[i]--
  }
  v := make([][]int, n)
  for i := 0; i < m; i++ {
    var from, to int
    fmt.Fscan(in, &from, &to)
    from--
    to--
    v[from] = append(v[from], to)
    v[to] = append(v[to], from)
  }
  ans := 0
  maxnode := 0
  left := n
  for i := 0; i < k; i++ {
    flag := make([]int, n)
    nodes, edges := DFS(govs[i], &flag, &v)
    if nodes > maxnode {
      maxnode = nodes
    }
    left -= nodes
    ans += (nodes * (nodes - 1) - edges) / 2
  }
  ans += (left * (left - 1)) / 2
  ans += left * maxnode
  fmt.Println(ans)
}

package main

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

type component struct {
	nodes, edges int
}

var n, m, k int
var graph [][]int
var specials map[int]bool
var used []bool
var components []component

func bfs(v int) component {
	nodes := 0
	edges := 0
	q := []int{v}
	used[v] = true

	for len(q) > 0 {
		nodes++
		t := q[0]
		q = q[1:]
		for _, vnext := range graph[t] {
			edges++
			if !used[vnext] {
				q = append(q, vnext)
				used[vnext] = true
			}
		}
	}

	return component{
		nodes: nodes,
		edges: edges / 2,
	}
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d %d\n", &n, &m, &k)
	specials = make(map[int]bool)
	graph = make([][]int, n + 1)
	used = make([]bool, n + 1)
	components = make([]component, n + 1)
	for i := 0; i < k; i++ {
		var tmp int
		fmt.Fscanf(buf, "%d", &tmp)
		specials[tmp] = true
	}
	fmt.Fscanf(buf, "\n")
	for i := 0; i < m; i++ {
		var v1, v2 int
		fmt.Fscanf(buf, "%d %d\n", &v1, &v2)
		graph[v1] = append(graph[v1], v2)
		graph[v2] = append(graph[v2], v1)
	}

	maxNodesInComponent := 0
	componentSpecial := 0
	ans := 0
	for v, _ := range specials {
		components[v] = bfs(v)
		if components[v].nodes > maxNodesInComponent {
			maxNodesInComponent = components[v].nodes
			componentSpecial = v
		}
		ans += components[v].nodes * (components[v].nodes - 1) / 2 - components[v].edges
	}

	for i := 1; i <= n; i++ {
		if !specials[i] && !used[i] {
			c := bfs(i)
			ans += c.nodes * (c.nodes - 1) / 2 - c.edges
			ans += c.nodes * components[componentSpecial].nodes
		}
	}
	fmt.Println(ans)
}


package main

import (
	"fmt"
)

func check(x, y, p, q, total int64) bool{
	pp := total / q * p
	return x <= pp && total - y >= pp - x
}

func main ()  {
	var x, y, p, q int64
	var t int
	fmt.Scan(&t)
	for idx := 0; idx < t; idx++{
		var ans int64 = -1
		fmt.Scan(&x, &y, &p, &q)
		if x * q == y * p {
			fmt.Println(0)
			continue
		}
		var l , r int64
		l = 0
		r = 4223372036854775800
		for ; ; {
			if l == r{
				break;
			}
			tmp := (l + r ) / 2
			mid := tmp - tmp % q
			//fmt.Println(l, r, mid, tmp)
			if mid < l{
				l = tmp + 1
				continue
			}
			if check(x, y, p, q, mid){
				ans = mid
				r = mid - 1
			}else{
				l = mid + 1
			}
		}
		if ans >= 0{
			fmt.Println(ans - y)
		}else {
			fmt.Println(-1)
		}
	}
}

package main

import "fmt"

var t int
var x, y, p, q int64
var ansa, ansb, ansc int64

func main() {
	fmt.Scan(&t)
	for t > 0 {
		t--
		fmt.Scan(&x)
		fmt.Scan(&y)
		fmt.Scan(&p)
		fmt.Scan(&q)
		y -= x
		q -= p
		if p == 0 {
			if x != 0 {
				goto fail
			} else {
				goto success
			}
		}
		if q == 0 {
			if y != 0 {
				goto fail
			} else {
				goto success
			}
		}

		ansa = x / p
		if x%p != 0 {
			ansa++
		}
		ansb = y / q
		if y%q != 0 {
			ansb++
		}

		if ansa > ansb {
			ansc = ansa
		} else {
			ansc = ansb
		}

		fmt.Println(ansc*p - x + ansc*q - y)
		continue
	fail:
		fmt.Println("-1")
		continue
	success:
		fmt.Println("0")
		continue
	}
}

package main

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

var in = bufio.NewScanner(os.Stdin)

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

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

	for t := readInt(); t > 0; t-- {
		x := readInt()
		y := readInt()
		p := readInt()
		q := readInt()
		if p == 0 && x > 0 || p == q && x != y {
			fmt.Fprintln(out, -1)
			continue
		}
		fmt.Fprintln(out, -y+q*int64(sort.Search(1e9, func(kk int) bool {
			k := int64(kk)
			if k*q < y {
				return false
			}
			ma := k*q - y + x
			return x <= k*p && k*p <= ma
		})))
	}
}

package main

import (
	"fmt"
)

func check(x, y, p, q, total int64) bool{
	pp := total / q * p
	return x <= pp && total - y >= pp - x
}

func main ()  {
	var x, y, p, q int64
	var t int
	fmt.Scan(&t)
	for idx := 0; idx < t; idx++{
		var ans int64 = -1
		fmt.Scan(&x, &y, &p, &q)
		if x * q == y * p {
			fmt.Println(0)
			continue
		}
		var l , r int64
		l = 0;
		r = 10000000000000000
		for ; ; {
			if l == r{
				break;
			}
			tmp := (l + r ) / 2
			mid := tmp - tmp % q
			//fmt.Println(l, r, mid, tmp)
			if mid < l{
				l = tmp + 1
				continue
			}
			if check(x, y, p, q, mid){
				ans = mid
				r = mid - 1
			}else{
				l = mid + 1
			}
		}
		if ans >= 0{
			fmt.Println(ans - y)
		}else {
			fmt.Println(-1)
		}
	}
}


package main

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

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	min := func(a, b int) int {
		if a < b {
			return a
		}
		return b
	}

	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		hard := make([]bool, n)
		for i := range hard {
			Fscan(in, &hard[i])
		}
		dp := make([][2][2]int, n)
		for i := range dp {
			dp[i] = [2][2]int{{-1, -1}, {-1, -1}}
		}
		var f func(p, who, killed int) int
		f = func(p, who, killed int) (res int) {
			if p == n {
				return
			}
			dv := &dp[p][who][killed]
			if *dv != -1 {
				return *dv
			}
			defer func() {
				if hard[p] && who == 0 {
					res++
				}
				*dv = res
			}()
			if killed == 0 {
				return min(f(p+1, who, 1), f(p+1, who^1, 0))
			} else {
				return f(p+1, who^1, 0)
			}
		}
		Fprintln(out, f(0, 0, 0))
	}
}

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

package main

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

var in *bufio.Reader
var out *bufio.Writer

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

var err error

func next() (n string) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return ""
		}
	}
}

func nextInt() (n int) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func nextLong() (n int64) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func nextDouble() (n float64) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func Fill(a []int, v int) {
	for i := range a {
		a[i] = v
	}
}

func FillB(a []bool, v bool) {
	for i := range a {
		a[i] = v
	}
}

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
}

func Abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

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

const mod = 1000000007

func Add(a, b int64) int64 {
	return (a + b) % mod
}

func Mult(a, b int64) int64 {
	return (a * b) % mod
}

func Sub(a, b int64) int64 {
	return (a - b + mod) % mod
}

func solve() {
	// x, y, k := nextLong()-1, nextLong(), nextLong()
	// printf("%d\n", k+((y+1)*k+x-2)/x)
	n := nextInt()
	arr := make([]int, n+1)
	for i := 0; i < n; i++ {
		arr[i] = nextInt()
	}

	dp := [2][]int{make([]int, n+2), make([]int, n+2)}
	for i := n - 1; i >= 0; i-- {
		dp[0][i] = Min(dp[1][i+1]+arr[i], dp[1][i+2]+arr[i]+arr[i+1])
		dp[1][i] = Min(dp[0][i+1], dp[0][i+2])
	}
	printf("%d\n", dp[0][0])
}

func main() {
	in = bufio.NewReaderSize(os.Stdin, 8192)
	out = bufio.NewWriterSize(os.Stdout, 8192)
	if false {
		name := "foreign"
		file1, err := os.Open(name + ".in")
		if err != nil {
			log.Fatal(err)
		}
		file2, err := os.Create(name + ".out")
		if err != nil {
			log.Fatal(err)
		}
		in = bufio.NewReaderSize(file1, 8192)
		out = bufio.NewWriterSize(file2, 8192)
	}
	defer out.Flush()
	// start := time.Now()

	for t, i := nextInt(), 1; t > 0; t, i = t-1, i+1 {
		// 	printf("Case #%d:\n", i)
		solve()
	}

	// printf("%v\n", time.Now().Sub(start))
}

package main

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

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

	tc := readNum(reader)

	var buf bytes.Buffer

	for tc > 0 {
		tc--
		n := readNum(reader)
		A := readNNums(reader, n)
		res := solve(n, A)
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}
	fmt.Print(buf.String())
}

func solve(n int, A []int) int {
	if n == 1 {
		return A[0]
	}
	// dp[i][0] = min(dp[i-1][1] + x, dp[i-2][1] + x + y)
	// dp[i][1] = dp[i-1][0]

	dp := make([][]int, 3)
	for i := 0; i < 3; i++ {
		dp[i] = make([]int, 2)
		for j := 0; j < 2; j++ {
			dp[i][j] = n
		}
	}

	dp[0][0] = A[0]
	dp[1][0] = A[0] + A[1]
	dp[1][1] = A[0]
	//dp[1][0] = A[0] + A[1]
	for i := 2; i < n; i++ {
		dp[idx(i)][1] = min(dp[idx(i-1)][0], dp[idx(i-2)][0])
		dp[idx(i)][0] = min(dp[idx(i-1)][1]+A[i], dp[idx(i-2)][1]+A[i-1]+A[i])
	}

	return min(dp[idx(n-1)][0], dp[idx(n-1)][1])
}

func idx(i int) int {
	i = i % 3
	i = (i + 3) % 3
	return i
}

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

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

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

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

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

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

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

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

	return i
}

package main

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

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

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

func solve(arr []int) int {
	ans := arr[0]

	for i := 1; i < len(arr); i++ {
		if arr[i] == 0 {
			continue
		}

		j := i
		for j < len(arr) && arr[j] == 1 {
			j++
		}

		ans += (j - i) / 3
		i = j - 1
	}

	return ans
}

func main() {
	defer writer.Flush()

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

	for t > 0 {
		scanf("%d\n", &n)
		arr = make([]int, n)
		for i := 0; i < n; i++ {
			scanf("%d", &arr[i])
		}
		scanf("\n")
		ans := solve(arr)
		printf("%d\n", ans)
		t--
	}
}

/*
URL:
https://codeforces.com/contest/1418/problem/C
*/

package main

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

var (
	t int

	n int
	A []int
)

func main() {
	defer stdout.Flush()

	t = readi()
	for tc := 0; tc < t; tc++ {
		n = readi()
		A = readis(n)

		solve()
	}
}

func solve() {
	// j: 自分 or フレンド, k: 回数
	dp := [][2][2]int{}
	for i := 0; i <= n; i++ {
		row := [2][2]int{}
		dp = append(dp, row)
	}

	for i := 0; i <= n; i++ {
		for j := 0; j < 2; j++ {
			for k := 0; k < 2; k++ {
				dp[i][j][k] = INF_B30
			}
		}
	}

	dp[0][0][0] = 0
	for i := 0; i < n; i++ {
		if A[i] == 0 {
			// フレンド
			ChMin(&dp[i+1][0][1], dp[i][0][0])
			ChMin(&dp[i+1][1][0], dp[i][0][0])
			ChMin(&dp[i+1][1][0], dp[i][0][1])

			// 自分
			ChMin(&dp[i+1][1][1], dp[i][1][0])
			ChMin(&dp[i+1][0][0], dp[i][1][0])
			ChMin(&dp[i+1][0][0], dp[i][1][1])
		} else {
			// フレンド
			ChMin(&dp[i+1][0][1], dp[i][0][0]+1)
			ChMin(&dp[i+1][1][0], dp[i][0][0]+1)
			ChMin(&dp[i+1][1][0], dp[i][0][1]+1)

			// 自分
			ChMin(&dp[i+1][1][1], dp[i][1][0])
			ChMin(&dp[i+1][0][0], dp[i][1][0])
			ChMin(&dp[i+1][0][0], dp[i][1][1])
		}
	}

	ans := INF_B30
	for j := 0; j < 2; j++ {
		for k := 0; k < 2; k++ {
			ChMin(&ans, dp[n][j][k])
		}
	}
	fmt.Println(ans)
}

// func solve() {
// 	dp := [][]int{}
// 	for i := 0; i <= n; i++ {
// 		row := make([]int, 2)
// 		dp = append(dp, row)
// 	}

// 	for i := 0; i <= n; i++ {
// 		for j := 0; j < 2; j++ {
// 			dp[i][j] = INF_B30
// 		}
// 	}

// 	dp[0][0] = 0
// 	for i := 0; i < n; i++ {
// 		if A[i] == 0 {
// 			ChMin(&dp[i+1][1], dp[i][0])
// 		} else {

// 		}
// 	}
// }

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

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

/********** common constants **********/

const (
	MOD = 1000000000 + 7
	// MOD          = 998244353
	ALPH_N  = 26
	INF_I64 = math.MaxInt64
	INF_B60 = 1 << 60
	INF_I32 = math.MaxInt32
	INF_B30 = 1 << 30
	NIL     = -1
)

// modi can calculate a right residual whether value is positive or negative.
func modi(val, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// modll can calculate a right residual whether value is positive or negative.
func modll(val, m int64) int64 {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

/********** bufio setting **********/

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

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

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

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

//str := reads()
//i := readi()
//X := readis(n)
//S := readrs()
//a := readf()
//A := readfs(n)

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

/*********** Input ***********/

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

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

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

// readi returns an integer.
func readi() int {
	return int(_readInt64())
}
func readi2() (int, int) {
	return int(_readInt64()), int(_readInt64())
}
func readi3() (int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64())
}
func readi4() (int, int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64()), int(_readInt64())
}

// readll returns as integer as int64.
func readll() int64 {
	return _readInt64()
}
func readll2() (int64, int64) {
	return _readInt64(), _readInt64()
}
func readll3() (int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64()
}
func readll4() (int64, int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64(), _readInt64()
}

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

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

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

// readf returns an float64.
func readf() float64 {
	return float64(_readFloat64())
}

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

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

// readrs returns a rune slice.
func readrs() []rune {
	return []rune(reads())
}

/*********** Output ***********/

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

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

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

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

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

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

	return res
}

package main

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

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	min := func(a, b int) int {
		if a < b {
			return a
		}
		return b
	}

	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		h := make([]bool, n)
		for i := range h {
			Fscan(in, &h[i])
		}
		dp := make([][2][2]int, n)
		for i := range dp {
			dp[i] = [2][2]int{{-1, -1}, {-1, -1}}
		}
		var f func(p, who, c int) int
		f = func(p, who, c int) (res int) {
			if p == n {
				return
			}
			dv := &dp[p][who][c]
			if *dv != -1 {
				return *dv
			}
			defer func() { *dv = res }()
			res = f(p+1, who^1, 0)
			if c == 0 {
				res = min(res, f(p+1, who, 1))
			}
			if who == 0 && h[p] {
				res++
			}
			return
		}
		Fprintln(out, f(0, 0, 0))
	}
}

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

package main

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

func print( a ...interface{}) { fmt.Fprint(w, a...) }
func scan( a ...interface{})  { fmt.Fscan(r, a...) }

func main() {
defer w.Flush()

var q int
scan(&q)
for ; q > 0; q-- {
	var n int
	scan(&n)
	var a = make([]int, n)
	var ans = 0
	for i:=0; i< n; i++ {
		scan(&a[i])
	}
	var turn = true
	for i:= 0; i < n; {
		if turn {
			if a[i] == 1 {
				ans++
			}
			i++
			if i < n && a[i] == 0 {
				if i+1 < n && a[i+1] == 1 {
					i++;
				}
			}
		}else{
			i++
				if i<n && a[i] == 1 {
					i++;
				}else if i+1 < n && a[i+1] == 0 {
					i++;
				}
			}
			turn = !turn
		}
		print(ans, "\n")
	}
}

package main

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

var rw = NewFastIO(os.Stdin, os.Stdout)

func main() {
	defer rw.Flush()
	tt := rw.NextInt()
	for i := 0; i < tt; i++ {
		solveCase()
	}
}

func Mins(x *int, y int) {
	if y < *x {
		*x = y
	}
}
func solveCase() {
	n := rw.NextInt()
	a := rw.NextInts(n)
	dp := make([]int, n+1)
	for i := 0; i <= n; i++ {
		dp[i] = 1e9
	}
	dp[0] = 0
	for i := 0; i <= n; i++ {
		if i+1 <= n {
			Mins(&dp[i+1], dp[i]+a[i])
		}
		if i+2 <= n {
			Mins(&dp[i+2], dp[i]+a[i])
		}
		if i+3 <= n {
			Mins(&dp[i+3], dp[i]+a[i])
		}
		if i+4 <= n {
			Mins(&dp[i+4], dp[i]+a[i]+a[i+1])
		}
	}
	rw.Println(dp[n])
}

// @meooow template uwu
type FastIO struct {
	*bufio.Writer
	r    io.Reader
	buf  [8192]byte
	i, n int
}

func NewFastIO(r io.Reader, w io.Writer) *FastIO {
	return &FastIO{r: r, Writer: bufio.NewWriter(w)}
}

func (f *FastIO) readC() byte {
	if f.i == f.n {
		f.n, _ = f.r.Read(f.buf[:])
		if f.n == 0 {
			panic("EOF")
		}
		f.i = 0
	}
	f.i++
	return f.buf[f.i-1]
}

func (f *FastIO) Next() string {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	var s []byte
	for ; c > ' '; c = f.readC() {
		s = append(s, c)
	}
	return string(s)
}

func (f *FastIO) NextInt() int {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := 0
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}
func (f *FastIO) NextInt64() int64 {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := int64(0)
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int64(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}

func (f *FastIO) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}
func (f *FastIO) NextInt64s(n int) []int64 {
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt64()
	}
	return a
}

func (f *FastIO) Println(a ...interface{}) {
	fmt.Fprintln(f, a...)
}

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f, a...)
}
func (f *FastIO) PrintInts(a ...int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}
func (f *FastIO) PrintlnInts(a ...int) {
	f.PrintInts(a...)
	f.Println()
}
func (f *FastIO) PrintInt64s(a ...int64) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}
func (f *FastIO) PrintlnInt64s(a ...int64) {
	f.PrintInt64s(a...)
	f.Println()
}

package main

import "fmt"

func solve(arr []int) int {
	ans := arr[0]

	for i := 1; i < len(arr); i++ {
		if arr[i] == 0 {
			continue
		}

		j := i
		for j < len(arr) && arr[j] == 1 {
			j++
		}

		ans += (j - i) / 3
		i = j - 1
	}

	return ans
}

func main() {
	var t int
	var n int
	var arr []int
	fmt.Scanf("%d\n", &t)
	for t > 0 {
		fmt.Scanf("%d\n", &n)
		arr = make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Scanf("%d", &arr[i])
		}
		// fmt.Scanf("\n")
		ans := solve(arr)
		fmt.Println(ans)
		t--
	}
}

package main

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

func print( a ...interface{}) { fmt.Fprint(w, a...) }
func scan( a ...interface{})  { fmt.Fscan(r, a...) }

func main() {
defer w.Flush()

var q int
scan(&q)
for ; q > 0; q-- {
	var n int
	scan(&n)
	var a = make([]int, n)
	var ans = 0
	for i:=0; i< n; i++ {
		scan(&a[i])
	}
	var turn = true
	for i:= 0; i < n; {
		if turn {
			if a[i] == 1 {
				ans++
			}
			i++
			if i < n && a[i] == 0 {
				i++
			}
		}else{
			i++
				if i<n && a[i] == 1 {
					i++;
				}else if i+1 < n && a[i+1] == 0 {
					i++;
				}
			}
			turn = !turn
		}
		print(ans, "\n")
	}
}


package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n := 0, 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		o, a, b, tot := []int{}, "", "", 0
		fmt.Fscan(f, &a, &b)
		for j := 0; j < n; j++ {
			if string(a[j]) == "1" {
				o = append(o, 1)
			} else {
				o = append(o, 0)
			}
		}
		for j := 0; j < n; j++ {
			p, _ := strconv.Atoi(string(b[j]))
			if j == 0 {
				if o[j] == 0 && p == 1 {
					o[j] = 2
				} else if o[j+1] == 1 && p == 1 {
					o[j+1] = 2
				}
			} else if j == n-1 {
				if o[j-1] == 1 && p == 1 {
					o[j-1] = 2
				} else if o[j] == 0 && p == 1 {
					o[j] = 2
				}
			} else {
				if o[j-1] == 1 && p == 1 {
					o[j-1] = 2
				} else if o[j] == 0 && p == 1 {
					o[j] = 2
				} else if o[j+1] == 1 && p == 1 {
					o[j+1] = 2
				}
			}
		}
		for j := 0; j < n; j++ {
			if o[j] == 2 {
				tot++
			}
		}
		fmt.Fprintln(w, tot)
	}
	w.Flush()
}

func main() {
	solve()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)
func main() {
	defer write.Flush()
	var t int
	fmt.Fscan(read,&t)
	for i := 0; i < t; i++ {
		solve()
	}
}

func solve() {
	var n int
	fmt.Fscan(read,&n)
	var s1, s2 string
	fmt.Fscan(read,&s1)
	fmt.Fscan(read,&s2)
	//var a, b = make([]byte, n)
	a := []byte(s1)
	b := []byte(s2)
	var count int = 0
	for i := 0; i < n; i++ {
		if b[i] == '1' {
			if i > 0 && a[i-1] == '1' {
				count++
			} else if a[i] == '0' {
				count++
				a[i] = '2'
			} else if i < n-1 && a[i+1] == '1' {
				count++
				a[i+1] = '2'
			}
		}
	}
	fmt.Fprintln(write,count)
}

package main

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

func main() {
	t := 0
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 1000000), 1000000)
	s.Scan()
	fmt.Sscanf(s.Text(), "%d", &t)

	for k := 0; k < t; k++ {
		var n int
		s.Scan()
		fmt.Sscanf(s.Text(), "%d", &n)
		s.Scan()
		a := s.Bytes()
		s.Scan()
		b := s.Bytes()

		res := 0
		for i := 0; i < n; i++ {
			if b[i] == '1' {
				if i > 0 && a[i-1] == '1' {
					res++
				} else if a[i] == '0' {
					a[i] = '2'
					res++
				} else if i < n-1 && a[i+1] == '1' {
					a[i+1] = '2'
					res++
				}
			}
		}
		fmt.Println(res)
	}
}

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 n int
		fmt.Fscan(in,&n)
		var top,bottom string
		fmt.Fscan(in,&top,&bottom)
		row2:= strings.Split(top,"")
		row1:= strings.Split(bottom,"")
		counter:=0
		for k:=0;k<n;k++{ //empties
			if string(row1[k]) == "1" && string(row2[k]) == "0"{
				counter++
				row1[k],row2[k] = ".","1."
			}
		}
		for k:=0;k<n;k++{ // diagonals
			if k == 0 {
				if string(row1[k]) == "1" && string(row2[k+1]) == "1"{
					counter++
					row1[k],row2[k+1] = ".","1."
				}
				continue
			}
			if k == n-1 {
				if string(row1[k]) == "1" && string(row2[k-1]) == "1"{
					counter++
					row1[k],row2[k-1] = ".","1."
				}
				continue
			}
			if string(row1[k]) == "1" && string(row2[k-1]) == "1" {
				counter++
				row1[k],row2[k-1] = ".","1."
				continue
			} else if string(row1[k]) == "1" && string(row2[k+1]) == "1" {
				counter++
				row1[k],row2[k+1] = ".","1."
				continue
			}
		}
		fmt.Fprintln(out,counter)
	}
}

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

package main

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

func main() {
	// START WRITING YOUR SOLUTION HERE:
	// writeLine(typeOf(readInt()))
	t := readInt()
	for j := 0; j < t; j++ {
		n := readInt()
		var arr []string
		arr = append(arr, readLine())
		arr = append(arr, readLine())
		//fmt.Printf("arr====>%v,n=====>%v\n", arr, n)
		cnt := 0
		map1 := make(map[int]int)
		for i := 0; i < n; i++ {
			if arr[1][i] == '1' {
				val := DFS(i, arr[0], map1)
				//fmt.Printf("val ====>%v\n", val)
				if val != 0 {
					if _, found := map1[val-1]; !found {
						map1[val-1]++
						cnt += 1
					}
				}
			}
		}
		//fmt.Printf("map1===>%v\n", map1)
		fmt.Printf("%v\n", cnt)
	}
}
func DFS(i int, s string, map1 map[int]int) int {
	//fmt.Printf("i====>%v, s====>%v, map1====>%v\n",i,s,map1)
	if s[i] == '0' {
		return i + 1
	}
	if i-1 >= 0 && s[i-1] == '1' {
		if _, found := map1[i-1]; !found {
			return i
		}
	}
	if i+1 < len(s) && s[i+1] == '1' {
		if _, found := map1[i+1]; !found {
			return i + 2
		}
	}
	return 0
}

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

var in = bufio.NewReader(os.Stdin)

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

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

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

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

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

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

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

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

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

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1549B
Date: 24/01/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1549/B
Problem: CF1549B
**/
func (in *CF1549B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		strx := in.NextString()
		str2 := in.NextString()
		marcados := make([]int , n)
		for i:=0;i<n;i++ {
			if strx[i] == '1' {
				marcados[i] = 1
			}
		}
		ans := 0
		for i := 0; i < n; i++ {
			if str2[i] == '1' {
				if marcados[i] == 0 {
					ans++
					marcados[i] = 2
				} else {
					if i > 0  && marcados[i-1] == 1 {
						ans++
						marcados[i-1] = 2
					} else {
						if i+1 < n && marcados[i+1] == 1 {
							ans++
							marcados[i+1] = 2
						}
					}
				}
			}
		}
		fmt.Println(ans)
	}
}

func change(str string, pos int, char string) string {
	if pos == 0 {
		return char + str[1:]
	}
	if pos == len(str)-1 {
		return str[0:pos]+ char
	}
	return str[0:pos] + char + str[pos+1:]
}

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

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

package main

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

var (
	in *bufio.Scanner = bufio.NewScanner(os.Stdin)
	out *bufio.Writer = bufio.NewWriter(os.Stdout)

	n int
	s [2][]string
	res int
)

func main() {
	in.Buffer([]byte{}, 4 * 1024 * 1024)
	var t int = 1
	t = getInts()[0]
	for i := 0; i < t; i++ {
		solve()
	}
	// test()
	out.Flush()
}

func solve() {
	initialize()
	input()
	count()
	output()
}

func initialize() {
	res = 0
}

func input() {
	n = getInts()[0]
	s[0] = strings.Split(getStrings()[0], "")
	s[1] = strings.Split(getStrings()[0], "")
}

func count() {
	for i := 0; i < n; i++ {
		if s[1][i] == "1" {
			if i > 0 && s[0][i-1] == "1" {
				res++
			} else if s[0][i] == "0" {
				res++
			} else if i < (n - 1) && s[0][i+1] == "1" {
				s[0][i+1] = "2"
				res++
			}
		}
	}
}

func output() {
	out.WriteString(fmt.Sprintf("%d\n", res))
}

func test() {

}

func getFloats() []float64 {
	in.Scan()
	str := strings.Split(in.Text(), " ")
	var res []float64 = make([]float64, len(str))
	for i := 0; i < len(str); i++ {
		res[i], _ = strconv.ParseFloat(str[i], 64)
	}
	return res
}

func getInt64s() []int64 {
	in.Scan()
	str := strings.Split(in.Text(), " ")
	var res []int64 = make([]int64, len(str))
	for i := 0; i < len(str); i++ {
		res[i], _ = strconv.ParseInt(str[i], 10, 64)
	}
	return res
}

func getInts() []int {
	in.Scan()
	str := strings.Split(in.Text(), " ")
	var res []int = make([]int, len(str))
	for i := 0; i < len(str); i++ {
		res[i], _ = strconv.Atoi(str[i])
	}
	return res
}

func getStrings() []string {
	in.Scan()
	return strings.Split(in.Text(), " ")
}

func bsLower(arr []int, n int) int {
	var minN, midN, maxN int
	maxN = len(arr)
	for maxN - 1 > minN {
		midN = (minN + maxN) / 2
		if arr[midN] > n {
			minN = midN
		} else {
			maxN = midN
		}
	}
	if arr[minN] <= n {
		return minN
	}
	return maxN
}

func bsLower64(arr []int64, n int64) int {
	var minN, midN, maxN int
	maxN = len(arr)
	for maxN - 1 > minN {
		midN = (minN + maxN) / 2
		if arr[midN] > n {
			minN = midN
		} else {
			maxN = midN
		}
	}
	if arr[minN] <= n {
		return minN
	}
	return maxN
}

func bsUpper(arr []int, n int) int {
	var minN, midN, maxN int
	maxN = len(arr)
	for maxN - 1 > minN {
		midN = (minN + maxN) / 2
		if arr[midN] <= n {
			minN = midN
		} else {
			maxN = midN
		}
	}
	if arr[minN] > n {
		return minN
	}
	return maxN
}

func bsUpper64(arr []int64, n int64) int {
	var minN, midN, maxN int
	maxN = len(arr)
	for maxN - 1 > minN {
		midN = (minN + maxN) / 2
		if arr[midN] <= n {
			minN = midN
		} else {
			maxN = midN
		}
	}
	if arr[minN] > n {
		return minN
	}
	return maxN
}

func max(n1, n2 int) int {
	return int(max64(int64(n1), int64(n2)))
}

func max64(n1, n2 int64) int64 {
	if n1 > n2 {
		return n1
	}
	return n2
}

func min(n1, n2 int) int {
	return int(min64(int64(n1), int64(n2)))
}

func min64(n1, n2 int64) int64 {
	if n1 < n2 {
		return n1
	}
	return n2
}

func yes(res, isUpperCase bool) bool {
	var arr [4]string = [4]string{"no", "yes", "NO", "YES"}
	var ind = 0
	if res == true {
		ind = 1
	}
	if isUpperCase == true {
		ind += 2
	}
	out.WriteString(fmt.Sprintf("%s\n", arr[ind]))
	return res
}

package main

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

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

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

func main() {
	defer out.Flush()

	var (
		n, t int
		str  [2]string
	)
	fmt.Fscanf(in, "%d", &t)
	for t > 0 {
		t--

		fmt.Fscan(in, &n)
		s := make([][]int, 2)
		for i := 0; i < 2; i++ {
			s[i] = make([]int, n)
			fmt.Fscan(in, &str[i])
			for j := 0; j < n; j++ {
				s[i][j] = int(str[i][j] - '0')
			}
		}
		ans := 0
		for i := 0; i < n; i++ {
			if s[1][i] == 0 {
				continue
			}
			if s[0][i] == 0 {
				ans++
				continue
			}
			if i-1 >= 0 && s[0][i-1] == 1 {
				ans++
				s[0][i-1] = 2
				continue

			}
			if i+1 < n && s[0][i+1] == 1 {
				ans++
				s[0][i+1] = 2

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

	}

}

package main

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

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		var n, res int
		var up, down []byte

		fmt.Fscan(r, &n, &up, &down)

		for i := range up {
			if down[i] == '1' && up[i] == '0' {
				res++
				down[i] = '0'
			}
		}

		for i := range up {
			if down[i] == '1' {
				if i > 0 && up[i-1] == '1' {
					res++
				} else if i < n-1 && up[i+1] == '1' {
					res++
					up[i+1] = '0'
				}
			}
		}

		fmt.Fprintln(w, res)
	}

}

package main

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

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

func solve(n int, e, a string) int {
	r := 0
	captured := make([]bool, n)
	for i := range e {
		if a[i] == '1' {
			if i-1 >= 0 && e[i-1] == '1' && !captured[i-1] {
				captured[i-1] = true
				r++
			} else if e[i] == '0' {
				r++
			} else if i < n-1 && e[i+1] == '1' && !captured[i+1] {
				captured[i+1] = true
				r++
			}
		}
	}
	return r
}

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

package main

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

var iost *Iost

type Iost struct {
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
}

func NewIost(fp io.Reader, wfp io.Writer) *Iost {
	const BufSize = 1000000
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	return &Iost{Scanner: scanner, Writer: bufio.NewWriter(wfp)}
}

func (i *Iost) Text() string {
	if !i.Scanner.Scan() {
		panic("scan failed")
	}
	return i.Scanner.Text()
}

func (i *Iost) Atoi(s string) int                 { x, _ := strconv.Atoi(s); return x }
func (i *Iost) GetNextInt() int                   { return i.Atoi(i.Text()) }
func (i *Iost) Atoi64(s string) int64             { x, _ := strconv.ParseInt(s, 10, 64); return x }
func (i *Iost) GetNextInt64() int64               { return i.Atoi64(i.Text()) }
func (i *Iost) Atof64(s string) float64           { x, _ := strconv.ParseFloat(s, 64); return x }
func (i *Iost) GetNextFloat64() float64           { return i.Atof64(i.Text()) }
func (i *Iost) Print(x ...interface{})            { fmt.Fprint(i.Writer, x...) }
func (i *Iost) Printf(s string, x ...interface{}) { fmt.Fprintf(i.Writer, s, x...) }
func (i *Iost) Println(x ...interface{})          { fmt.Fprintln(i.Writer, x...) }
func isLocal() bool                               { return os.Getenv("I") == "IronMan" }

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	if isLocal() {
		fp, _ = os.Open(os.Getenv("END_GAME"))
	}
	iost = NewIost(fp, wfp)
	defer func() {
		if isLocal() {
			iost.Println(recover())
		}
		iost.Writer.Flush()
	}()
	solve()
	for i := 0; isLocal() && i < 100; i++ {
		iost.Println("-----------------------------------")
		solve()
	}
}

func solve() {
	t := iost.GetNextInt()
	for t > 0 {
		t--
		func() {
			n := iost.GetNextInt()
			epawn := iost.Text()
			pawn := iost.Text()
			used := make([]int, n+2)
			ret := 0
			for i := 0; i < n; i++ {
				if pawn[i] == '1' {
					if i-1 >= 0 && used[i-1] == 0 && epawn[i-1] == '1' {
						ret += 1
						used[i-1] = 1
					} else if used[i] == 0 && epawn[i] == '0' {
						ret += 1
						used[i] = 1
					} else if i+1 < n && epawn[i+1] == '1' {
						ret += 1
						used[i+1] = 1
					}
				}
			}
			iost.Println(ret)
		}()
	}
}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

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

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

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

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

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

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

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

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

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	var l, q int64
	l = MAX(x, y)
	q = MIN(x, y)
	var m int64
	for l*q > 0 {
		a := l % q
		b := l - a
		cc := int64(b / q)
		remain := l - cc*q
		l = MAX(remain, q)
		q = MIN(remain, q)
		if l*q == 0 {
			m = l + q
			break
		}

	}
	return m
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

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

var t int

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

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

		var n int
		fmt.Fscan(input, &n)

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

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

		var ans int
		ARR := make([]int, 0)
		BRR := make([]int, 0)

		ARR = append(ARR, -1)
		BRR = append(BRR, -1)

		for i := 0; i < n; i++ {
			if string(STRING[i]) == "0" {
				ARR = append(ARR, 0)
			}

			if string(STRING[i]) == "1" {
				ARR = append(ARR, 1)
			}

			if string(STRINGSEC[i]) == "0" {
				BRR = append(BRR, 0)
			}

			if string(STRINGSEC[i]) == "1" {
				BRR = append(BRR, 1)
			}

		}
		ARR = append(ARR, -1)
		BRR = append(BRR, -1)

		for i := 1; i <= n; i++ {
			if BRR[i] == 1 {
				if ARR[i] == 0 {
					ans++
				} else {
					if ARR[i-1] == 1 {
						ans++
						ARR[i-1] = 0
					} else {
						if ARR[i+1] == 1 {
							ans++
							ARR[i+1] = 0
						}
					}
				}

			}
		}
		fmt.Println(ans)

	}

}

package main

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

func main() {
	var (
		test int
		n    int
	)
	inp := bufio.NewScanner(os.Stdin)
	inp.Buffer(make([]byte, 1000000), 1000000)

	inp.Scan()
	fmt.Sscanf(inp.Text(), "%d", &test)
	for tt := 0; tt < test; tt++ {
		inp.Scan()
		fmt.Sscanf(inp.Text(), "%d", &n)
		inp.Scan()
		s := inp.Bytes()
		inp.Scan()
		t := inp.Bytes()
		var mark = make([]bool, n)
		var ans int
		for i := 0; i < n; i++ {
			if t[i] == '1' {
				if i > 0 && s[i-1] == '1' && !mark[i-1] {
					ans++
				} else if s[i] == '0' && !mark[i] {
					mark[i] = true
					ans++
				} else if i+1 < n && s[i+1] == '1' && !mark[i+1] {
					mark[i+1] = true
					ans++
				}
			}
		}
		fmt.Println(ans)
	}
}

package main

import "fmt"

func main() {
	var (
		test int
		n    int
		top  string
		bot  string
	)
	fmt.Scanln(&test)
	for tt := 0; tt < test; tt++ {
		fmt.Scanln(&n)
		fmt.Scanln(&top)
		fmt.Scanln(&bot)
		s := []byte(top)
		t := []byte(bot)
		var mark = make([]bool, n)
		var ans int
		for i := 0; i < n; i++ {
			if t[i] == '1' {
				if i > 0 && s[i-1] == '1' {
					ans++
				} else if s[i] == '0' && !mark[i] {
					mark[i] = true
					ans++
				} else if i+1 < n && s[i+1] == '1' && !mark[i+1] {
					mark[i+1] = true
					ans++
				}
			}
		}
		fmt.Println(ans)
	}
}

package main

import "fmt"

func main() {
	var (
		test int
		n    int
		top  string
		bot  string
	)
	fmt.Scanln(&test)
	for tt := 0; tt < test; tt++ {
		fmt.Scanln(&n)
		fmt.Scanln(&top)
		fmt.Scanln(&bot)
		s := []byte(top)
		t := []byte(bot)
		var mark = make([]bool, n)
		var ans int
		for i := 0; i < n; i++ {
			if t[i] == '1' {
				if i > 0 && s[i-1] == '1' {
					ans++
				} else if s[i] == '0' && !mark[i] {
					mark[i] = true
					ans++
				} else if i+1 < n && s[i+1] == '1' && !mark[i] {
					mark[i+1] = true
					ans++
				}
			}
		}
		fmt.Println(ans)
	}
}

package main

import "fmt"

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

func solve() {
	var n int
	fmt.Scan(&n)
	var s1, s2 string
	fmt.Scan(&s1, &s2)
	//var a, b = make([]byte, n)
	a := []byte(s1)
	b := []byte(s2)
	var count int = 0
	for i := 0; i < n; i++ {
		if b[i] == '1' {
			if i > 0 && a[i-1] == '1' {
				count++
			} else if a[i] == '0' {
				count++
				a[i] = '2'
			} else if i < n-1 && a[i+1] == '1' {
				count++
				a[i] = '2'
			}
		}
	}
	fmt.Println(count)
}

package main

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

func main() {
	t := 0
	s := bufio.NewScanner(os.Stdin)
	s.Scan()
	fmt.Sscanf(s.Text(), "%d", &t)

	for i := 0; i < t; i++ {
		var a, b []byte
		var n int
		s.Scan()
		fmt.Sscanf(s.Text(), "%d", &n)
		s.Scan()
		a = s.Bytes()
		s.Scan()
		b = s.Bytes()

		res := 0
		for i := 0; i < n; i++ {
			if b[i] == '1' {
				if i > 0 && a[i-1] == '1' {
					res++
				} else if a[i] == '0' {
					a[i] = '2'
					res++
				} else if i < n-1 && a[i+1] == '1' {
					a[i+1] = '2'
					res++
				}
			}
		}
		fmt.Printf("%d\n", res)
	}
}

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

package main

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

func main() {
	// START WRITING YOUR SOLUTION HERE:
	// writeLine(typeOf(readInt()))
	t := readInt()
	for j := 0; j < t; j++ {
		n := readInt()
		var arr []string
		arr = append(arr, readLine())
		arr = append(arr, readLine())
		//fmt.Printf("arr====>%v,n=====>%v\n", arr, n)
		cnt := 0
		for i := 0; i < n; i++ {
			if arr[1][i] == '1' {
				cnt += DFS(i, arr[0])
			}
		}
		fmt.Printf("%v\n", cnt)
	}
}
func DFS(i int, s string) int {
	if s[i] == '0' {
		return 1
	}
	if (i-1 >= 0 && s[i-1] == '1') || (i+1 < len(s) && s[i+1] == '1') {
		return 1
	}
	return 0
}

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

var in = bufio.NewReader(os.Stdin)

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

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

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

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

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

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

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

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

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

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

package main

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

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

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

func main() {
	defer out.Flush()

	var (
		n, t int
		str  [2]string
	)
	fmt.Fscanf(in, "%d", &t)
	for t > 0 {
		t--

		fmt.Fscan(in, &n)
		s := make([][]int, 2)
		for i := 0; i < 2; i++ {
			s[i] = make([]int, n)
			fmt.Fscan(in, &str[i])
			for j := 0; j < n; j++ {
				s[i][j] = int(str[i][j] - '0')
			}
		}
		ans := 0
		for i := 0; i < n; i++ {
			if s[1][i] == 0 {
				continue
			}
			if s[0][i] == 0 {
				ans++
				continue
			}
			if i+1 < n && s[0][i+1] == 1 {
				ans++
				s[0][i+1] = 0
			}
		}
		printf("%d\n", ans)

	}

}


package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

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

func init() {
	if f, err := os.Open("in.txt"); 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, "\n") == nil {
		solve(n)
	}
}

func solve(n int) {
	t, ans := make([]int64, n+1), make([]int64, n+1)
	for i := 0; i < n; i++ {
		I(&t[i], "\n")
	}
	for i := 0; i < n; i++ {
		ans[i+1] = ans[i] + 20
		q := sort.Search(n, func(ii int) bool { return t[i]-90 < t[ii] })
		var o int64
		if q != n {
			o = int64(50) + ans[q]
			if ans[i+1] > o {
				ans[i+1] = o
			}
		}
		q = sort.Search(n, func(ii int) bool { return t[i]-1440 < t[ii] })
		if q != n {
			o = int64(120) + ans[q]
			if ans[i+1] > o {
				ans[i+1] = o
			}
		}
		O(ans[i+1]-ans[i], "\n")
	}
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

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

func init() {
	if f, err := os.Open("in.txt"); 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, "\n") == nil {
		solve(n)
	}
}

func solve(n int) {
	t, ans := make([]int64, n+1), make([]int64, n+1)
	for i := 0; i < n; i++ {
		I(&t[i], "\n")
	}
	for i := 0; i < n; i++ {
		ans[i+1] = ans[i] + 20
		q := sort.Search(n, func(ii int) bool { return t[i]-89 <= t[ii] })
		var o int64
		if q != n {
			o = int64(50) + ans[q]
			if ans[i+1] > o {
				ans[i+1] = o
			}
		}
		q = sort.Search(n, func(ii int) bool { return t[i]-1439 <= t[ii] })
		if q != n {
			o = int64(120) + ans[q]
			if ans[i+1] > o {
				ans[i+1] = o
			}
		}
		O(ans[i+1]-ans[i], "\n")
	}
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

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

func init() {
	if f, err := os.Open("in.txt"); 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, "\n") == nil {
		solve(n)
	}
}

func solve(n int) {
	t, ans := make([]int64, n+1), make([]int64, n+1)
	for i := 0; i < n; i++ {
		I(&t[i], "\n")
		ans[i+1] = ans[i] + 20
		q := sort.Search(n, func(ii int) bool { return t[i]-90 < t[ii] })
		var o int64
		if q != n {
			o = int64(50) + ans[q]
			if ans[i+1] > o {
				ans[i+1] = o
			}
		}
		q = sort.Search(n, func(ii int) bool { return t[i]-1440 < t[ii] })
		if q != n {
			o = int64(120) + ans[q]
			if ans[i+1] > o {
				ans[i+1] = o
			}
		}
		O(ans[i+1]-ans[i], "\n")
	}
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

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

func init() {
	if f, err := os.Open("in.txt"); 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, "\n") == nil {
		solve(n)
	}
}

func solve(n int) {
	t, ans := make([]int64, n+1), make([]int64, n+1)
	for i := 0; i < n; i++ {
		I(&t[i], "\n")
		ans[i+1] = ans[i] + 20
		q := sort.Search(n, func(ii int) bool { return t[i]-89 <= t[ii] })
		var o int64
		if q != n {
			o = int64(50) + ans[q]
			if ans[i+1] > o {
				ans[i+1] = o
			}
		}
		q = sort.Search(n, func(ii int) bool { return t[i]-1439 <= t[ii] })
		if q != n {
			o = int64(120) + ans[q]
			if ans[i+1] > o {
				ans[i+1] = o
			}
		}
		O(ans[i+1]-ans[i], "\n")
	}
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1174D(in io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n, x int
	Fscan(in, &n, &x)
	if m := 1 << n; x < m {
		m >>= 1
		Fprintln(out, m-1)
		mask := x&-x - 1
		for i := 1; i < m; i++ {
			v := i & -i
			Fprint(out, v&^mask<<1|v&mask, " ")
		}
	} else {
		Fprintln(out, m-1)
		for i := 1; i < m; i++ {
			Fprint(out, i&-i, " ")
		}
	}
}
func main() { CF1174D(os.Stdin, os.Stdout) }


package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var n, x, d int
		var arr []int
		var sums []int
		fmt.Scan(&n)
		fmt.Scan(&x)
		for j := 0; j < n; j++ {
			fmt.Scan(&d)
			arr = append(arr, d)
			if j == 0 {
				sums = append(sums, d)
			} else {
				sums = append(sums, sums[j-1]+d)
			}

		}
		if sums[len(sums)-1] == x {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
			for j := 0; j < n; j++ {
				if x == arr[j] {
					arr[j], arr[j+1] = arr[j+1], arr[j]
				}
				fmt.Printf("%d ", arr[j])
				x -= arr[j]
			}
			fmt.Println("")
		}
	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n,w,summer int
		fmt.Fscan(in,&n,&w)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
			summer+=list[j]
		}
		if summer == w {
			fmt.Fprintln(out,"NO")
			continue
		}
		var sum int
		for j:=0;j<n;j++{
			if list[j]+sum == w {
				if j == n-1 {
					list[j],list[j-1] = list[j-1],list[j]
				} else {
					list[j],list[j+1] = list[j+1],list[j]
				}
				break
			}
			sum+=list[j]
		}
		fmt.Fprintln(out,"YES")
		for j:=0;j<n;j++{
			fmt.Fprintf(out,"%v ",list[j])
		}
		fmt.Fprintln(out)
	}
}

package main

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

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

func printArr(w []int) string {
	x := ""
	for _, v := range w {
		x += fmt.Sprintf("%d ", v)
	}
	return x
}

func solve(n, x int, w []int) string {
	sum := 0
	for _, v := range w {
		sum += v
	}
	if sum == x {
		return "NO"
	}
	sort.Ints(w)
	sum = 0
	for i := range w {
		sum += w[i]
		if sum == x {
			w[i], w[n-1] = w[n-1], w[i]
			break
		}
	}
	return "YES\n" + printArr(w)
}

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

package main

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

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

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

	for kk := 0; kk < nt; kk++ {
		var n, x int
		fmt.Fscanf(reader, "%d%d\n", &n, &x)

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

		var sum = 0

		for i := 0; i < n; i++ {
			sum += a[i]
			if sum == x && i < n - 1 {
				a[i], a[i + 1] = a[i + 1], a[i]
			}
		}

		if sum != x {
			fmt.Fprintf(writer, "YES\n")
			for _, record := range a {
				fmt.Fprintf(writer, "%d ", record)
			}
			fmt.Fprintf(writer, "\n")
		} else {
			fmt.Fprintf(writer, "NO\n")
		}
	}
}

package main

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

const maxN = 1023

func swap(x, y *int) {
  *x, *y = *y, *x
}

func main() {
  in := bufio.NewReader(os.Stdin)
  out := bufio.NewWriter(os.Stdout)
  defer out.Flush()
  var tt int
  fmt.Fscan(in, &tt)
  for tc := 1; tc <= tt; tc++ {
    var n, x int
    fmt.Fscan(in, &n, &x)
    var w[maxN] int
    for i := 0; i < n; i++ {
      fmt.Fscan(in, &w[i]);
    }
    //sort.Ints(w[:n])
    var sm int
    sm = 0
    for i := 0; i < n; i++ {
      sm += w[i]
      if sm == x && i < n - 1 {
        sm += w[i+1] - w[i]
        swap(&w[i], &w[i+1])
      }
    }
    if sm == x {
      fmt.Fprint(out, "NO\n")
    }else {
      fmt.Fprint(out, "YES\n")
      for i := 0; i < n; i++ {
        fmt.Fprint(out, w[i], " ")
      }
      fmt.Fprint(out, "\n")
    }
  }
}

package main

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

const maxN = 1023

func swap(x, y *int) {
  *x, *y = *y, *x
}

func main() {
  in := bufio.NewReader(os.Stdin)
  out := bufio.NewWriter(os.Stdout)
  defer out.Flush()
  var tt int
  fmt.Fscan(in, &tt)
  for tc := 1; tc <= tt; tc++ {
    var n, x int
    fmt.Fscan(in, &n, &x)
    var w[maxN] int
    for i := 0; i < n; i++ {
      fmt.Fscan(in, &w[i]);
    }
    sort.Ints(w[:n])
    var sm int
    sm = 0
    for i := 0; i < n; i++ {
      sm += w[i]
      if sm == x && i < n - 1 {
        sm += w[i+1] - w[i]
        swap(&w[i], &w[i+1])
      }
    }
    if sm == x {
      fmt.Fprint(out, "NO\n")
    }else {
      fmt.Fprint(out, "YES\n")
      for i := 0; i < n; i++ {
        fmt.Fprint(out, w[i], " ")
      }
      fmt.Fprint(out, "\n")
    }
  }
}

package main

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

func main_gr_14_A() {
	_in, _out := os.Stdin, os.Stdout
	in, out := bufio.NewReader(_in), bufio.NewWriter(_out)
	defer out.Flush()
	var cas int = 1
	Fscan(in, &cas)
	var sol func()
	sol = func() {
		var n, x int
		Fscan(in, &n, &x)
		arr := make([]int, n)
		var total int
		for i := 0; i < n; i++ {
			Fscan(in, &arr[i])
			total += arr[i]
		}
		if total == x {
			Fprintln(out, "NO")
			return
		}
		Fprintln(out, "YES")
		total = 0
		sort.Ints(arr)
		for i := 0; i < n; i++ {
			total += arr[i]
			if total == x {
				Fprint(out, arr[i+1], " ", arr[i], " ")
				i++
			} else {
				Fprint(out, arr[i], " ")
			}
		}
		Fprintln(out)
	}
	for i := 0; i < cas; i++ {
		sol()
	}
}

func main() {
	main_gr_14_A()
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n, x := 0, 0, 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n, &x)
		o, sum, s := make([]int, n), 0, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &o[j])
			sum += o[j]
		}
		if sum == x {
			fmt.Fprintln(w, "NO")
		} else {
			fmt.Fprintln(w, "YES")
			for j := 0; j < n-1; j++ {
				if s+o[j] == x {
					o[j], o[j+1] = o[j+1], o[j]
				}
				s += o[j]
			}
			for j := 0; j < n; j++ {
				fmt.Fprint(w, o[j], " ")
			}
			fmt.Fprintln(w, "")
		}
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

func run(r io.Reader, w io.Writer) {
	in := bufio.NewReader(r)
	out := bufio.NewWriter(w)
	defer out.Flush()

	var t int
	for	Fscan(in, &t); t > 0; t-- {
		var n, x int
		Fscan(in, &n, &x)

		nums := make([]int, n)
		sum, pos := 0, -1
		for i := range nums {
			Fscan(in, &nums[i])
			sum += nums[i]
			if sum == x {
				pos = i
			}
		}
		if pos == n - 1 {
			Fprintln(out, "NO")
			continue
		}
		Fprintln(out, "YES")
		if pos != -1 {
			nums[pos], nums[pos+1] = nums[pos+1], nums[pos]
		}
		for _, val := range nums {
			Fprint(out, val, " ")
		}
		Fprintln(out)
	}
}

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

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

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

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

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var T, N, X, w int
	Fscan(in, &T)
	for t := 0; t < T; t++ {
		Fscan(in, &N)
		Fscan(in, &X)
		ns := make([]int, N)
		tot := 0
		for n := 0; n < N; n++ {
			Fscan(in, &w)
			tot += w
			ns[n] = w
		}
		if tot < X {
			Fprintln(out, "YES")
			for i := 0; i < N; i++ {
				Fprint(out, ns[i], " ")
			}
			Fprintln(out)
			continue
		} else if tot == X {
			Fprintln(out, "NO")
			continue
		}

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

		s := 0
		eqIdx := -1
		idx := 0
		for idx < N {
			s += ns[idx]
			if s == X {
				eqIdx = idx
				break
			}
			idx++
		}

		Fprintln(out, "YES")
		if eqIdx == -1 {
			for i := 0; i < N; i++ {
				Fprint(out, ns[i], " ")
			}
			Fprintln(out)
		} else {
			idx = 0
			for idx < N {
				if idx == eqIdx {
					Fprint(out, ns[idx+1], " ", ns[idx], " ")
					idx += 2
					continue
				}
				Fprint(out, ns[idx], " ")
				idx++
			}
			Fprintln(out)
		}
	}
}

package main

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

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

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

		w := make([]int, n)
		var sum int

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

		if sum == x {
			fmt.Println("NO")
			continue
		}

		sort.Ints(w)

		count := 0
		for i := 0; i < n; i++ {
			count += w[i]

			if count == x {
				w[i], w[i+1] = w[i+1], w[i]
				break
			}
		}

		fmt.Println("YES")
		for _, val := range w {
			fmt.Printf("%d ", val)
		}
		fmt.Println()
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var n, x, d int
		var arr []int
		var sums []int
		fmt.Scan(&n)
		fmt.Scan(&x)
		for j := 0; j < n; j++ {
			fmt.Scan(&d)
			arr = append(arr, d)
			if j == 0 {
				sums = append(sums, d)
			} else {
				sums = append(sums, sums[j-1]+d)
			}

		}
		if sums[len(sums)-1] == x {
			fmt.Println("NO")
		} else {
			for j := 0; j < len(arr)-1; j++ {
				if sums[j] >= x && arr[j+1] != x {
					arr[0], arr[j+1] = arr[j+1], arr[0]
					break

				}

			}
			fmt.Println("YES")
			for j := 0; j < len(arr); j++ {
				fmt.Printf("%d ", arr[j])
			}
			fmt.Println("")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var n, x, d int
		var arr []int
		var sums []int
		fmt.Scan(&n)
		fmt.Scan(&x)
		for j := 0; j < n; j++ {
			fmt.Scan(&d)
			arr = append(arr, d)
			if j == 0 {
				sums = append(sums, d)
			} else {
				sums = append(sums, sums[j-1]+d)
			}

		}
		if sums[len(sums)-1] == x {
			fmt.Println("NO")
		} else {
			for j := 0; j < len(arr)-1; j++ {
				if sums[j] == x {
					arr[0], arr[j+1] = arr[j+1], arr[0]
				}

			}
			fmt.Println("YES")
			for j := 0; j < len(arr); j++ {
				fmt.Printf("%d ", arr[j])
			}
			fmt.Println("")
		}
	}
}

package main

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

func main() {
	var t int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n, x, d int
		var arr []int
		var sums []int
		_, _ = fmt.Fscan(in, &n, &x)
		for j := 0; j < n; j++ {
			_, _ = fmt.Fscan(in, &d)
			arr = append(arr, d)
			if j == 0 {
				sums = append(sums, d)
			} else {
				sums = append(sums, sums[j-1]+d)
			}

		}
		if sums[len(sums)-1] == x {
			fmt.Println("NO")
		} else {
			for j := 0; j < len(arr)-1; j++ {
				if sums[j] == x {
					arr[0], arr[j+1] = arr[j+1], arr[0]
				}

			}
			fmt.Println("YES")
			for j := 0; j < len(arr); j++ {
				fmt.Printf("%d ", arr[j])
			}
			fmt.Println()
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var n, x, d int
		var arr []int
		var sums []int
		fmt.Scan(&n)
		fmt.Scan(&x)
		for j := 0; j < n; j++ {
			fmt.Scan(&d)
			arr = append(arr, d)
			if j == 0 {
				sums = append(sums, d)
			} else {
				sums = append(sums, sums[j-1]+d)
			}

		}
		if sums[len(sums)-1] == x {
			fmt.Println("NO")
		} else {
			for j := 0; j < len(arr)-1; j++ {
				if sums[j] == x {
					arr[0], arr[j+1] = arr[j+1], arr[0]
				}

			}
			fmt.Println("YES")
			for j := 0; j < len(arr); j++ {
				fmt.Printf("%d ", arr[j])
			}
			fmt.Println()
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	var n, x, d int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var arr []int
		var sums []int
		fmt.Scan(&n)
		fmt.Scan(&x)
		for j := 0; j < n; j++ {
			fmt.Scan(&d)
			arr = append(arr, d)
			if j == 0 {
				sums = append(sums, d)
			} else {
				sums = append(sums, sums[j-1]+d)
			}

		}
		if sums[len(sums)-1] == x {
			fmt.Println("NO")
		} else {
			for j := 0; j < len(arr)-1; j++ {
				if sums[j] == x {
					arr[0], arr[j+1] = arr[j+1], arr[0]
				}

			}
			fmt.Println("YES")
			for j := 0; j < len(arr); j++ {
				fmt.Print(arr[j])
				fmt.Print(" ")
			}
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	var n, x, d int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var arr []int
		var sums []int
		fmt.Scan(&n)
		fmt.Scan(&x)
		for j := 0; j < n; j++ {
			fmt.Scan(&d)
			arr = append(arr, d)
			if j == 0 {
				sums = append(sums, d)
			} else {
				sums = append(sums, sums[j-1]+d)
			}

		}
		if sums[len(sums)-1] == x {
			fmt.Println("NO")
		} else {
			for j := 0; j < len(arr)-1; j++ {
				if sums[j] == x {
					arr[0], arr[j+1] = arr[j+1], arr[0]
				}

			}
			fmt.Println("YES")
			for j := 0; j < len(arr); j++ {
				if j == len(arr)-1 {
					fmt.Println(arr[j])

				} else {
					fmt.Print(arr[j])
					fmt.Print(" ")
				}
			}
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	var n, x, d int
	fmt.Scanf("%d", &t)
	for i := 0; i < t; i++ {
		var arr []int
		var sums []int
		fmt.Scan(&n)
		fmt.Scan(&x)
		for j := 0; j < n; j++ {
			fmt.Scan(&d)
			arr = append(arr, d)
			if j == 0 {
				sums = append(sums, d)
			} else {
				sums = append(sums, sums[j-1]+d)
			}

		}
		if sums[len(sums)-1] == x {
			fmt.Println("NO")
		} else {
			for j := 0; j < len(arr)-1; j++ {
				if sums[j] == x {
					arr[0], arr[j+1] = arr[j+1], arr[0]
				}

			}
			fmt.Println("YES")
			for j := 0; j < len(arr); j++ {
				if j == len(arr)-1 {
					fmt.Println(arr[j])

				} else {
					fmt.Print(arr[j])
					fmt.Print(" ")
				}
			}
		}
	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n,w int
		fmt.Fscan(in,&n,&w)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
		}
		var sum int
		for j:=0;j<n;j++{
			if sum+list[j] == w {
				sum=0
				goto out
			}
			sum+= list[j]
		}
		fmt.Fprintln(out,"YES")
		for j:=0;j<n;j++{
			fmt.Fprintf(out,"%v ",list[j])
		}
		fmt.Fprintln(out)
		continue

		out:
		for j:=n-1;j>=0;j--{
			if list[j]+sum == w {
				fmt.Fprintln(out,"NO")
				goto out2
			}
			sum+=list[j]
		}
		fmt.Fprintln(out,"YES")
		for j:=n-1;j>=0;j--{
			fmt.Fprintf(out,"%v ",list[j])
		}
		fmt.Fprintln(out)
		out2:
	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n,w int
		fmt.Fscan(in,&n,&w)
		list:= make([]int,n)
		var test bool
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
			if list[j] != w {
				test=true
			}
		}
		if test == false {
			fmt.Fprintln(out,"NO")
			continue
		}
		for j:=1;j<n;j++{
			if list[j] > list[j-1] {
				list[j-1],list[j] = list[j],list[j-1]
				j-=2
				if j < 0 {
					j=0
				}
			}
		}
		fmt.Fprintln(out,"YES")
		var sum int
		for j:=0;j<n;j++{
			if sum+list[j] == w {
				fmt.Fprintf(out,"%v ",list[n-1])
				sum+=list[n-1]
				n--
			}
			fmt.Fprintf(out,"%v ",list[j])
			sum+= list[j]
		}
		fmt.Fprintln(out)
	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n,w int
		fmt.Fscan(in,&n,&w)
		list:= make([]int,n)
		var test bool
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
			if list[j] != w {
				test=true
			}
		}
		if test == false {
			fmt.Fprintln(out,"NO")
			continue
		}
		fmt.Fprintln(out,"YES")
		if list[0] == w {
			for j:=1;j<n;j++{
				fmt.Fprintf(out,"%v ",list[j])
			}
			fmt.Fprintf(out,"%v",list[0])
		} else {
			for j:=0;j<n;j++{
				fmt.Fprintf(out,"%v ",list[j])
			}
		}
		fmt.Fprintln(out)
	}
}

package main

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

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

func printArr(w []int) string {
	x := ""
	for _, v := range w {
		x += fmt.Sprintf("%d ", v)
	}
	return x
}

func solve(n, x int, w []int) string {
	sum := 0
	for _, v := range w {
		sum += v
	}
	if sum == x {
		return "NO"
	}
	sum = 0
	for i := range w {
		sum += w[i]
		if sum == x {
			w[i], w[n-1] = w[n-1], w[i]
			break
		}
	}
	return "YES\n" + printArr(w)
}

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

package main

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

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

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

	for kk := 0; kk < nt; kk++ {
		var n, x int
		fmt.Fscanf(reader, "%d%d\n", &n, &x)

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

		var sum = 0

		for i := 0; i < n; i++ {
			sum += a[i]
			if sum == x && i < n - 1 {
				a[i], a[i + 1] = a[i + 1], a[i]
			}
		}

		if sum != x {
			fmt.Fprintf(writer, "YES\n")
			for _, record := range a {
				fmt.Fprintf(writer, "%d ", record)
			}
			fmt.Fprintf(writer, "\n")
		} else {
			fmt.Fprintf(writer, "NO\n")
		}
	}
}