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

type priorityQueue [][2]int

func (pq priorityQueue) Len() int {
	return len(pq)
}

func (pq priorityQueue) Less(i, j int) bool {
	return pq[i][1] > pq[j][1]
}

func (pq priorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *priorityQueue) Push(x interface{}) {
	*pq = append(*pq, x.([2]int))
}

func (pq *priorityQueue) Pop() (res interface{}) {
	res = (*pq)[len(*pq)-1]
	*pq = (*pq)[:len(*pq)-1]
	return res
}

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
}

var (
	dx     [4]int       = [4]int{-1, 0, 1, 0}
	dy     [4]int       = [4]int{0, 1, 0, -1}
	dirMap map[byte]int = map[byte]int{'U': 0, 'R': 1, 'D': 2, 'L': 3}
)

func solve() {
	n := nextInt()
	nums := map[int]int{}
	has := [4]int{}

	for i := 0; i < n; i++ {
		x := nextInt()
		nums[x]++
		if nums[x] == 8 {
			has[3]++
			has[2]--
		} else if nums[x] == 6 {
			has[2]++
			has[1]--
		} else if nums[x] == 4 {
			has[1]++
			has[0]--
		} else if nums[x] == 2 {
			has[0]++
		}
	}

	q := nextInt()
	for i := 0; i < q; i++ {
		qt, x := next(), nextInt()
		if qt == "+" {
			nums[x]++
			if nums[x] == 8 {
				has[3]++
				has[2]--
			} else if nums[x] == 6 {
				has[2]++
				has[1]--
			} else if nums[x] == 4 {
				has[1]++
				has[0]--
			} else if nums[x] == 2 {
				has[0]++
			}
		} else {
			nums[x]--
			if nums[x] == 1 {
				has[0]--
			} else if nums[x] == 3 {
				has[1]--
				has[0]++
			} else if nums[x] == 5 {
				has[2]--
				has[1]++
			} else if nums[x] == 7 {
				has[3]--
				has[2]++
			}
		}
		if has[3] > 0 || has[2] > 1 || (has[2] > 0 && has[0]+has[1] > 0) || has[1] > 1 || (has[1] > 0 && has[0] > 1) {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
	}

}

func main() {
	in = bufio.NewReaderSize(os.Stdin, 8192)
	out = bufio.NewWriterSize(os.Stdout, 8192)
	if false {
		name := "in"
		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()

	// for t := nextInt(); t > 0; t-- {
	solve()
	// }
}

package main

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

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

	n := readNum(reader)

	A := readNNums(reader, n)

	solver := NewSolver(n, A)

	q := readNum(reader)

	var buf bytes.Buffer

	for q > 0 {
		q--
		s, _ := reader.ReadBytes('\n')

		var x int
		readInt(s, 2, &x)
		var res bool
		if s[0] == '+' {
			res = solver.Add(x)
		} else {
			res = solver.Add(-x)
		}

		if res {
			buf.WriteString("YES\n")
		} else {
			buf.WriteString("NO\n")
		}
	}

	fmt.Print(buf.String())
}

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
}

type Solver struct {
	planks map[int]int
	two    int
	four   int
}

func NewSolver(n int, A []int) Solver {
	planks := make(map[int]int)

	for i := 0; i < n; i++ {
		planks[A[i]]++
	}

	var two int
	var four int
	for _, v := range planks {
		two += v / 2
		four += v / 4
	}

	return Solver{planks, two, four}
}

func (solver *Solver) Add(x int) bool {
	sign := 1
	if x < 0 {
		x = -x
		sign = -1
	}
	y := solver.planks[x]

	two, four := solver.two, solver.four

	two -= y / 2
	four -= y / 4

	y += sign

	two += y / 2
	four += y / 4

	solver.two = two
	solver.four = four
	solver.planks[x] = y

	return four >= 1 && two >= 4
}

package main

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

func main() {
	io := NewFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	const maxa = int(1e5 + 5)

	n := io.NextInt()
	a := io.NextInts(n)
	f := make([]int, maxa)
	c2, c4, c6, c8 := 0, 0, 0, 0

	upd := func(x, d int) {
		if d == 1 {
			f[x]++
			if f[x] == 2 {
				c2++
			}
			if f[x] == 4 {
				c4++
			}
			if f[x] == 6 {
				c6++
			}
			if f[x] == 8 {
				c8++
			}
		} else {
			if f[x] == 2 {
				c2--
			}
			if f[x] == 4 {
				c4--
			}
			if f[x] == 6 {
				c6--
			}
			if f[x] == 8 {
				c8--
			}
			f[x]--
		}
	}

	for _, x := range a {
		upd(x, 1)
	}

	for q := io.NextInt(); q > 0; q-- {
		t, x := io.Next(), io.NextInt()
		if t == "+" {
			upd(x, 1)
		} else {
			upd(x, -1)
		}
		if c4 >= 1 && c2 >= 3 || c4 >= 2 || c6 >= 1 && c2 >= 2 || c8 >= 1 {
			io.Println("YES")
		} else {
			io.Println("NO")
		}
	}
}

type FastIO struct {
	*bufio.Reader
	*bufio.Writer
	c [1]byte
}

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

func (f *FastIO) readC() byte {
	f.Read(f.c[:])
	return f.c[0]
}

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) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}

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

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

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f.Writer, 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()
}

package main

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

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

	inputStr := func() string {
		scanner.Scan()
		return scanner.Text()
	}

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

	n := inputInt()
	a := make([]int, 10e5+1)

	for i := 0; i < n; i++ {
		a[inputInt()]++
	}

	count2 := 0
	count4 := 0

	for i := range a {
		count2 += a[i] / 2
		count4 += a[i] / 4
	}

	q := inputInt()

	for i := 0; i < q; i++ {
		sgn := inputStr()
		val := inputInt()
		count2 -= a[val] / 2
		count4 -= a[val] / 4
		switch sgn {
		case "+":
			{
				a[val]++
				count2 += a[val] / 2
				count4 += a[val] / 4
			}
		case "-":
			{
				a[val]--
				count2 += a[val] / 2
				count4 += a[val] / 4
			}
		}

		if count4 >= 1 && count2 >= 4 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

/*
URL:
https://codeforces.com/contest/1393/problem/B
*/

package main

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

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

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

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

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

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

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

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

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

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

var (
	n int
	A []int
	q int

	cnts [100000 + 50]int
	G    [10]int
)

func main() {
	n = ReadInt()
	A = ReadIntSlice(n)
	q = ReadInt()

	for i := 0; i < n; i++ {
		cnts[A[i]]++
	}
	for i := 1; i <= 100000; i++ {
		// if cnts[i] >= 4 {
		// 	G[4]++
		// } else if cnts[i] >= 2 {
		// 	G[2]++
		// }
		cnt := cnts[i]
		four := cnt / 4
		two := (cnt % 4) / 2
		G[4] += four
		G[2] += two
	}

	for i := 0; i < q; i++ {
		tmp := ReadString()
		x := ReadInt()

		preCnt := cnts[x]
		four := preCnt / 4
		two := (preCnt % 4) / 2
		G[4] -= four
		G[2] -= two

		if tmp == "+" {
			cnts[x]++
		} else {
			cnts[x]--
		}
		curCnt := cnts[x]
		four = curCnt / 4
		two = (curCnt % 4) / 2
		G[4] += four
		G[2] += two

		if G[4] >= 2 || (G[4] >= 1 && G[2] >= 2) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func toG(cnt int) int {
	if cnt >= 8 {
		// G[8]++
		return 8
	} else if cnt >= 6 {
		// G[6]++
		return 6
	} else if cnt >= 4 {
		// G[4]++
		return 4
	} else if cnt >= 2 {
		// G[2]++
		return 2
	}
	return 0
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

package main

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

var reader *bufio.Reader
var writer *bufio.Writer

func main() {
	//ioutil.WriteFile("input.txt", []byte(generateInput()), os.ModeExclusive)

	debug := 1
	filename := "input.txt"
	if debug != 0 && len(os.Args) > 1 && os.Args[1] == "debug" {
		file, _ := os.Open(filename)
		reader = bufio.NewReaderSize(file, 1024*1024)
	} else {
		reader = bufio.NewReaderSize(os.Stdin, 1024*1024)
	}
	writer = bufio.NewWriterSize(os.Stdout, 1024*1024)

	planks := make([]int, int(1e5)+3)
	_ = readInt()
	arr := readInts()
	c2, c4 := 0, 0
	for _, v64 := range arr {
		v := int(v64)
		planks[v]++
		if planks[v] % 2 == 0 {
			c2++
		}
		if planks[v] % 4 == 0 {
			c4++
		}
	}
	q := readInt()
	for ; q > 0; q-- {
		str := readLine()
		op := str[0]
		v, _ := strconv.ParseInt(str[2:], 10, 32)
		switch op {
		case '+':
			planks[v]++
			if planks[v] % 2 == 0 {
				c2++
			}
			if planks[v] % 4 == 0 {
				c4++
			}
			break
		case '-':
			if planks[v] % 2 == 0 {
				c2--
			}
			if planks[v] % 4 == 0 {
				c4--
			}
			planks[v]--
			break
		}
		if c4 >= 2 || (c4 == 1 && c2 >= 4) {
			fmt.Fprintln(writer, "YES")
		} else {
			fmt.Fprintln(writer, "NO")
		}
	}

	writer.Flush()
}

func readInts() []int64 {
	line := readLine()
	fields := strings.Fields(line)
	res := make([]int64, len(fields))
	for i := range fields {
		v, _ := strconv.ParseInt(fields[i], 10, 64)
		res[i] = v
	}
	return res
}

func readInt() int64 {
	line := readLine()
	n, _ := strconv.ParseInt(line, 10, 32)
	return int64(n)
}

func readLine() string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

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

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

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

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

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

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

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

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func band(i int64) int64 {
	for _, b := range []int64{8, 6, 4, 2} {
		if i >= b {
			return b
		}
	}
	return 0
}

func main() {
	defer writer.Flush()
	n := sint64()
	counts := map[int64]int64{}
	for i := int64(0); i < n; i++ {
		counts[sint64()]++
	}
	bands := map[int64]int64{}
	for _, c := range counts {
		bands[band(c)]++
	}
	q := sint64()
	for i := int64(0); i < q; i++ {
		diff := sstring()
		num := sint64()
		bands[band(counts[num])]--
		if diff == "+" {
			counts[num]++
		} else {
			counts[num]--
		}
		bands[band(counts[num])]++
		has4 := false
		has2a := false
		has2b := false
		for _, b := range []int64{8, 6, 4, 2} {
			c := bands[b]
			if c > 0 {
				if b == 8 {
					has4, has2a, has2b = true, true, true
				} else if b == 6 {
					if c > 1 {
						has4, has2a, has2b = true, true, true
					} else {
						if has4 {
							has2a, has2b = true, true
						} else {
							has4 = true
							if has2a {
								has2b = true
							} else {
								has2a = true
							}
						}
					}
				} else if b == 4 {
					if c > 1 {
						has4, has2a, has2b = true, true, true
					} else {
						if has4 {
							has2a, has2b = true, true
						} else {
							has4 = true
						}
					}
				} else if b == 2 {
					if c > 1 {
						has2a, has2b = true, true
					} else {
						if has2a {
							has2b = true
						} else {
							has2a = true
						}
					}
				}
			}
			if has4 && has2a && has2b {
				break
			}
		}
		if has4 && has2a && has2b {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
	}
}

package main

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

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

	n := readNum(reader)

	A := readNNums(reader, n)

	solver := NewSolver(n, A)

	q := readNum(reader)

	var buf bytes.Buffer

	for q > 0 {
		q--
		s, _ := reader.ReadBytes('\n')

		var x int
		readInt(s, 2, &x)
		var res bool
		if s[0] == '+' {
			res = solver.Add(x)
		} else {
			res = solver.Sub(x)
		}

		if res {
			buf.WriteString("YES\n")
		} else {
			buf.WriteString("NO\n")
		}
	}

	fmt.Print(buf.String())
}

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
}

type Solver struct {
	planks map[int]int
	cnt    [4]int
}

func NewSolver(n int, A []int) Solver {
	planks := make(map[int]int)

	for i := 0; i < n; i++ {
		planks[A[i]]++
	}
	var cnt [4]int
	for _, v := range planks {
		cnt[v%4]++
	}

	return Solver{planks, cnt}
}

func (solver *Solver) Add(x int) bool {
	prev := solver.planks[x]

	solver.cnt[prev%4]--

	solver.planks[x]++

	cur := prev + 1

	solver.cnt[cur%4]++

	// cnt[0] doesn't matter
	// cnt[1] == 0 && cnt[3] == 0
	return check(solver.cnt)
}

func (solver *Solver) Sub(x int) bool {
	prev := solver.planks[x]
	solver.cnt[prev%4]--

	solver.planks[x]--

	cur := prev - 1

	solver.cnt[cur%4]++

	return check(solver.cnt)

}

func check(cnt [4]int) bool {
	if cnt[1] != 0 || cnt[3] != 0 {
		return false
	}
	x := cnt[2]
	return x&1 == 0
}

package main

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

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

	n := readNum(reader)

	A := readNNums(reader, n)

	solver := NewSolver(n, A)

	q := readNum(reader)

	var buf bytes.Buffer

	for q > 0 {
		q--
		s, _ := reader.ReadBytes('\n')

		var x int
		readInt(s, 2, &x)
		var res bool
		if s[0] == '+' {
			res = solver.Add(x)
		} else {
			res = solver.Add(-x)
		}

		if res {
			buf.WriteString("YES\n")
		} else {
			buf.WriteString("NO\n")
		}
	}

	fmt.Print(buf.String())
}

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
}

type Solver struct {
	planks map[int]int
	two    int
}

func NewSolver(n int, A []int) Solver {
	planks := make(map[int]int)

	for i := 0; i < n; i++ {
		planks[A[i]]++
	}

	var two int
	for _, v := range planks {

		x, y := v / 4, v % 4

		two += (x * 4) / 2

		if y >= 2 {
			two++
		}
	}

	return Solver{planks, two}
}

func (solver *Solver) Add(x int) bool {
	sign := 1
	if x < 0 {
		x = -x
		sign = -1
	}
	y := solver.planks[x]

	a, b := y / 4, y % 4

	two := solver.two

	two -= (a * 4) / 2
	if b >= 2 {
		two--
	}

	y += sign

	a, b = y / 4, y % 4

	two += (a * 4) / 2
	if b >= 2 {
		two++
	}
	solver.planks[x] = y
	solver.two = two
	return two/2 >= 2
}

package main

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

func main() {
	io := NewFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	const maxa = int(1e5 + 5)

	n := io.NextInt()
	a := io.NextInts(n)
	f := make([]int, maxa)
	c2, c4, c6, c8 := 0, 0, 0, 0

	upd := func(x, d int) {
		if d == 1 {
			f[x]++
			if f[x] == 2 {
				c2++
			}
			if f[x] == 4 {
				c4++
			}
			if f[x] == 6 {
				c6++
			}
			if f[x] == 8 {
				c8++
			}
		} else {
			if f[x] == 2 {
				c2--
			}
			if f[x] == 4 {
				c4--
			}
			if f[x] == 6 {
				c6--
			}
			if f[x] == 8 {
				c8--
			}
			f[x]--
		}
	}

	for _, x := range a {
		upd(x, 1)
	}

	for q := io.NextInt(); q > 0; q-- {
		t, x := io.Next(), io.NextInt()
		if t == "+" {
			upd(x, 1)
		} else {
			upd(x, -1)
		}
		io.Println(c2, c4, c6, c8)
		if c4 >= 1 && c2 >= 3 || c4 >= 2 || c6 >= 1 && c2 >= 2 || c8 >= 1 {
			io.Println("YES")
		} else {
			io.Println("NO")
		}
	}
}

type FastIO struct {
	*bufio.Reader
	*bufio.Writer
	c [1]byte
}

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

func (f *FastIO) readC() byte {
	f.Read(f.c[:])
	return f.c[0]
}

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) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}

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

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

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f.Writer, 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()
}

package main

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

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

	inputStr := func() string {
		scanner.Scan()
		return scanner.Text()
	}

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

	n := inputInt()
	a := make([]int, 10e5+1)

	fmt.Println(len(a))

	for i := 0; i < n; i++ {
		a[inputInt()]++
	}

	count2 := 0
	count4 := 0

	for i := range a {
		count2 += a[i] / 2
		count4 += a[i] / 4
	}

	q := inputInt()

	for i := 0; i < q; i++ {
		sgn := inputStr()
		val := inputInt()
		count2 -= a[val] / 2
		count4 -= a[val] / 4
		switch sgn {
		case "+":
			{
				a[val]++
				count2 += a[val] / 2
				count4 += a[val] / 4
			}
		case "-":
			{
				a[val]--
				count2 += a[val] / 2
				count4 += a[val] / 4
			}
		}

		if count4 >= 1 && count2 >= 4 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

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

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

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

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

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

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

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

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	defer writer.Flush()
	n := sint64()
	counts := map[int64]int64{}
	for i := int64(0); i < n; i++ {
		counts[sint64()]++
	}
	q := sint64()
	for i := int64(0); i < q; i++ {
		diff := sstring()
		if diff == "+" {
			counts[sint64()]++
		} else {
			counts[sint64()]--
		}
		has4 := false
		has2 := false
		has := false
		for _, c := range counts {
			if c >= 8 {
				has = true
				break
			}
			if c >= 6 {
				if has4 {
					has = true
					break
				}
				has4 = true
				if has2 {
					has = true
					break
				}
				has2 = true
				continue
			}
			if c >= 4 {
				if has4 {
					has = true
					break
				}
				has4 = true
				continue
			}
			if c >= 2 {
				if has4 && has2 {
					has = true
				}
				has2 = true
				continue
			}
		}
		if has {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
	}
}

package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

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

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

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

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

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

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

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

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func band(i int64) int64 {
	for _, b := range []int64{8, 6, 4, 2} {
		if i >= b {
			return b
		}
	}
	return 0
}

func main() {
	defer writer.Flush()
	n := sint64()
	counts := map[int64]int64{}
	for i := int64(0); i < n; i++ {
		counts[sint64()]++
	}
	bands := map[int64]int64{}
	for _, c := range counts {
		bands[band(c)]++
	}
	q := sint64()
	for i := int64(0); i < q; i++ {
		diff := sstring()
		num := sint64()
		bands[band(counts[num])]--
		if diff == "+" {
			counts[num]++
		} else {
			counts[num]--
		}
		bands[band(counts[num])]++
		has4 := false
		has2a := false
		has2b := false
		for b, c := range bands {
			if b == 8 {
				has4, has2a, has2b = true, true, true
				break
			}
			if b == 6 && c > 1 {
				has4, has2a, has2b = true, true, true
				break
			}
			if b == 6 && c == 1 {
				if has4 {
					has2a, has2b = true, true
				} else {
					has4 = true
					if has2a {
						has2b = true
						break
					} else {
						has2a = true
					}
				}
			}
			if b == 4 && c > 1 {
				has4, has2a, has2b = true, true, true
				break
			}
			if b == 4 && c == 1 {
				if has4 {
					has2a, has2b = true, true
				} else {
					has4 = true
				}
			}
			if b == 2 && c > 1 {
				has2a, has2b = true, true
			}
			if b == 2 {
				if has2a {
					has2b = true
				} else {
					has2a = true
				}
			}
			if has4 && has2a && has2b {
				break
			}
		}
		if has4 && has2a && has2b {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
	}
}


package main

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

const cf = true

func solve() {
	var n, k int
	fmt.Fscan(in, &n, &k)
	var str string
	cnt := make(map[byte]int)
	fmt.Fscan(in, &str)
	for i := 0; i < n; i++ {
		cnt[str[i]]++
	}
	len := n / k
	for i := 0; i < k; i++ {
		cur := "a"[0]
		for j := 0; j < len; j++ {
			if val, ok := cnt[cur]; ok && val > 0 {
				cnt[cur]--
				cur++
			} else {
				break
			}
		}
		fmt.Fprint(out, string(cur))
	}
	fmt.Fprintln(out)
}

func main() {
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		solve()
	}
}

func ConvertInt(val string, base, toBase int) (string, error) {
	i, err := strconv.ParseInt(val, base, 64)
	if err != nil {
		return "", err
	}
	return strconv.FormatInt(i, toBase), nil
}

type set[T Ordered] struct {
	itms map[T]struct{}
}

func (s *set[T]) init() {
	if s.itms == nil {
		s.itms = make(map[T]struct{})
	}
}

func (s *set[T]) add(item T) *set[T] {
	s.init()
	s.itms[item] = exists
	return s
}

func (s *set[T]) remove(item T) *set[T] {
	s.init()
	delete(s.itms, item)
	return s
}

func (s *set[T]) has(item T) bool {
	s.init()
	_, c := s.itms[item]
	return c
}

func (s *set[T]) sortedItems() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	sort.Slice(items, func(i, j int) bool {
		return items[i] < items[j]
	})
	return items
}

func (s *set[T]) items() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	return items
}

func (s *set[T]) size() int {
	s.init()
	return len(s.itms)
}

var exists = struct{}{}

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func reverseStr(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Ordered interface {
	Integer | Float | ~string
}

func abs[T Signed](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func min[T Ordered](x, y T) T {
	if x < y {
		return x
	}
	return y
}

func max[T Ordered](x, y T) T {
	if x > y {
		return x
	}
	return y
}

var (
	in  = getReader()
	out = getWriter()
)

func getReader() *bufio.Reader {
	if cf {
		return bufio.NewReader(os.Stdin)
	} else {
		in, _ := os.Open("input.txt")
		return bufio.NewReader(in)
	}
}

func getWriter() *bufio.Writer {
	if cf {
		return bufio.NewWriter(os.Stdout)
	} else {
		out, _ := os.Create("output.txt")
		return bufio.NewWriter(out)
	}
}

// https://codeforces.com/problemset/problem/1737/A

// 1737A - Ela Sorting Books

// Ela loves reading a lot, just like her new co-workers in DTL! On her first day after becoming an engineer in DTL, she is challenged by a co-worker to sort a heap of books into different compartments on the shelf.

// n books must be split into k compartments on the bookshelf (n is divisible by k). Each book is represented by a lowercase Latin letter from 'a' to 'y' inclusively, which is the beginning letter in the title of the book.
// Ela must stack exactly n/k books in each compartment. After the books are stacked, for each compartment indexed from 1 to k, she takes the minimum excluded (MEX) letter of the multiset of letters formed by letters representing all books in that compartment, then combines the resulting letters into a string. The first letter of the resulting string is the MEX letter of the multiset of letters formed by the first compartment, the second letter of the resulting string is the MEX letter of the multiset of letters formed by the second compartment, ... and so on. Please note, under the constraint of this problem, MEX letter can always be determined for any multiset found in this problem because 'z' is not used.
// What is the lexicographically greatest resulting string possible that Ela can create?
// A string a is lexicographically greater than a string b if and only if one of the following holds:
//  • b is a prefix of a, but b≠a;
//  • in the first position where a and b differ, the string a has a letter that appears later in the alphabet than the corresponding letter in b.
// The minimum excluded (MEX) letter of a multiset of letters is the letter that appears earliest in the alphabet and is not contained in the multiset. For example, if a multiset of letters contains 7 letters 'b', 'a', 'b', 'c', 'e', 'c', 'f' respectively, then the MEX letter of this compartment is 'd', because 'd' is not included in the multiset, and all letters comes before 'd' in the alphabet, namely 'a', 'b' and 'c', are included in the multiset.

// Input
// Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤100). Description of the test cases follows.
// The first line of each test case contains two integers n and k (1≤n≤200; 1≤k≤n). It is guaranteed that n is divisible by k.
// The second line of each test case contains a string of n lowercase Latin letters from 'a' to 'y' inclusively. Each letter represents the starting letter of the title of a book in the initial heap.
// It is guaranteed that the sum of n over all test cases does not exceed 1000.

// Output
// For each test case, output a string of k letters which is the most optimal string that Ela can find.

// Example
// input
// 5
// 12 3
// cabccadabaac
// 12 6
// cabccadabaac
// 12 12
// cabccadabaac
// 25 1
// abcdefghijklmnopqrstuvwxy
// 10 5
// bcdxedbcfg
// output
// edb
// ccbbba
// bbbbbaaaaaaa
// z
// aaaaa

// Note

// In the first test case, the books can be divided into 3 compartments as below:
//  • the first compartment contains the books with indices 1,2,3,7: multiset1={'c', 'a', 'b', 'd'} → MEX(multiset1)= 'e'
//  • the second compartment contains the books with indices 4,5,6,9 : multiset2={'c', 'c', 'a', 'b'} → MEX(multiset2)= 'd'
//  • the third compartment contains the remaining books 8,10,11,12 : multiset3={ 'a', 'a', 'a', 'c'} → MEX(multiset3)= 'b'
// Therefore, the answer is 'edb'. It can be proven that there is no way that Ela can arrange the books so that it results in a lexicographically greater string.

// Tutorial

// We'll iterate through compartments from 1 to K. we'll try to put 1 'a' book in it, so the MEX in that compartment will not be 'a'. If any compartment can't be filled by 'a' because we ran out of 'a', the MEX of that compartment will have to be 'a'.
// The same logic applies to 'b', 'c', 'd', ..., where for each compartment from 1, if the MEX of that compartment hasn't been determined, we'll fill the corresponding letter there.
// We'll stop when reaching the end of the alphabet, or we've reached the (N/K)-th letter in the alphabet (because the first compartment is already full).

package main

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

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	var q int
	var t, n, k, i, j uint
	var s string
	var count_char []uint
	var ans []byte
	var c rune
	var char byte

	for q, _ = fmt.Fscan(reader, &t); q == 1; q, _ = fmt.Fscan(reader, &t) {
		for ; t > 0; t-- {
			fmt.Fscan(reader, &n, &k, &s)

			count_char = make([]uint, 26)
			ans = make([]byte, 0)

			for _, c = range s {
				count_char[c-'a']++
			}

			for i = 0; i < 25 && i*k < n; i++ {
				for k > count_char[i]+uint(len(ans)) {
					ans = append(ans, byte('a'+i))
				}
			}

			if n < 25*k {
				char = byte('a' + n/k)
			} else {
				char = byte('a' + 25)
			}

			for uint(len(ans)) < k {
				ans = append(ans, char)
			}

			for i, j = 0, uint(len(ans)); i+1 < j; i, j = i+1, j-1 {
				ans[i], ans[j-1] = ans[j-1], ans[i]
			}

			fmt.Fprintln(writer, string(ans))
		}
	}

	writer.Flush()
}

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, k int
		fmt.Fscan(r, &n, &k)

		var s string
		fmt.Fscan(r, &s)

		sr := make([]byte, k)
		cmap := make(map[int]int)
		for _, v := range s {
			cmap[int(v)]++
		}

		for i := 0; i < k; i++ {
			var j int
			for j = 'a'; j < 'a' + n/k && cmap[j] > 0; j++ {
				cmap[j]--
			}
			sr[i] = byte(j)
		}

		fmt.Fprintln(w, string(sr))

	}
}

package main

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

var sc = bufio.NewScanner(os.Stdin)

const INF = 1e18
const N = 105

func main() {
	sc.Buffer(make([]byte, 500000*1+1), 500000)
	sc.Split(bufio.ScanWords)

	T := nextInt()
	for T > 0 {
		T--
		n, k, s := nextInt(), nextInt(), nextString()
		a := make([]int, 26)
		for _, v := range s {
			a[v-'a']++
		}
		res := make([]byte, k)
		for i := 0; i < k; i++ {
			res[i] = 'a'
		}
		l, r := 0, k-1
		for i := 0; i < n/k; i++ {
			for j := l; j <= r; j++ {
				if a[i] > 0 {
					a[i]--
					res[j]++
				} else {
					r = j - 1
					break
				}
			}
		}
		for _, v := range res {
			fmt.Printf("%c", v)
		}
		fmt.Printf("\n")
	}
}

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

package main

import (
	"fmt"
	"math"
)

func main() {
	var T int
	fmt.Scan(&T)
	for tt:=0; tt<T; tt++ {
		var n, k int
		var s string
		fmt.Scan(&n, &k, &s)
		d := n / k

		cnt := make([]int, 25)
		for i:=0; i<n; i++ {
			cnt[s[i]-'a']++
		}

		var res string
		for i:=0; i<k; i++ {
			ch := 0
			for j:=0; j< int(math.Min(25, float64(d))); j++ {
				if cnt[ch] > 0 {
					cnt[ch]--
					ch++
					continue
				}
				break
			}
			res += string('a' + ch)
		}

		fmt.Println(res)
	}
}

package main

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

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

func main() {
	var test int
	fmt.Fscan(in, &test)
	for i := 0; i < test; i++ {
		solve()
	}
	defer out.Flush()
}

func solve() {
	var n, k int
	var s string

	fmt.Fscan(in, &n, &k, &s)
	m := n / k
	cnt := make(map[rune]int)
	for _, c := range s {
		cnt[c]++
	}
	// fmt.Println(cnt)

	var res string
	for i := 0; i < k; i++ {
		j := 0
		c := 'a'
		for ; c <= 'z' && j < m; c++ {
			if cnt[c] <= 0 {
				res = res + string(c)
				// fmt.Println(i, j, c)
				break
			}
			// fmt.Println(i, j, c, cnt[c])
			j++
			cnt[c]--
		}
		if j >= m {
			res = res + string(c)
		}
	}
	fmt.Fprintf(out, "%s\n", res)
}


package main

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

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

func readInt64(in *bufio.Reader) int64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.ParseInt(nStr, 10, 64)
	return n
}

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

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

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

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

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

	defer out.Flush()

	n := readInt(in)

	for i := 0; i < n; i++ {
		input := readString(in)
		search := readString(in)

		res := Solve(input, search)

		fmt.Fprintf(out, "%s\n", res)
	}
}

func Solve(in string, s string) string {
	for i, c := range in {
		if string(c) == string(s[0]) && (i+1)%2 != 0 {
			return fmt.Sprint("YES")
		}
	}

	return fmt.Sprint("NO")
}

package main

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

func ReadLine(inputReader *bufio.Reader) string {
	line, err := inputReader.ReadString('\n')
	if err != nil {
		return ""
	}
	return strings.TrimSpace(string(line))
}

func main() {
	inputReader := bufio.NewReader(os.Stdin)
	a := ReadLine(inputReader)
	t, err := strconv.Atoi(a)
	if err != nil {
		return
	}
	var answers []string
	for i := 0; i < t; i++ {
		text := ReadLine(inputReader)
		symb := ReadLine(inputReader)
		chet := false
		nechen := false
		for i, r := range text {
			if fmt.Sprintf("%c", r) == symb {
				if (i + 1) % 2 == 0 {
					chet = true
				} else {
					nechen = true
				}
			}
		}
		if chet && !nechen {
			answers = append(answers,"NO" )
		} else if nechen {
			answers = append(answers,"YES")
		} else {
			answers = append(answers,"NO" )
		}

	}
	for _ ,r := range answers {
		fmt.Println(r)
	}

}

package main

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

func ReadLine(inputReader *bufio.Reader) string {
	line, err := inputReader.ReadString('\n')
	if err != nil {
		return ""
	}
	return strings.TrimSpace(line)
}

func main() {
	inputReader := bufio.NewReader(os.Stdin)
	a := ReadLine(inputReader)
	t, err := strconv.Atoi(a)
	if err != nil {
		return
	}
	var answers []string

	for i := 0; i < t; i++ {
		value := ReadLine(inputReader)
		x := ReadLine(inputReader)
		if detect(value, x) {
			answers = append(answers, "YES")
		} else {
			answers = append(answers, "NO")
		}
	}
	for _, r := range answers {
		fmt.Println(r)
	}
}

func detect(value string, toFind string) bool {
	for i, x := range value {
		if string(x) == toFind {
			newV := deleteAllBefore(value, i)
			if len(newV) == 1 {
				return true
			}
			newV = deleteAllAfter(newV, strings.Index(newV, toFind))
			if len(newV) == 1 {
				return true
			}
		}
	}
	return false
}

func deleteAllBefore(value string, i int) string {
	if i%2 == 0 {
		return value[i:]
	}
	if len(value[:i]) == 2 {
		return value[i:]
	}
	return value
}

func deleteAllAfter(value string, i int) string {
	if i%2 == 0 {
		return value[:i+1]
	}
	if len(value[i+1:]) == 2 {
		return value[:i+1]
	}
	return value
}

package main

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

func ReadLine(inputReader *bufio.Reader) string {
	line, err := inputReader.ReadString('\n')
	if err != nil {
		return ""
	}
	return strings.TrimSpace(line)
}

func main() {
	inputReader := bufio.NewReader(os.Stdin)
	a := ReadLine(inputReader)
	t, err := strconv.Atoi(a)
	if err != nil {
		return
	}
	var answers []string

	for i := 0; i < t; i++ {
		b := ReadLine(inputReader)
		value := ReadLine(inputReader)
		if detect(b, value) {
			answers = append(answers, "YES")
		} else {
			answers = append(answers, "NO")
		}

		//n, err := strconv.Atoi(b)
		//if err != nil {
		//	return
		//}
		//
		//variables := make([]int64, n)
		//s := strings.Split(value, " ")
		//for j := 0; j < n; j++ {
		//	number, err := strconv.Atoi(s[j])
		//	if err != nil {
		//		return
		//	}
		//	variables[j] = int64(number)
		//}
		//
		//sort.Slice(variables, func(i, j int) bool {
		//	return variables[i] > variables[j]
		//})
		//flag := false
		//if len(variables) > 2 {
		//	var prefixSum int64 = 0
		//	var postfiSum int64 = variables[len(variables)-1]
		//	if prefixSum > postfiSum {
		//		answers = append(answers, "YES")
		//		continue
		//	}
		//	for j := 0; j < int(len(variables)/2); j++ {
		//		prefixSum += variables[j]
		//		postfiSum += variables[len(variables)-1-(j+1)]
		//		if prefixSum > postfiSum {
		//			flag = true
		//			break
		//		}
		//	}
		//}
		//
		//if flag {
		//	answers = append(answers, "YES")
		//} else {
		//	answers = append(answers, "NO")
		//}
	}
	for _, r := range answers {
		fmt.Println(r)
	}
}

//
//func main() {
//	fmt.Println(detect("abcde", "c"))
//	fmt.Println(detect("abcde", "b"))
//	fmt.Println(detect("b", "x"))
//	fmt.Println(detect("aaaaaaaaaaaaaaa", "a"))
//	fmt.Println(detect("contest", "t"))
//	fmt.Println(detect("tconaes", "t"))
//}
//
func detect(value string, toFind string) bool {
	for i, x := range value {
		if string(x) == toFind {
			newV := deleteAllBefore(value, i)
			if len(newV) == 1 {
				return true
			}
			newV = deleteAllAfter(newV, strings.Index(newV, toFind))
			if len(newV) == 1 {
				return true
			}
		}
	}
	return false
}

func deleteAllBefore(value string, i int) string {
	if i%2 == 0 {
		return value[i:]
	}
	if len(value[:i]) == 2 {
		return value[i:]
	}
	return value
}

func deleteAllAfter(value string, i int) string {
	if i%2 == 0 {
		return value[:i+1]
	}
	if len(value[i+1:]) == 2 {
		return value[:i+1]
	}
	return value
}

//func deleteAllBefore(value string, i int) string {
//	if len(value[:i]) == 2 {
//		return value[i:]
//	}
//	return value
//}
//
//func deleteAllAfter(value string, i int) string {
//	if len(value[i+1:]) == 2 {
//		return value[:i+1]
//	}
//	return value
//}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1650A
Date: 11/03/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1650/A
Problem: CF1650A
**/
func (in *CF1650A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		str := in.NextString()
		char := in.NextString()[0]

		ans := false
		for i := 0; i < len(str); i++ {
			if str[i] == char && i%2 == 0{
					ans = true
					break
			}
		}

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

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

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

package main

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

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

	var T int
	var s, t string
o:
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &s, &t)
		if len(s)&1 > 0 {
			for i := range s {
				if s[i] == t[0] && i&1 == 0 {
					Fprintln(out, "YES")
					continue o
				}
			}
		}
		Fprintln(out, "NO")
	}
}

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

package main
import ."fmt"

// github.com/EndlessCheng/codeforces-go
func main() {
	T,s,t:=0,"",""
o:  for Scan(&T); T > 0; T-- {
		Scan(&s, &t)
		if len(s)&1 > 0 {
			for i := range s {
				if s[i] == t[0] && i&1 == 0 {
					Println("YES")
					continue o
				}
			}
		}
		Println("NO")
	}
}

package main

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

func main() {
	var (
		t int
	)

	reader := bufio.NewReader(os.Stdin)
	fmt.Scanf("%d\n", &t)

	for t > 0 {
		t--

		s, _ := reader.ReadString('\n')
		if s[len(s)-1] == 10 {
			s = s[:len(s)-1]
		}
		if s[len(s)-1] == 13 {
			s = s[:len(s)-1]
		}

		c, _ := reader.ReadString('\n')
		if c[len(c)-1] == 10 {
			c = c[:len(c)-1]
		}
		if c[len(c)-1] == 13 {
			c = c[:len(c)-1]
		}

		done := false
		//if len(s) > 1 {

			visa := make([]bool, len(s))
			cc := 0

			for i := 0; i < len(s); i++  {
				visa[i] = false
				if byte(s[i]) == []byte(c)[0] {
					cc++
				}
			}

			for done == false && cc > 0 {
				fhc := 0
				shc := 0
				fhd := false
				vis := false
				for i := 0; i < len(s); i++ {
					if fhd == true {
						shc++
					}
					if byte(s[i]) == []byte(c)[0] && vis == false && visa[i] == false {
						vis = true
						visa[i] = true
						fhd = true
						cc--
					}
					if fhd == false {
						fhc++
					}
				}
				if fhc % 2 == 0 && shc % 2 == 0 {
					done = true
				}
			}
		//}
		if done == true {
			fmt.Println("YES")
		} else {
                        fmt.Println("NO")
		}
	}
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		var s, c string
		fmt.Fscan(in, &s, &c)

		var f bool
		for i, v := range s {
			if v == rune(c[0]) {
				if i%2 == 0 {
					f = true
				}
			}
		}

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

	}
}

package main

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

/*

 */

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var s, c string
	scanf("%s\n%s\n", &s, &c)

	for i, r := range s {
		if byte(r) == c[0] && i%2 == 0 {
			fmt.Fprintln(writer, "YES")
			return
		}
	}

	fmt.Fprintln(writer, "NO")
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int) int {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	minimum := nums[0]
	for _, num := range nums {
		if num < minimum {
			minimum = num
		}
	}
	return minimum
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	idx := nums[0]
	for i, num := range nums {
		if num > nums[idx] {
			idx = i
		}
	}

	return nums[idx]
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

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

func solve(cin *scanner, cout *writer, cerr *writer) {
	s := cin.Next()
	t := []rune(cin.Next())[0]
	for i, c := range s {
		if i%2 == 1 {
			continue
		}
		if c == t {
			cout.Println("YES")
			return
		}
	}
	cout.Println("NO")
}

func main() {
	cin := NewScanner(os.Stdin)
	cout, cerr := NewWriter(os.Stdout), NewWriter(os.Stderr)
	defer cout.Flush()
	defer cerr.Flush()
	t := cin.NextInt()
	// t := 1
	for ti := 0; ti < t; ti++ {
		solve(cin, cout, cerr)
	}
}

// Template Bolierplate {{{
type scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 1024*1024)
	return &scanner{s}
}

func (i *scanner) Next() string {
	i.Scan()
	return i.Text()
}

func (i *scanner) Nexts(n int) []string {
	res := make([]string, n)
	for j := range res {
		res[j] = i.Next()
	}
	return res
}

func (i *scanner) NextInt() int {
	v, _ := strconv.Atoi(i.Next())
	return v
}

func (i *scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(i.Next(), 10, 64)
	return v
}

func (i *scanner) NextInts(n int) []int {
	res := make([]int, n)
	for j := range res {
		res[j] = i.NextInt()
	}
	return res
}

func (i *scanner) NextInt64s(n int) []int64 {
	res := make([]int64, n)
	for j := range res {
		res[j] = i.NextInt64()
	}
	return res
}

type writer struct {
	w *bufio.Writer
}

func NewWriter(w io.Writer) *writer {
	return &writer{bufio.NewWriter(w)}
}

func (i *writer) Print(a ...interface{}) {
	fmt.Fprint(i.w, a...)
}

func (i *writer) Println(a ...interface{}) {
	fmt.Fprintln(i.w, a...)
}

func (i *writer) Printf(format string, a ...interface{}) {
	fmt.Fprintf(i.w, format, a...)
}

func (i *writer) Flush() {
	i.w.Flush()
}

// }}}

// vim: fdm=marker

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		x := 0
		scanner.Scan()
		sls := strings.Split(scanner.Text(), "")
		scanner.Scan()
		c := scanner.Text()
		for j := 0; j < len(sls); j += 2 {
			if sls[j] == c {
				x++
			}
		}
		if x > 0 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main
import(
    "fmt"
    "strings"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var word,letter string
		fmt.Scan(&word,&letter)
		if strings.IndexAny(word,letter) == -1 {
			fmt.Println("NO")
		} else {
			for j:=0;j<len(word);j++ {
				if string(word[j]) == letter {
					if j%2 == 0 {
						fmt.Println("YES")
						goto out
					}
				}
			}
			fmt.Println("NO")
			out:
		}
	}
}

package main

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

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

func main() {
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t, "\n")
	for ; t > 0; t-- {
		var str string
		var ch string

		fmt.Fscan(in, &str, "\n")
		fmt.Fscan(in, &ch, "\n")
		flag := false
		arr := make([]int, 0)
		for idx, val := range str {
			if uint8(val) == ch[0] {
				arr = append(arr, idx)
			}
		}
		length := len(str)
		for _, val := range arr {
			front := val
			end := length - val - 1
			if (front%2 == 0) && (end%2 == 0) {
				flag = true
			}
		}
		if flag {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

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

	//count, _ := reader.ReadString('\n')
	//n, _ := strconv.Atoi(count)
	inputString := make([]string, 0)
	inputChar := make([]byte, 0)
	//for i:= 0; i < n; i++ {
	//	str, _ := reader.ReadString('\n')
	//	char, _ := reader.ReadByte()
	//	inputChar = append(inputChar, char)
	//	inputString = append(inputString, str)
	//
	//}
	i := 0
	n := 0
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		if i == 0 {
			count := scanner.Text()
			n, _ = strconv.Atoi(count)
			i++
			continue
		}

		inputString = append(inputString, scanner.Text())
		scanner.Scan()
		inputChar = append(inputChar, scanner.Text()[0])

		if i == n {
			break
		}
		i++
	}

	if err := scanner.Err(); err != nil {
		log.Println(err)
	}

	for i := range inputString {
		fmt.Println(checkString(inputString[i], inputChar[i]))
	}
}

func checkString(s string, c byte) string {
	for i := range s {
		if s[i] == c && (i+1)%2 != 0 {
			return "yes"
		}
	}
	return "no"
}

package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	_, _ = fmt.Fscan(in, &t)
	for ii := 0; ii < t; ii++ {
		var s, c string
		_, _ = fmt.Fscan(in, &s, &c)
		i, j := 0, 0
		last := -1
		for i < len(s) && j < len(c) {
			if s[i] == c[j] && (i-last)&1 == 1 {
				last = i
				j++
			}
			i++
		}
		if j == len(c) {
			_, _ = fmt.Fprintln(out, "YES")
		} else {
			_, _ = fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

func main() {
	inputReader := bufio.NewReader(os.Stdin)
	a := ReadLine(inputReader)

	numCases, _ := strconv.Atoi(a)

	answers := make([]string, numCases)
	for i := 0; i < numCases; i++ {
		str := ReadLine(inputReader)
		letter := ReadLine(inputReader)
		ans := processLine(str, letter[0])
		answers[i] = ans
	}

	for _, res := range answers {
		fmt.Println(res)
	}
}

func ReadLine(inputReader *bufio.Reader) string {
	line, err := inputReader.ReadString('\n')
	if err != nil {
		return ""
	}

	return strings.TrimSpace(string(line))
}

func processLine(line string, letter byte) string {
	for i := 0; i < len(line); i++ {
		if line[i] == letter && (i+1)%2 != 0 {
			return "yes"
		}
	}
	return "no"
}

package main

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

func CF1650A(rawIn io.Reader, rawOut io.Writer) {
	in := bufio.NewReader(rawIn)
	out := bufio.NewWriter(rawOut)
	defer out.Flush()

	var cases int
	fmt.Fscan(in, &cases)
	for cc := 0; cc < cases; cc++ {
		var s string
		fmt.Fscan(in, &s)
		var c string
		fmt.Fscan(in, &c)

		can := false
		for i, sc := range s {
			scs := string(sc)
			if scs == c && i%2 == 0 {
				can = true
				break
			}
		}

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

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

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, s, c := 0, "", ""
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &s, &c)
		ok, n := false, len(s)
		for j := 0; j < n; j++ {
			if string(s[j]) == c && j&1 == 0 && (n-j-1)&1 == 0 {
				ok = true
				break
			}
		}
		if ok {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
	}
	w.Flush()
}

func main() {
	solve()
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanln(&n)
	var str []byte
	var letter string

	for i := 0; i < n; i++ {
		var checker bool
		fmt.Scanln(&str)
		fmt.Scanln(&letter)
		for j := 0; j < len(str); j++ {
			if str[j] == []byte(letter)[0] && (j+1)%2 != 0 {
				checker = true
				break
			}
		}
		if checker {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

const mod = 998244353
const mx = 3000

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()
	var n int
	fmt.Fscan(in,&n)
	var s1,s2 string
	fmt.Fscan(in,&s1,&s2)
	prev := -1
	cur := 0
	for i := range s1{
		if s1[i] == s2[cur] && (i - prev) % 2 == 1{
			cur++
		}
		if cur == len(s2){
			fmt.Fprintln(out,"Yes")
			return
		}
	}
	fmt.Fprintln(out,"No")
}

func sum(a,b int64)int64{
	return (b + a) * (b - a + 1) / 2
}

func max(a,b int)int{
	if a > b{
		return a
	}
	return b
}
func min(a,b int64)int64{
	if a > b{
		return b
	}
	return a
}
func gcd(a,b int)int{
	if a % b == 0{
		return b
	}
	return gcd(b,a%b)
}

func main() {
	stdin := os.Stdin
	stdout := os.Stdout
	in := bufio.NewReader(stdin)
	out := bufio.NewWriter(stdout)
	n := 1
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		solve(in, out)
	}
}

//nolint
package main

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

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

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func print(a ...interface{})            { fmt.Fprint(writer, a...) }
func println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scan(a ...interface{})             { fmt.Fscan(reader, a...) }

func main() {
	defer writer.Flush()

	Main()
}

func Main() {
	var t int
	scan(&t)
	for ; t > 0; t-- {
		Solve()
	}
}

//}

func Solve() {
	var st, tp string
	scan(&st, &tp)
	c := rune(tp[0])
	for i, ch := range st {
		if ch == c && i%2 == 0 {
			println("YES")
			return
		}
	}
	println("NO")
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	t := readInt(reader)
	for t > 0 {
		s, _ := reader.ReadString('\n')
		s = strings.ReplaceAll(s, "\r", "")
		s = strings.ReplaceAll(s, "\n", "")

		c, _ := reader.ReadString('\n')
		c = strings.ReplaceAll(c, "\r", "")
		c = strings.ReplaceAll(c, "\n", "")

		kokoko(s, c)
		t--
	}
}

func kokoko(s, c string) {
	if !strings.Contains(s, c) {
		fmt.Println("NO")
		return
	}
	for i := range s {
		if s[i] == c[0] && i%2 == 0 {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
	return
}

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

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

func debug(name string, a interface{}) {
	fmt.Printf("\n%s = %v \n", name, a)
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
    defer writer.Flush()

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

    for (t > 0) {
        var s,c string
        flag := 0
        i := 0
        scanf("%s\n%s\n", &s, &c)

        for i = 0 ; i < len(s); i++ {
            if (s[i] == c[0] && (i % 2) == 0) {
                flag = 1
                break
            }
        }

        if (flag == 1) {
            printf("YES\n")
        }else {
            printf("NO\n")
        }
        t--
    }
}

package main

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

func main() {
	_r, _w := os.Stdin, os.Stdout
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var solve func()
	// Todo...
	solve = func() {
		var a string
		var b string
		Fscan(in, &a)
		Fscan(in, &b)
		n := len(a)
		for i := 0; i < n; i++ {
			if a[i] == b[0] && (i%2 == 0) && ((n-i-1)%2 == 0) {
				Fprintln(out, "YES")
				return
			}
		}
		Fprintln(out, "NO")
		//Fprintln(out, a, b)
	}
	// End...
	var T int = 1
	Fscan(in, &T)
	for i := 0; i < T; i++ {
		solve()
	}
}

package main

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

func ReadLine(inputReader *bufio.Reader) string {
	line, err := inputReader.ReadString('\n')
	if err != nil {
		return ""
	}
	return strings.TrimSpace(string(line))
}

func main() {
	inputReader := bufio.NewReader(os.Stdin)
	a := ReadLine(inputReader)
	t, err := strconv.Atoi(a)
	if err != nil {
		return
	}
	var answers []string
	for i := 0; i < t; i++ {
		text := ReadLine(inputReader)
		symb := ReadLine(inputReader)
		chet := false
		nechen := false
		for i, r := range text {
			if fmt.Sprintf("%c", r) == symb {
				if (i + 1) % 2 == 0 {
					chet = true
				} else {
					nechen = true
				}
			}
		}
		if chet && !nechen {
			answers = append(answers,"NO" )
			fmt.Println("NO")
		} else if nechen {
			answers = append(answers,"YES")
		} else {
			answers = append(answers,"NO" )
		}

	}
	for _ ,r := range answers {
		fmt.Println(r)
	}

}

package main

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

func ReadLine(inputReader *bufio.Reader) string {
	line, err := inputReader.ReadString('\n')
	if err != nil {
		return ""
	}
	return strings.TrimSpace(string(line))
}

func main() {
	inputReader := bufio.NewReader(os.Stdin)
	a := ReadLine(inputReader)
	t, err := strconv.Atoi(a)
	if err != nil {
		return
	}
	var answers []string
	for i := 0; i < t; i++ {
		text := ReadLine(inputReader)
		symb := ReadLine(inputReader)
		chet := false
		nechen := false
		for i, r := range text {
			if fmt.Sprintf("%c", r) == symb {
				if (i + 1) % 2 == 0 {
					chet = true
				} else {
					nechen = true
				}
			}
		}
		fmt.Println(chet,nechen)
		if chet && !nechen {
			answers = append(answers,"NO" )
			fmt.Println("NO")
		} else if nechen {
			answers = append(answers,"YES")
		} else {
			answers = append(answers,"NO" )
		}

	}
	for _ ,r := range answers {
		fmt.Println(r)
	}

}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1650A
Date: 11/03/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1650/A
Problem: CF1650A
**/
func (in *CF1650A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		str := in.NextString()
		char := in.NextString()[0]

		ans := false
		for i := 0; i < len(str); i++ {
			if str[i] == char{
				if i==0 || i == len(str)-1 || i == len(str)/2 {
					ans = true
					break
				}
			}
		}

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

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

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

package main

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

func main() {
	var (
		t int
	)

	reader := bufio.NewReader(os.Stdin)
	fmt.Scanf("%d\n", &t)

	for t > 0 {
		t--

		s, _ := reader.ReadString('\n')
		if s[len(s)-1] == 10 {
			s = s[:len(s)-1]
		}
		if s[len(s)-1] == 13 {
			s = s[:len(s)-1]
		}

		c, _ := reader.ReadString('\n')
		if c[len(c)-1] == 10 {
			c = c[:len(c)-1]
		}
		if c[len(c)-1] == 13 {
			c = c[:len(c)-1]
		}

		done := false
		if len(s) > 1 {

			visa := make([]bool, len(s))
			cc := 0

			for i := 0; i < len(s); i++  {
				visa[i] = false
				if byte(s[i]) == []byte(c)[0] {
					cc++
				}
			}

			for done == false && cc > 0 {
				fhc := 0
				shc := 0
				fhd := false
				vis := false
				for i := 0; i < len(s); i++ {
					if fhd == true {
						shc++
					}
					if byte(s[i]) == []byte(c)[0] && vis == false && visa[i] == false {
						vis = true
						visa[i] = true
						fhd = true
						cc--
					}
					if fhd == false {
						fhc++
					}
				}
				if fhc % 2 == 0 && shc % 2 == 0 {
					done = true
				}
			}
		}
		if done == true {
			fmt.Println("YES")
		} else {
            fmt.Println("NO")
		}
	}
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		var s, c string
		fmt.Fscan(in, &s, &c)

		var f bool
		fmt.Println(s, c)
		for i, v := range s {
			if v == rune(c[0]) {
				if i%2 == 0 {
					f = true
				}
			}
		}

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

	}
}

package main

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

/*

 */

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var s, c string
	scanf("%s\n%s\n", &s, &c)

	for i, r := range s {
		if byte(r) == c[0] && i != 1 && i != len(s)-2 {
			fmt.Fprintln(writer, "YES")
			return
		}
	}

	fmt.Fprintln(writer, "NO")
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int) int {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	minimum := nums[0]
	for _, num := range nums {
		if num < minimum {
			minimum = num
		}
	}
	return minimum
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	idx := nums[0]
	for i, num := range nums {
		if num > nums[idx] {
			idx = i
		}
	}

	return nums[idx]
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}


package main

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

func main_gr_14_D() {
	_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, l, r int
		Fscan(in, &n, &l, &r)
		left, right := map[int]int{}, map[int]int{}
		for i := 0; i < n; i++ {
			var val int
			Fscan(in, &val)
			if i < l {
				left[val]++
			} else {
				right[val]++
			}
		}
		for k, v := range left {
			var minCount int = int(1e9)
			if v < right[k] {
				minCount = v
			} else {
				minCount = right[k]
			}
			if minCount > 0 {
				left[k] -= minCount
				right[k] -= minCount
			}
		}
		var lcount, rcount int
		for _, v := range left {
			lcount += v
		}
		for _, v := range right {
			rcount += v
		}
		var ans = (lcount + rcount) / 2
		if lcount > rcount {
			moveCount := (lcount - rcount) / 2
			ans += moveCount
			for _, v := range left {
				moveCount -= v / 2
				if moveCount <= 0 {
					ans -= (moveCount + v/2)
					break
				} else {
					ans -= v / 2
				}
			}
		} else if rcount > lcount {
			moveCount := (rcount - lcount) / 2
			ans += moveCount
			for _, v := range right {
				moveCount -= v / 2
				if moveCount <= 0 {
					ans -= (moveCount + v/2)
					break
				} else {
					ans -= v / 2
				}
			}
		}
		Fprintln(out, ans)
	}
	for i := 0; i < cas; i++ {
		sol()
	}
}

func main() {
	main_gr_14_D()
}

package main

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

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

	var T, n, l, r, v int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &l, &r)
		c := make([]int, n+1)
		for i := 0; i < l; i++ {
			Fscan(in, &v)
			c[v]++
		}
		for i := 0; i < r; i++ {
			Fscan(in, &v)
			c[v]--
		}
		ans := 0
		for i := 1; i <= n; i++ {
			for l > r && c[i] > 1 {
				l -= 2
				c[i] -= 2
				ans++
			}
			for l < r && c[i] < -1 {
				r -= 2
				c[i] += 2
				ans++
			}
		}
		left := abs(l - r)
		for _, c := range c {
			left += abs(c)
		}
		Fprintln(out, ans+left/2)
	}
}

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

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

package main

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

var in *bufio.Reader

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

func solve() {
	var n, l, r int
	fmt.Fscan(in, &n)
	fmt.Fscan(in, &l)
	fmt.Fscan(in, &r)

	lefts := make(map[int]int)
	for i := 0; i < l; i++ {
		var t int
		fmt.Fscan(in, &t)
		lefts[t]++
	}

	rights := make(map[int]int)
	for i := 0; i < r; i++ {
		var t int
		fmt.Fscan(in, &t)
		rights[t]++
	}

	// Assume that lefts >= rights
	if l < r {
		l, r = r, l
		lefts, rights = rights, lefts
	}

	// Matched without change
	for color, leftCount := range lefts {
		rightCount, ok := rights[color]
		if !ok {
			continue
		}
		remove := min(leftCount, rightCount)
		lefts[color] -= remove
		l -= remove
		r -= remove
	}

	// Matched with one change
	result := 0
	for _, leftCount := range lefts {
		extras := l - r
		move := min(leftCount/2, extras/2)
		leftCount -= move * 2
		l -= move * 2
		result += move
	}

	// Change direction and change color
	result += (l-r)/2 + (l+r)/2

	fmt.Println(result)
}

func main() {
	in = bufio.NewReader(os.Stdin)

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

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

package main

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

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

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

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, l, r int
		fmt.Fscanf(reader, "%d%d%d\n", &n, &l, &r)

		var left = make(map[int]int)
		var right = make(map[int]int)

		for i := 0; i < n; i++ {
			var c int
			fmt.Fscanf(reader, "%d", &c)
			if i < l {
				if right[c] > 0 {
					right[c]--
				} else {
					left[c]++
				}
			} else {
				if left[c] > 0 {
					left[c]--
				} else {
					right[c]++
				}
			}
		}

		fmt.Fscanf(reader, "\n")

		var cost = 0
		var totalLeft = 0
		var totalRight = 0

		for _, v := range left {
			totalLeft += v
		}

		for _, v := range right {
			totalRight += v
		}

		// need change
		var diff = abs(totalLeft, totalRight) / 2

		cost += diff

		var middle = (totalLeft + totalRight) / 2

		//fmt.Println("middle", middle, "cost", cost)

		if totalRight < totalLeft {
			// change left -> right
			for k, v := range left {
				var ex = min(v / 2, diff)
				diff -= ex
				left[k] = v - ex
				middle -= ex
			}

		} else {
			// change right -> left
			for k, v := range right {
				var ex = min(v / 2, diff)
				diff -= ex
				right[k] = v - ex
				middle -= ex
			}

		}

		cost += middle

		fmt.Fprintf(writer, "%d\n", cost)
	}
}

package main

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

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

	var T, n, l, r, v int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &l, &r)
		c := make([]int, n+1)
		for i := 0; i < l; i++ {
			Fscan(in, &v)
			c[v]++
		}
		for i := 0; i < r; i++ {
			Fscan(in, &v)
			c[v]--
		}
		ans := 0
		for i := 1; i <= n; i++ {
			for l > r && c[i] > 1 { // 左袜子多，且有相同颜色，左变右，与自己匹配
				l -= 2
				c[i] -= 2
				ans++
			}
			for l < r && c[i] < -1 { // 右袜子多，且有相同颜色，右变左，与自己匹配
				r -= 2
				c[i] += 2
				ans++
			}
		}
		ans += abs(l-r) / 2 // 左变右或右变左
		left := 0
		for _, c := range c {
			left += abs(c) // 变完之后左右相同，变更颜色
		}
		Fprintln(out, ans+left/2) // 上面的每次变更都会配对一双袜子，所以要除以 2
	}
}

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


package main

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

func main() {
	var s int
	var err error
	reader := bufio.NewReaderSize(os.Stdin, 1024*1024)

	st := strings.Split(readLine(reader), " ")

	s, err = strconv.Atoi(st[0])
	if err != nil {
		panic(err)
	}

	var b [50][50]string

	// var t []string
	for line := 0; line < s; line++ {
		arTemp := string(readLine(reader))

		for arItr := 0; arItr < s; arItr++ {
			//t = append(t, string(arTemp[arItr]))
			b[line][arItr] = string(arTemp[arItr])
		}

	}

	for line := 0; line < s; line++ {
		for col := 0; col < s; col++ {
			if b[line][col] == "." {
				if line+2 < s && col-1 >= 0 && col+1 < s && b[line+1][col-1] == "." && b[line+1][col] == "." && b[line+1][col+1] == "." && b[line+2][col] == "." {
					b[line][col], b[line+1][col-1], b[line+1][col], b[line+1][col+1], b[line+2][col] = "#", "#", "#", "#", "#"
				} else {
					fmt.Print("NO")
					return
				}
			}
		}
	}
	fmt.Print("YES")
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

// Author: sighduck
// URL: https://codeforces.com/contest/1150/problem/B

package main

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

type Cell struct {
	X int
	Y int
}

func getPieceCells(i int, j int) []Cell {
	return []Cell{
		{X: i, Y: j},
		{X: i + 1, Y: j - 1},
		{X: i + 1, Y: j},
		{X: i + 1, Y: j + 1},
		{X: i + 2, Y: j},
	}
}

func isLegal(n int, i int, j int, cells [][]bool) bool {
	for _, cell := range getPieceCells(i, j) {
		if !(0 <= cell.X && cell.X < n) || !(0 <= cell.Y && cell.Y < n) || cells[cell.X][cell.Y] {
			return false
		}
	}
	return true
}

func Solve(n int, board []string) string {
	cells := make([][]bool, n)
	for i := 0; i < n; i++ {
		cells[i] = make([]bool, n)
		for j := 0; j < n; j++ {
			if string(board[i][j]) == "#" {
				cells[i][j] = true
			} else {
				cells[i][j] = false
			}
		}
	}
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if !cells[i][j] && isLegal(n, i, j, cells) {
				for _, cell := range getPieceCells(i, j) {
					cells[cell.X][cell.Y] = true
				}
			} else if !cells[i][j] {
				return "NO"
			}
		}
	}
	return "YES"
}

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

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

	fmt.Fprintf(writer, "%s\n", Solve(n, board))
}

package main

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

func main() {
	var s int
	var err error
	reader := bufio.NewReaderSize(os.Stdin, 1024*1024)

	st := strings.Split(readLine(reader), " ")

	s, err = strconv.Atoi(st[0])
	if err != nil {
		panic(err)
	}

	var b [50][50]string

	// var t []string
	for line := 0; line < s; line++ {
		arTemp := string(readLine(reader))

		for arItr := 0; arItr < s; arItr++ {
			//t = append(t, string(arTemp[arItr]))
			b[line][arItr] = string(arTemp[arItr])
			fmt.Println(b[line][arItr])
		}

	}

	for line := 0; line < s; line++ {
		for col := 0; col < s; col++ {
			fmt.Println(line, col)
			if b[line][col] == "." {
				if line+2 < s && col-1 >= 0 && col+1 < s && b[line+1][col-1] == "." && b[line+1][col] == "." && b[line+1][col+1] == "." && b[line+2][col] == "." {
					b[line][col], b[line+1][col-1], b[line+1][col], b[line+1][col+1], b[line+2][col] = "#", "#", "#", "#", "#"
				} else {
					fmt.Print("NO")
					return
				}
			}
		}
	}
	fmt.Print("YES")
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

// Author: sighduck
// URL: https://codeforces.com/contest/1150/problem/B

package main

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

type Cell struct {
	X int
	Y int
}

func getPieceCells(i int, j int) []Cell {
	return []Cell{
		{X: i, Y: i},
		{X: i + 1, Y: j - 1},
		{X: i + 1, Y: j},
		{X: i + 1, Y: j + 1},
		{X: i + 2, Y: j},
	}
}

func isLegal(n int, i int, j int, cells [][]bool) bool {
	for _, cell := range getPieceCells(i, j) {
		if !(0 <= cell.X && cell.X < n) || !(0 <= cell.Y && cell.Y < n) || cells[i][j] {
			return false
		}
	}
	return true
}

func Solve(n int, board []string) string {
	cells := make([][]bool, n)
	for i := 0; i < n; i++ {
		cells[i] = make([]bool, n)
		for j := 0; j < n; j++ {
			if string(board[i][j]) == "#" {
				cells[i][j] = true
			} else {
				cells[i][j] = false
			}
		}
	}
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if !cells[i][j] && isLegal(n, i, j, cells) {
				for _, cell := range getPieceCells(i, j) {
					cells[cell.X][cell.Y] = true
				}
			} else if !cells[i][j] {
				return "NO"
			}
		}
	}
	return "YES"
}

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

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

	fmt.Fprintf(writer, "%s\n", Solve(n, board))
}

// Author: sighduck
// URL: https://codeforces.com/contest/1150/problem/B

package main

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

type Cell struct {
	X int
	Y int
}

func getPieceCells(i int, j int) []Cell {
	return []Cell{
		{X: i, Y: j},
		{X: i + 1, Y: j - 1},
		{X: i + 1, Y: j},
		{X: i + 1, Y: j + 1},
		{X: i + 2, Y: j},
	}
}

func isLegal(n int, i int, j int, cells [][]bool) bool {
	for _, cell := range getPieceCells(i, j) {
		if !(0 <= cell.X && cell.X < n) || !(0 <= cell.Y && cell.Y < n) || cells[i][j] {
			return false
		}
	}
	return true
}

func Solve(n int, board []string) string {
	cells := make([][]bool, n)
	for i := 0; i < n; i++ {
		cells[i] = make([]bool, n)
		for j := 0; j < n; j++ {
			if string(board[i][j]) == "#" {
				cells[i][j] = true
			} else {
				cells[i][j] = false
			}
		}
	}
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if !cells[i][j] && isLegal(n, i, j, cells) {
				for _, cell := range getPieceCells(i, j) {
					cells[cell.X][cell.Y] = true
				}
			} else if !cells[i][j] {
				return "NO"
			}
		}
	}
	return "YES"
}

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

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

	fmt.Fprintf(writer, "%s\n", Solve(n, board))
}