package main

import (
	"fmt"
)

func main() {
	var n, x, l, r, c, res int

	c = 1

	fmt.Scan(&n, &x)

	for i := 0; i < n; i++ {
		fmt.Scan(&l, &r)

		c = c + ((l-c)/x)*x
		res += r + 1 - c
		c = r + 1
	}

	fmt.Println(res)
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var s int
	fmt.Scan(&s)
	a := make([][2]int, n)
	for i := range a {
		var p int
		fmt.Scan(&p)
		var q int
		fmt.Scan(&q)
		a[i] = [2]int{p, q}
	}
	c := 1
	dr := 0
	for _, p := range a {
		d := p[0] - c
		dr += p[1] - p[0] + 1 + (d % s)
		c = p[1] + 1
	}
	fmt.Println(dr)
}

package main

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

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

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

	n, x := nextInt(), nextInt()
	current := 1
	minute := 0

	for ; n > 0; n-- {
		l, r := nextInt(), nextInt() + 1

		for current + x <= l {
			current += x
		}

		minute += r - current
		current = r
	}

	println(minute)
}

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

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

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

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

package main

import (
	"fmt"
)

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

	var watch int = 0

	var pos int = 1
	var s, e int
	for i := 0; i < n; i++ {
		if _, err := fmt.Scanf("%d %d\n", &s, &e); err != nil {
			return
		}

		remain := (s - pos) % x
		watch += (remain + e - s + 1)

		pos = e + 1
	}

	fmt.Println(watch)
}

package main

import (
	"fmt"
)

var (
	n      int
	x      int
	left   []int
	right  []int
	result int
)

func in() {
	fmt.Scanf("%d %d\n", &n, &x)

	left = make([]int, n+1)
	right = make([]int, n+1)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d\n", &left[i+1], &right[i+1])
	}
}

func out() {
	fmt.Println(result)
}

func run() {
	result = 0
	left[0] = -1
	right[0] = 0
	for i := 1; i <= n; i++ {
		result += (left[i] - right[i-1] - 1) % x
		result += right[i] - left[i] + 1
	}
}

func main() {
	in()
	run()
	out()
}

package main

import "fmt"

// 1000
// 26.05.2020
// https://codeforces.com/problemset/problem/499/A
func main() {
	var n, x int
	fmt.Scanln(&n, &x)
	cur := 1
	var watched int
	for i := 0; i < n; i++ {
		var l, r int
		fmt.Scanln(&l, &r)

		watched += (l-cur)%x + r - l + 1
		cur = r + 1
	}
	fmt.Println(watched)
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var n, x, ans int
	fmt.Fscan(os.Stdin, &n, &x)
	cur := 1
	for i := 0; i < n; i++ {
		var l, r int
		fmt.Fscan(os.Stdin, &l, &r)
		ans += (l-cur)%x + r - l + 1
		cur = r + 1
	}
	fmt.Println(ans)
}

package main

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

func main() {
    bio := bufio.NewReader(os.Stdin)
    line, _, _ := bio.ReadLine()
    parts := strings.Split(string(line), " ")
    howManyBestPart, _ := strconv.ParseInt(parts[0], 10, 64)
    howLongSkip, _ := strconv.ParseInt(parts[1], 10, 64)

    minimunTimeMustBeSpent := 0
    for i, lastBestPartEndsHere := 0, 0; i < int(howManyBestPart); i++ {
        line, _, _ := bio.ReadLine()
        parts := strings.Split(string(line), " ")
        bestPartLeft, _ := strconv.ParseInt(parts[0], 10, 64)
        bestPartRight, _ := strconv.ParseInt(parts[1], 10, 64)

        howLongThisBestPartLast := int(bestPartRight) - int(bestPartLeft) + 1 // bound including
        howLongMustBeSeenWithoutSkip := (int(bestPartLeft) - 1 - lastBestPartEndsHere) % int(howLongSkip)
        minimunTimeMustBeSpent += howLongMustBeSeenWithoutSkip + howLongThisBestPartLast
        lastBestPartEndsHere = int(bestPartRight)
    }

    fmt.Println(minimunTimeMustBeSpent)
}

package main

import (
	"fmt"
)

func main() {
	var n, x int
	var l, r [50]int
	fmt.Scan(&n, &x)
	for i := 0; i < n; i++ {
		fmt.Scan(&l[i], &r[i])
	}

	z := 0
	for i, t := 0, 1; i < n; i++ {
		d := l[i] - t
		z += d%x + r[i] - l[i] + 1
		t = r[i] + 1
	}
	fmt.Println(z)
}

package main

import "fmt"

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	point := 1
	r := 0
	for i := 0; i < n; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		for ; a-point >= x; point += x {
		}
		r += b - point + 1
		point = b + 1
	}
	fmt.Println(r)
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var s int
	fmt.Scan(&s)
	a := make([][2]int, n)
	for i := range a {
		var p int
		fmt.Scan(&p)
		var q int
		fmt.Scan(&q)
		a[i] = [2]int{p, q}
	}
	c := 0
	dr := 0
	for _, p := range a {
		d := p[0] - c
		dr += p[1] - p[0] + (d % s)
		c = p[1]
	}
	fmt.Println(dr)
}

package main

import (
	"fmt"
)

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

	var watch int = 0

	var pos int = 1
	var s, e int
	for i := 0; i < n; i++ {
		if _, err := fmt.Scanf("%d %d\n", &s, &e); err != nil {
			return
		}

		remain := (s - pos) % x
		watch += (remain + e - s + 1)
	}

	fmt.Println(watch)
}

package main

import (
	"fmt"
)

var (
	n      int
	x      int
	left   []int
	right  []int
	result int
)

func in() {
	fmt.Scanf("%d %d\n", &n, &x)

	left = make([]int, n+1)
	right = make([]int, n+1)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d\n", &left[i+1], &right[i+1])
	}
}

func out() {
	fmt.Println(result)
}

func run() {
	result = 0
	left[0] = -1
	right[0] = 0
	for i := 1; i < n; i++ {
		result += (left[i] - right[i-1] - 1) % x
		result += right[i] - left[i] + 1
	}
}

func main() {
	in()
	run()
	out()
}

package main

import (
	"fmt"
)

type Moment struct {
	Left  int
	Right int
}

func (m *Moment) getDuration() int {
	return m.Right - m.Left + 1
}

var (
	n       int
	x       int
	moments []Moment
	result  int
)

func in() {
	fmt.Scanf("%d %d\n", &n, &x)
	for i := 0; i < n; i++ {
		var l, r int
		fmt.Scanf("%d %d", &l, &r)
		moments = append(moments, Moment{l, r})
	}
}

func out() {
	fmt.Println(result)
}

func run() {
	result = (moments[0].Left-1)%x + moments[0].getDuration()
	for i := 1; i < n; i++ {
		result += (moments[i].Left - moments[i-1].Right - 1) % x
		result += moments[i].getDuration()
	}
}

func main() {
	in()
	run()
	out()
}

package main

import (
	"fmt"
)

var (
	n      int
	x      int
	left   []int
	right  []int
	result int
)

func in() {
	fmt.Scanf("%d %d\n", &n, &x)

	left = make([]int, n+1)
	right = make([]int, n+1)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d", &left[i+1], &right[i+1])
	}
}

func out() {
	fmt.Println(result)
}

func run() {
	result = 0
	left[0] = -1
	right[0] = 0
	for i := 1; i < n; i++ {
		result += (left[i] - right[i-1] - 1) % x
		result += right[i] - left[i] + 1
	}
}

func main() {
	in()
	run()
	out()
}

package main

import (
	"fmt"
)

type Moment struct {
	Left  int
	Right int
}

func (m *Moment) getDuration() int {
	return m.Right - m.Left + 1
}

var (
	n       int
	x       int
	moments []Moment
	result  int
)

func in() {
	fmt.Scanf("%d %d\n", &n, &x)
	for i := 0; i < n; i++ {
		m := new(Moment)
		fmt.Scanf("%d %d", &m.Left, &m.Right)
		moments = append(moments, *m)
	}
}

func out() {
	fmt.Println(result)
}

func run() {
	result = (moments[0].Left-1)%x + moments[0].getDuration()
	for i := 1; i < n; i++ {
		result += (moments[i].Left - moments[i-1].Right - 1) % x
		result += moments[i].getDuration()
	}
}

func main() {
	in()
	run()
	out()
}

package main

import "fmt"

// 1000
// 26.05.2020
// https://codeforces.com/problemset/problem/499/A
func main() {
	var n, x int
	fmt.Scanln(&n, &x)
	var watched, cur int
	for i := 0; i < n; i++ {
		var l, r int
		fmt.Scanln(&l, &r)

		watched += (l-cur)%x + r - l
		cur = r
	}
	fmt.Println(watched)
}

package main

import "fmt"

func main() {
    howManyBestPart := -1
    howLongSkip := -1
    fmt.Scanf("%d %d", &howManyBestPart, &howLongSkip)

    minimunTimeMustBeSpent := 0
    for i, lastBestPartEndsHere := 0, 0; i < howManyBestPart; i++ {
        bestPartLeft, bestPartRight := -1, -1
        fmt.Scanf("%d %d", &bestPartLeft, &bestPartRight)

        howLongThisBestPartLast := bestPartRight - bestPartLeft + 1 // bound including
        howLongMustBeSeenWithoutSkip := (bestPartLeft - 1 - lastBestPartEndsHere) % howLongSkip
        minimunTimeMustBeSpent = minimunTimeMustBeSpent + howLongMustBeSeenWithoutSkip + howLongThisBestPartLast
        lastBestPartEndsHere = bestPartRight
    }

    fmt.Println(minimunTimeMustBeSpent)
}

package main

import "fmt"

func main() {
    howManyBestPart := -1
    howLongSkip := -1
    fmt.Scanf("%d %d", &howManyBestPart, &howLongSkip)

    minimunTimeMustBeSpent := 0
    for i, lastBestPartEndsHere := 0, 0; i < howManyBestPart; i++ {
        bestPartLeft, bestPartRight := -1, -1
        fmt.Scanf("%d %d", &bestPartLeft, &bestPartRight)

        howLongThisBestPartLast := bestPartRight - bestPartLeft + 1 // bound including
        howLongMustBeSeenWithoutSkip := (bestPartLeft - 1 - lastBestPartEndsHere) % howLongSkip
        minimunTimeMustBeSpent += howLongMustBeSeenWithoutSkip + howLongThisBestPartLast
        lastBestPartEndsHere = bestPartRight
    }

    fmt.Println(minimunTimeMustBeSpent)
}

package main

import "fmt"

func main() {
    howManyBestPart := -1
    howLongSkip := -1
    fmt.Scanf("%d %d", &howManyBestPart, &howLongSkip)

    minimunTimeMustBeSpent := 0
    lastBestPartEndsHere := 0
    for i := 0; i < howManyBestPart; i++ {
        bestPartLeft, bestPartRight := -1, -1
        fmt.Scanf("%d %d", &bestPartLeft, &bestPartRight)

        howLongThisBestPartLast := bestPartRight - bestPartLeft + 1 // bound including
        howLongMustBeSeenWithoutSkip := (bestPartLeft - 1 - lastBestPartEndsHere) % howLongSkip
        minimunTimeMustBeSpent = minimunTimeMustBeSpent + howLongMustBeSeenWithoutSkip + howLongThisBestPartLast
        lastBestPartEndsHere = bestPartRight
    }

    fmt.Println(minimunTimeMustBeSpent)
}

package main

import "fmt"

func main() {
    howManyBestPart := -1
    howLongSkip := -1
    fmt.Scanf("%d %d", &howManyBestPart, &howLongSkip)

    minimunTimeMustBeSpent := 0
    for i, lastBestPartEndsHere := 0, 0; i < howManyBestPart; i++ {
        bestPartLeft, bestPartRight := -1, -1
        //fmt.Scanf("%d %d", &bestPartLeft, &bestPartRight)
        fmt.Scanf("%d", &bestPartLeft)
        fmt.Scanf("%d", &bestPartRight)

        howLongThisBestPartLast := bestPartRight - bestPartLeft + 1 // bound including
        howLongMustBeSeenWithoutSkip := (bestPartLeft - 1 - lastBestPartEndsHere) % howLongSkip
        minimunTimeMustBeSpent += howLongMustBeSeenWithoutSkip + howLongThisBestPartLast
        lastBestPartEndsHere = bestPartRight
    }

    fmt.Println(minimunTimeMustBeSpent)
}

package main

import (
	"fmt"
)

func main() {
	var n, x int
	var l, r [50]int
	fmt.Scan(&n, &x)
	for i := 0; i < n; i++ {
		fmt.Scan(&l[i], &r[i])
	}

	z := 0
	for i, t := 0, 1; i < n; i++ {
		d := l[i] - t
		z += d%x + r[i] - l[i]
		t = r[i]
	}
	fmt.Println(z + 1)
}


package main

import (
	"bufio"
	"container/heap"
	. "fmt"
	"math"
	"os"
)

type Int int64

const (
	INF = 3e5 + 10
	L0  = Int(0)
	L1  = Int(1)
)

type Segment struct {
	l, r, val, add, minIndex Int
}

type SegTree struct {
	st []Segment
}

func (segTree SegTree) Build(x, l, r Int) {
	segTree.st[x].l = l
	segTree.st[x].r = r
	if l == r {
		segTree.st[x].minIndex = l
		return
	}
	mid := (l + r) >> 1
	segTree.Build(x<<1, l, mid)
	segTree.Build(x<<1|1, mid+1, r)
}

func (segTree SegTree) push(x Int) {
	if segTree.st[x].add != 0 {
		segTree.modifyOne(x<<1, segTree.st[x].add)
		segTree.modifyOne(x<<1|1, segTree.st[x].add)
		segTree.st[x].add = 0
	}
}

func (segTree SegTree) update(x Int) {
	if segTree.st[x<<1].val < segTree.st[x<<1|1].val {
		segTree.st[x].val = segTree.st[x<<1].val
		segTree.st[x].minIndex = segTree.st[x<<1].minIndex
	} else {
		segTree.st[x].val = segTree.st[x<<1|1].val
		segTree.st[x].minIndex = segTree.st[x<<1|1].minIndex
	}
}

func (segTree SegTree) modifyOne(x, add Int) {
	segTree.st[x].val += add
	if segTree.st[x].l != segTree.st[x].r {
		segTree.st[x].add += add
	}
}

func (segTree SegTree) Modify(x, l, r, add Int) {
	if segTree.st[x].l >= l && segTree.st[x].r <= r {
		segTree.modifyOne(x, add)
		return
	}
	segTree.push(x)
	mid := (segTree.st[x].l + segTree.st[x].r) >> 1
	if mid >= l {
		segTree.Modify(x<<1, l, r, add)
	}
	if mid < r {
		segTree.Modify(x<<1|1, l, r, add)
	}
	segTree.update(x)
}

func updateRes(cRes, cIndex, res, index Int) (Int, Int) {
	if cRes > res {
		return res, index
	}
	return cRes, cIndex
}

func (segTree SegTree) Query(x, l, r Int) (Int, Int) {
	res := Int(math.MaxInt64)
	resInd := -L1
	if segTree.st[x].l >= l && segTree.st[x].r <= r {
		res, resInd = updateRes(res, resInd, segTree.st[x].val, segTree.st[x].minIndex)
		return res, resInd
	}
	mid := (segTree.st[x].l + segTree.st[x].r) >> 1
	if mid >= l {
		sonRes, sonInd := segTree.Query(x<<1, l, r)
		res, resInd = updateRes(res, resInd, sonRes, sonInd)
	}
	if mid < r {
		sonRes, sonInd := segTree.Query(x<<1|1, l, r)
		res, resInd = updateRes(res, resInd, sonRes, sonInd)
	}
	return res, resInd
}

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

	var T int
	Fscan(in, &T)

	for tt := 0; tt < T; tt++ {
		var n, k Int
		Fscan(in, &n, &k)

		segTree := SegTree{make([]Segment, n<<2)}
		segTree.Build(1, 1, n)

		ans := L0
		for i := L1; i <= n; i++ {
			var x Int
			Fscan(in, &x)
			segTree.Modify(1, i, i, n-i-x)
			ans += x
		}

		for k > 0 {
			mi, index := segTree.Query(1, 1, n)
			if mi < 0 {
				ans += mi
				segTree.Modify(1, index, index, math.MaxInt64>>1)
				segTree.Modify(1, 1, n, -1)
				k--
			} else {
				break
			}
		}
		Fprintln(out, ans)
	}

}

func MakeGrid(h, w int) [][]Int {
	index := make([][]Int, h)
	data := make([]Int, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

func Abs(x Int) Int {
	if x > 0 {
		return x
	}
	return -x
}

func Min(nums ...Int) Int {
	return nums[MinIdx(nums...)]
}

func MinIdx(nums ...Int) Int {
	maxNumIdx := L0
	for i, num := range nums {
		if num < nums[maxNumIdx] {
			maxNumIdx = Int(i)
		}
	}
	return maxNumIdx
}

func Max(nums ...Int) Int {
	return nums[MaxIdx(nums...)]
}

func MaxIdx(nums ...Int) Int {
	maxNumIdx := L0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = Int(i)
		}
	}
	return maxNumIdx
}

var (
	mod  Int
	fmod func(Int) Int = doNothing
)

// SetMod sets the mod. It must be called first.
func SetMod(newMod Int) {
	mod = newMod
	fmod = dynamicMod
}

func dynamicMod(m Int) Int {
	m %= mod
	if m < 0 {
		return m + mod
	}
	return m
}

func doNothing(m Int) Int {
	return m
}

// Mod returns m % mod.
func (m Int) Mod() Int {
	return fmod(m)
}

// Inv returns modular multiplicative inverse
func (m Int) Inv() Int {
	return m.Pow(Int(0).Sub(2))
}

// Pow returns m^n
func (m Int) Pow(n Int) Int {
	p := Int(1)
	for n > 0 {
		if n&1 == 1 {
			p.MulAs(m)
		}
		m.MulAs(m)
		n >>= 1
	}
	return p
}

// Add returns m+x
func (m Int) Add(x Int) Int {
	return (m + x).Mod()
}

// Sub returns m-x
func (m Int) Sub(x Int) Int {
	return (m - x).Mod()
}

// Mul returns m*x
func (m Int) Mul(x Int) Int {
	return (m * x).Mod()
}

// Div returns m/x
func (m Int) Div(x Int) Int {
	return m.Mul(x.Inv())
}

// AddAs assigns *m + x to *m and returns m
func (m *Int) AddAs(x Int) *Int {
	*m = m.Add(x)
	return m
}

// SubAs assigns *m - x to *m and returns m
func (m *Int) SubAs(x Int) *Int {
	*m = m.Sub(x)
	return m
}

// MulAs assigns *m * x to *m and returns m
func (m *Int) MulAs(x Int) *Int {
	*m = m.Mul(x)
	return m
}

// DivAs assigns *m / x to *m and returns m
func (m *Int) DivAs(x Int) *Int {
	*m = m.Div(x)
	return m
}

func (m *Int) MaxAs(x ...Int) *Int {
	*m = Max(append(x, *m)...)
	return m
}

func (m *Int) MinAs(x ...Int) *Int {
	*m = Min(append(x, *m)...)
	return m
}

// An Item is something we manage in a priority queue.
type Item struct {
	value    string // The value of the item; arbitrary.
	priority int    // The priority of the item in the queue.
	// The index is needed by update and is maintained by the heap.Interface methods.
	index int // The index of the item in the heap.
}

// A PriorityQueue implements heap.Interface and holds Items.
type PriorityQueue []*Item

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

func (pq PriorityQueue) Less(i, j int) bool {
	// We want Pop to give us the highest, not lowest, priority so we use greater than here.
	return pq[i].priority > pq[j].priority
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

// update modifies the priority and value of an Item in the queue.
func (pq *PriorityQueue) update(item *Item, value string, priority int) {
	item.value = value
	item.priority = priority
	heap.Fix(pq, item.index)
}

package main

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

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

	var T, n, k int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &k)
		ori := make([]int, n)
		type pair struct{ v, i int }
		a := make([]pair, n)
		for i := range a {
			Fscan(in, &ori[i])
			a[i] = pair{ori[i] + i, i}
		}
		sort.Slice(a, func(i, j int) bool { return a[i].v > a[j].v })
		del := make([]bool, n)
		for _, p := range a[:k] {
			del[p.i] = true
		}
		ans, ex := int64(0), 0
		for i, b := range del {
			if b {
				ex++
			} else {
				ans += int64(ori[i] + ex)
			}
		}
		Fprintln(out, ans)
	}
}

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

package main

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

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

	var T, n, k int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &k)
		ori := make([]int, n)
		type pair struct{ v, i int }
		a := make([]pair, n)
		for i := range a {
			Fscan(in, &ori[i])
			a[i] = pair{ori[i], i}
		}
		sort.Slice(a, func(i, j int) bool { return a[i].v+a[i].i > a[j].v+a[j].i })
		del := make([]bool, n)
		for _, p := range a[:k] {
			del[p.i] = true
		}
		ans, ex := int64(0), 0
		for i, b := range del {
			if b {
				ex++
			} else {
				ans += int64(ori[i] + ex)
			}
		}
		Fprintln(out, ans)
	}
}

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

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int     { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }
func gi2() (int,int) { return gi(),gi() }
func gi3() (int,int,int) { return gi(),gi(),gi() }
func gi4() (int,int,int,int) { return gi(),gi(),gi(),gi() }
func gis(n int) []int  { res := make([]int,n); for i:=0;i<n;i++ { res[i] = gi() }; return res }
func gf() float64 { f,e := strconv.ParseFloat(gs(),64); if e != nil {panic(e)}; return f }
func gbs() []byte { return []byte(gs()) }
func gfs(n int) []float64  { res := make([]float64,n); for i:=0;i<n;i++ { res[i] = gf() }; return res }
func gss(n int) []string  { res := make([]string,n); for i:=0;i<n;i++ { res[i] = gs() }; return res }
func ia(m int) []int { return make([]int,m) }
func iai(m int,v int) []int { a := make([]int,m); for i:=0;i<m;i++ { a[i] = v }; return a }
func twodi(n int,m int,v int) [][]int {
	r := make([][]int,n); for i:=0;i<n;i++ { x := make([]int,m); for j:=0;j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill2(m int) ([]int,[]int) { a,b := ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i] = gi(),gi()}; return a,b }
func fill3(m int) ([]int,[]int,[]int) { a,b,c := ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i] = gi(),gi(),gi()}; return a,b,c }
func fill4(m int) ([]int,[]int,[]int,[]int) { a,b,c,d := ia(m),ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i],d[i] = gi(),gi(),gi(),gi()}; return a,b,c,d }
func abs(a int) int { if a < 0 { return -a }; return a }
func rev(a []int) { i,j := 0,len(a)-1; for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max(a,b int) int { if a > b { return a }; return b }
func min(a,b int) int { if a > b { return b }; return a }
func tern(cond bool, a int, b int) int { if cond { return a }; return b }
func terns(cond bool, a string, b string) string { if cond { return a }; return b }
func maxarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr(a []int) int { ans := 0; for _,aa := range(a) { ans += aa }; return ans }
func zeroarr(a []int) { for i:=0; i<len(a); i++ { a[i] = 0 } }
func powmod(a,e,mod int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint(a,e int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd(a,b int) int { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended(a,b int) (int,int,int) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv(a,m int) (int,bool) { g,x,_ := gcdExtended(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func makefact(n int,mod int) ([]int,[]int) {
	fact,factinv := make([]int,n+1),make([]int,n+1)
	fact[0] = 1; for i:=1;i<=n;i++ { fact[i] = fact[i-1] * i % mod }
	factinv[n] = powmod(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * (i+1) % mod }
	return fact,factinv
}
func vecintstring(a []int) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.Itoa(a) }; return strings.Join(astr," ") }
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	// We are always going to jump over K traps (e.g. jumping over the last K traps is free)
	// To make the math easy, we first assume we will take damage from ALL subsequent traps (even the ones we jump over)
	// The undercount of the savings is always K choose 2 which we can deal with at the end
	// This allows us to be greedy
	T := gi()
	for tt:=1;tt<=T;tt++ {
		N,K := gi(),gi(); A := gis(N)
		suma := int64(0); for _,a := range A { suma += int64(a) }
		savea := ia(N); for i:=0;i<N;i++ { savea[i] = A[i] - (N-i-1) }
		sort.Slice(savea,func(i,j int) bool { return savea[i] > savea[j] } )
		sumsavea := int64(K) * int64(K-1) / 2;  for i:=0;i<K;i++ { sumsavea += int64(savea[i]) }
		ans := suma-sumsavea
		fmt.Fprintln(wrtr,ans)
	}
}

package main

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

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

		var sum int64
		arr := make([]int64, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &arr[i])
			sum += arr[i]
			arr[i] += int64(i) + 1
		}

		sort.Slice(arr, func(i, j int) bool {
			return arr[i] > arr[j]
		})
		for i := 0; i < k; i++ {
			sum -= arr[i]
			sum += int64(n)
			sum -= int64(i)
		}

		fmt.Fprintln(out, sum)
	}
}

package main

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

// This example demonstrates an integer heap built using the heap interface.

// An IntHeap is a min-heap of ints.
/* type IntHeap []int64

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

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int64))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}
*/

// // This example inserts several ints into an Int, checks the minimum,
// // and removes them in order of priority.
// func main() {
// 	h := &IntHeap{2, 1, 5}
// 	heap.Init(h)
// 	heap.Push(h, 3)
// 	fmt.Printf("minimum: %d\n", (*h)[0])
// 	for h.Len() > 0 {
// 		fmt.Printf("%d ", heap.Pop(h))
// 	}
// }
type ts struct {
	idx int
	d   int
}

func A2() {
	_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()
	// Coding...beg!
	sol = func() {
		var n, k int
		Fscan(in, &n, &k)
		dam := make([]int, n)
		ct := make([]ts, n)
		for i := 0; i < n; i++ {
			Fscan(in, &dam[i])
			ct[i] = ts{i, dam[i] - (n - i - 1)}
		}
		sort.Slice(ct, func(i, j int) bool {
			if ct[i].d == ct[j].d {
				return ct[i].idx > ct[j].idx
			}
			return ct[i].d > ct[j].d
		})
		jump := make([]int, k)
		for i := 0; i < k; i++ {
			jump[i] = ct[i].idx
		}
		sort.Ints(jump)
		var ans int64
		for i, j := n-1, k-1; i >= 0; i-- {
			if j >= 0 && i == jump[j] {
				j--
				// jump

			} else {
				ans += int64(dam[i])
				ans += int64(j + 1)
			}
		}
		Fprintln(out, ans)
	}
	// Coding...ove!
	for i := 0; i < cas; i++ {
		sol()
	}
}

func main() { A2() }


package main

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

func isOdd(a int) bool {
	if a&1 == 1 {
		return true
	}
	return false
}

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		cntOdd, cntEven := 0, 0
		n, x := 0, 0
		fmt.Fscan(in, &n, &x)
		for ; n > 0; n-- {
			a := 0
			fmt.Fscan(in, &a)
			if isOdd(a) {
				cntOdd++
			} else {
				cntEven++
			}
		}
		gapOdd := x - min(x, cntEven)

		if !isOdd(gapOdd) {
			if gapOdd != x && cntOdd > gapOdd {
				fmt.Fprintln(out, "Yes")
				continue
			}
		} else {
			if cntOdd > 0 {
				fmt.Fprintln(out, "Yes")
				continue
			}
		}
		fmt.Fprintln(out, "No")
	}
}

package main

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

func isOdd(a int) bool {
	if a&1 == 1 {
		return true
	}
	return false
}

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		cntOdd, cntEven := 0, 0
		n, x := 0, 0
		fmt.Fscan(in, &n, &x)
		for ; n > 0; n-- {
			a := 0
			fmt.Fscan(in, &a)
			if isOdd(a) {
				cntOdd++
			} else {
				cntEven++
			}
		}
		gapOdd := x - min(x, cntEven)
		if isOdd(gapOdd) && cntOdd > 0 || x > gapOdd && gapOdd < cntOdd {
			fmt.Fprintln(out, "Yes")
		} else {
			fmt.Fprintln(out, "No")
		}
	}
}

package main

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

func isOdd(a int) bool {
	if a&1 == 1 {
		return true
	}
	return false
}

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		cntOdd, cntEven := 0, 0
		n, x := 0, 0
		fmt.Fscan(in, &n, &x)
		for ; n > 0; n-- {
			a := 0
			fmt.Fscan(in, &a)
			if isOdd(a) {
				cntOdd++
			} else {
				cntEven++
			}
		}
		gapOdd := x - min(x, cntEven)

		if !isOdd(gapOdd) {
			if gapOdd != x && cntOdd > gapOdd {
				fmt.Fprintln(out, "Yes")
				continue
			}
		} else if cntOdd > 0 {
			fmt.Fprintln(out, "Yes")
			continue
		}
		fmt.Fprintln(out, "No")
	}
}

package main

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

func isOdd(a int) bool {
	if a&1 == 1 {
		return true
	}
	return false
}

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		cntOdd, cntEven := 0, 0
		n, x := 0, 0
		fmt.Fscan(in, &n, &x)
		for ; n > 0; n-- {
			a := 0
			fmt.Fscan(in, &a)
			if isOdd(a) {
				cntOdd++
			} else {
				cntEven++
			}
		}
		gapOdd := x - min(x, cntEven)
		if isOdd(gapOdd) && cntOdd > 0 {
			fmt.Fprintln(out, "Yes")
			continue
		} else if x > gapOdd && gapOdd < cntOdd {
			fmt.Fprintln(out, "Yes")
			continue
		}
		fmt.Fprintln(out, "No")
	}
}

package main

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

func isOdd(a int) bool {
	if a&1 == 1 {
		return true
	}
	return false
}

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		cntOdd, cntEven := 0, 0
		n, x := 0, 0
		fmt.Fscan(in, &n, &x)
		for ; n > 0; n-- {
			a := 0
			fmt.Fscan(in, &a)
			if isOdd(a) {
				cntOdd++
			} else {
				cntEven++
			}
		}
		//gapOdd := x - cntEven
		gapOdd := x - min(x, cntEven)

		if !isOdd(gapOdd) {
			if gapOdd != x && cntOdd > gapOdd {
				fmt.Fprintln(out, "Yes")
			} else {
				fmt.Fprintln(out, "No")
			}
		} else {
			if cntOdd > 0 {
				fmt.Fprintln(out, "Yes")
			} else {
				fmt.Fprintln(out, "No")
			}
		}
	}
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var t int
	fmt.Fscan(r, &t)
	for ; t > 0; t-- {
		var n, x int
		fmt.Fscan(r, &n, &x)
		var odd, even int
		for i := 0; i < n; i++ {
			var a int
			fmt.Fscan(r, &a)
			if a%2 == 1 {
				odd++
			} else {
				even++
			}
		}
		if odd == 0 {
			fmt.Fprintln(w, "No")
			continue
		}
		if odd%2 == 0 && x == n {
			fmt.Fprintln(w, "No")
			continue
		}
		if x%2 == 0 {
			if even > 0 {
				fmt.Fprintln(w, "Yes")
			} else {
				fmt.Fprintln(w, "No")
			}
		} else {
			fmt.Fprintln(w, "Yes")
		}
	}
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var t int
	fmt.Fscan(r, &t)
	for ; t > 0; t-- {
		var n, x int
		fmt.Fscan(r, &n, &x)
		var odd, even int
		for i := 0; i < n; i++ {
			var a int
			fmt.Fscan(r, &a)
			if a%2 == 1 {
				odd++
			} else {
				even++
			}
		}
		if odd == 0 {
			fmt.Fprintln(w, "No")
			continue
		}
		if odd == n && x%2 == 0 {
			fmt.Fprintln(w, "No")
			continue
		}
		if odd%2 == 0 && x == n {
			fmt.Fprintln(w, "No")
			continue
		}
		fmt.Fprintln(w, "Yes")
	}
}

package main

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

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
}

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

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n, x := readTwoNums(reader)
		A := readNNums(reader, n)
		res := solve(n, x, A)
		if res {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

func solve(n int, x int, A []int) bool {
	var odd int
	for i := 0; i < n; i++ {
		odd += A[i] & 1
	}

	if odd == 0 {
		return false
	}

	if x == n {
		return odd&1 == 1
	}
	// a + b = x & a is odd

	// 1, 1, 0, 0, 0, 0
	// x = 5
	if odd <= x {
		return true
	}
	// odd > x
	if x&1 == 1 {
		return true
	}
	// x is even, need at least one 0
	return odd < n
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		n, m := 0, 0
		fmt.Fscanf(in, "%d %d\n", &n, &m)
		a := make([]int, n)
		odd := 0
		even := 0
		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d", &a[i])
			if a[i]%2 == 1 {
				odd++
			} else {
				even++
			}
		}
		fmt.Fscanf(in, "\n")
		if odd < 1 {
			fmt.Fprintf(out, "No\n")
		} else {
			if m == n && odd%2 == 0 {
				fmt.Fprintf(out, "No\n")
			} else if m%2 == 0 && even == 0 {
				fmt.Fprintf(out, "No\n")
			} else {
				fmt.Fprintf(out, "Yes\n")
			}
		}
	}
	return
}

/*
URL:
https://codeforces.com/problemset/problem/1363/A
*/

package main

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

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

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

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

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

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

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

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

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

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

var (
	t int

	n, x int
	A    []int
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		n, x = ReadInt2()
		A = ReadIntSlice(n)

		solve()
	}
}

func solve() {
	for i := 0; i < n; i++ {
		A[i] = A[i] % 2
	}
	sort.SliceStable(A, func(i, j int) bool { return A[i] < A[j] })
	// PrintfDebug("%v\n", A)

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

	for i := 0; i+x <= n; i++ {
		s := S[i+x] - S[i]
		if s%2 == 1 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

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

/*********** 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"
	"os"
)

var nTest, n, x, a int

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

	fmt.Fscan(in, &nTest)
	for t := 0; t < nTest; t++ {
		fmt.Fscan(in, &n, &x)
		odd := 0
		even := 0

		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a)
			if a&1 == 0 {
				even++
			} else {
				odd++
			}
		}

		odd--
		if odd < 0 {
			fmt.Fprintln(out, "No")
			continue
		}

		if x&1 == 0 {
			even--

			if even < 0 {
				fmt.Fprintln(out, "No")
				continue
			}
		}

		if (x-1)/2 > (odd/2 + even/2) {
			fmt.Fprintln(out, "No")
			continue
		}

		fmt.Fprintln(out, "Yes")
	}

	out.Flush()
}

package main

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

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

	var t, n, x, v int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &x)
		c := [2]int{}
		for i := 0; i < n; i++ {
			Fscan(in, &v)
			c[v&1]++
		}
		if c[1] == 0 || c[0] == 0 && x&1 == 0 || x == n && c[1]&1 == 0 {
			Fprintln(out, "No")
		} else {
			Fprintln(out, "Yes")
		}
	}
}

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

package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		fmt.Println(solver())
	}
}

func no() string {
	return "No"
}
func yes() string {
	return "Yes"
}
func solver() string {
	var n, x, tmp, odd, even int
	fmt.Fscan(input, &n, &x)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &tmp)
		if tmp & 1 > 0 {
			odd++
		} else {
			even++
		}
	}
	odd--
	x--
	if odd < 0  {
		return no()
	}
	x -= min(x,odd)/2*2
	//fmt.Println("X is:", x, odd, even)
	if x <= even {return yes()}
	return no()
}

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

package main
import (
        "fmt"
        "os"
        "bufio"
)
func main(){
    var t, n, x, even, odd, tmp int
    var ans bool
    in := bufio.NewReader(os.Stdin)
    fmt.Fscan(in, &t)
    for ; t > 0; t-- {
        fmt.Fscan(in, &n, &x)
        even, odd = 0, 0
        for i:=0; i < n; i++ {
            fmt.Fscan(in, &tmp)
            if tmp % 2 == 0 {
                even++
            } else {
                odd++
            }
        }
        ans = false
        for i := 1; i <= odd; i+=2 {
            if z := x-i; z >= 0 && z <= even {
                ans = true
                break
            }
        }
        if ans {
            fmt.Println("Yes")
        } else {
            fmt.Println("No")
        }
    }
}

package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		fmt.Println(solver())
	}
}

func no() string {
	return "No"
}
func yes() string {
	return "Yes"
}
func solver() string {
	var n, x, tmp, odd, even int
	fmt.Fscan(input, &n, &x)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &tmp)
		if tmp & 1 > 0 {
			odd++
		} else {
			even++
		}
	}
	odd--
	x--
	if odd < 0  {
		return no()
	}
	x -= (min(x,odd)>>1)<<1
	//fmt.Println("X is:", x, odd, even)
	if x <= even {return yes()}
	return no()
}

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

package main

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

func readInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	res, _ := strconv.Atoi(scanner.Text())
	return res
}

func readIntSlice(scanner *bufio.Scanner) []int {
	scanner.Scan()
	nums := strings.Split(scanner.Text(), " ")
    var r []int
    for _, v := range nums {
        i, _ := strconv.Atoi(v)
        r = append(r, i)
    }
    return r
}

func main() {
	var q int
	scanner := bufio.NewScanner(os.Stdin)
	q = readInt(scanner)
	//fmt.Println(q)
	for qq := 0; qq < q; qq++ {
		sum := 0
		tmp := readIntSlice(scanner)
		n := tmp[0]
		x := tmp[1]
		haveOdd := false
		haveEven := false
		a := readIntSlice(scanner)
		for i := 0; i < n; i++ {
			if a[i] % 2 == 0 {
				haveEven = true
			} else {
				haveOdd = true
			}
			sum += a[i]
		}
		if !haveOdd {
			fmt.Println("No")
		} else if !haveEven {
			if x % 2 == 1 {
				fmt.Println("Yes")
			} else {
				fmt.Println("No")
			}
		} else {
			if x == n && sum % 2 == 0 {
				fmt.Println("No")
			} else {
				fmt.Println("Yes")
			}
		}
	}
}

package main

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

func main() {
	t := nextInt()
	for i := 0; i < t; i++ {
		if answer() {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

func answer() bool {
	n, x := nextInt(), nextInt()

	oddCount := 0
	evenCount := 0
	for i := 0; i < n; i++ {
		a := nextInt()
		if a%2 == 1 {
			oddCount++
		} else {
			evenCount++
		}
	}

	for i:=1; i <= x; i+=2 {
		if oddCount >= i {
			if evenCount + i >= x {
				return true
			}
		}
	}
	return false
}

var sc = bufio.NewScanner(os.Stdin)

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

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

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

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

package main

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

func main() {
	t := nextInt()
	for i := 0; i < t; i++ {
		if answer() {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

func answer() bool {
	n, x := nextInt(), nextInt()

	oddCount := 0
	evenCount := 0
	for i := 0; i < n; i++ {
		a := nextInt()
		if a%2 == 1 {
			oddCount++
		} else {
			evenCount++
		}
	}

	for i := 1; i <= x; i += 2 {
		if oddCount >= i {
			if evenCount+i >= x {
				return true
			}
		}
	}
	return false
}

var sc = bufio.NewScanner(os.Stdin)

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

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

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

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		var n, x int
		fmt.Fscan(in, &n, &x)
		cntEven := 0
		cntOdd := 0
		var a int
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a)
			if a%2 == 0 {
				cntEven++
			} else {
				cntOdd++
			}
		}
		x -= cntEven
		if cntOdd > 0 && (x < cntOdd && cntEven > 0 || x%2 != 0) {
			fmt.Fprintln(out, "Yes")
		} else {
			fmt.Fprintln(out, "No")
		}
	}
}

package main

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

func isOdd(a int) bool {
	if a&1 == 1 {
		return true
	}
	return false
}

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		cntOdd, cntEven := 0, 0
		n, x := 0, 0
		fmt.Fscan(in, &n, &x)
		for ; n > 0; n-- {
			a := 0
			fmt.Fscan(in, &a)
			if isOdd(a) {
				cntOdd++
			} else {
				cntEven++
			}
		}

		gapOdd := x - min(x, cntEven)
		if isOdd(gapOdd) && cntOdd > 0 || x > gapOdd && gapOdd < cntOdd {
			fmt.Fprintln(out, "Yes")
			continue
		}
		fmt.Fprintln(out, "No")
	}
}

package main

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

func isOdd(a int) bool {
	if a&1 == 1 {
		return true
	}
	return false
}

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		cntOdd, cntEven := 0, 0
		n, x := 0, 0
		fmt.Fscan(in, &n, &x)
		for ; n > 0; n-- {
			a := 0
			fmt.Fscan(in, &a)
			if isOdd(a) {
				cntOdd++
			} else {
				cntEven++
			}
		}
		gapOdd := x - min(x, cntEven)
		if !isOdd(gapOdd) {
			if gapOdd < x && cntOdd > gapOdd {
				fmt.Fprintln(out, "Yes")
				continue
			}
		} else if cntOdd > 0 {
			fmt.Fprintln(out, "Yes")
			continue
		}
		fmt.Fprintln(out, "No")
	}
}

package main

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

func isOdd(a int) bool {
	if a&1 == 1 {
		return true
	}
	return false
}

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		cntOdd, cntEven := 0, 0
		n, x := 0, 0
		fmt.Fscan(in, &n, &x)
		for ; n > 0; n-- {
			a := 0
			fmt.Fscan(in, &a)
			if isOdd(a) {
				cntOdd++
			} else {
				cntEven++
			}
		}
		gapOdd := x - min(x, cntEven)
		if isOdd(gapOdd) {
			if cntOdd > 0 {
				fmt.Fprintln(out, "Yes")
				continue
			}
		} else if x > gapOdd && gapOdd < cntOdd {
			fmt.Fprintln(out, "Yes")
			continue
		}
		fmt.Fprintln(out, "No")
	}
}

package main

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

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

	var t, n, x, v int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &x)
		c := [2]int{}
		for i := 0; i < n; i++ {
			Fscan(in, &v)
			c[v&1]++
		}
		if c[1] == 0 || c[0] == 1 && c[1]&1 == 0 {
			Fprintln(out, "No")
		} else {
			Fprintln(out, "Yes")
		}
	}
}

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

package main

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

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

	var t, n, x, v int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &x)
		c := [2]int{}
		for i := 0; i < n; i++ {
			Fscan(in, &v)
			c[v&1]++
		}
		if c[1] == 0 || x > c[0] && (x-c[0])&1 == 0 {
			Fprintln(out, "No")
		} else {
			Fprintln(out, "Yes")
		}
	}
}

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

package main

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

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

	var t, n, x, v int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &x)
		c := [2]int{}
		for i := 0; i < n; i++ {
			Fscan(in, &v)
			c[v&1]++
		}
		if c[1] == 0 || (x == n || c[0] == 1) && c[1]&1 == 0 {
			Fprintln(out, "No")
		} else {
			Fprintln(out, "Yes")
		}
	}
}

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

package main
import (
        "fmt"
        "os"
        "bufio"
)
func main(){
    var t, n, x, even, odd, tmp int
    in := bufio.NewReader(os.Stdin)
    fmt.Fscan(in, &t)
    for ; t > 0; t-- {
        fmt.Fscan(in, &n, &x)
        even, odd = 0, 0
        for i:=0; i < n; i++ {
            fmt.Fscan(in, &tmp)
            if tmp % 2 == 0 {
                even++
            } else {
                odd++
            }
        }
        if odd > 0 {
            odd--
            x--
            if x == 1 {
                if even > 0 {
                    fmt.Println("Yes")
                } else {
                    fmt.Println("No")
                }
            } else {
                even += odd / 2
                if even >= x {
                    fmt.Println("Yes")
                } else {
                    fmt.Println("No")
                }
            }
        } else {
            fmt.Println("No")
        }
    }
}

package main
import (
        "fmt"
        "os"
        "bufio"
)
func main(){
    var t, n, x, even, odd, tmp int
    in := bufio.NewReader(os.Stdin)
    fmt.Fscan(in, &t)
    for ; t > 0; t-- {
        fmt.Fscan(in, &n, &x)
        even, odd = 0, 0
        for i:=0; i < n; i++ {
            fmt.Fscan(in, &tmp)
            if tmp % 2 == 0 {
                even++
            } else {
                odd++
            }
        }
        if odd > 0 {
            odd--
            x--
            even += odd / 2
            if even >= x {
                fmt.Println("Yes")
            } else {
                fmt.Println("No")
            }
        } else {
            fmt.Println("No")
        }
    }
}

package main
import (
        "fmt"
        "os"
        "bufio"
)
func main(){
    var t, n, x, even, odd, tmp int
    in := bufio.NewReader(os.Stdin)
    fmt.Fscan(in, &t)
    for ; t > 0; t-- {
        fmt.Fscan(in, &n, &x)
        even, odd = 0, 0
        for i:=0; i < n; i++ {
            fmt.Fscan(in, &tmp)
            if tmp % 2 == 0 {
                even++
            } else {
                odd++
            }
        }
        if odd > 0 {
            odd--
            x--
            if x <= even {
                fmt.Println("Yes")
            } else {
                x -= even
                even = 0
                if x % 2 == 0 {
                    fmt.Println("Yes")
                } else {
                    fmt.Println("No")
                }
            }
        } else {
            fmt.Println("No")
        }
    }
}

package main

import (
	"fmt"
)

func main() {
	var q int
	fmt.Scan(&q)
	for qq := 0; qq < q; qq++ {
		var n int
		var x int
		sum := 0
		fmt.Scanf("%d", &n)
		fmt.Scanf("%d", &x)
		a := make([]int, n)
		haveOdd := false
		haveEven := false
		for i := 0; i < n; i++ {
			fmt.Scanf("%d", &a[i])
			if a[i] % 2 == 0 {
				haveEven = true
			} else {
				haveOdd = true
			}
			sum += a[i]
		}
		if !haveOdd {
			fmt.Println("No")
		} else if !haveEven {
			if x % 2 == 1 {
				fmt.Println("Yes")
			} else {
				fmt.Println("No")
			}
		} else {
			if x == n && sum % 2 == 0 {
				fmt.Println("No")
			} else {
				fmt.Println("Yes")
			}
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var q int
	fmt.Scanf("%d\n", &q)
	for qq := 0; qq < q; qq++ {
		var n int
		var x int
		sum := 0
		fmt.Scanf("%d %d\n", &n, &x)
		a := make([]int, n)
		haveOdd := false
		haveEven := false
		for i := 0; i < n - 1; i++ {
			fmt.Scanf("%d ", &a[i])
		}
		fmt.Scanf("%d\n", &a[n-1])
		for i := 0; i < n; i++ {
			if a[i] % 2 == 0 {
				haveEven = true
			} else {
				haveOdd = true
			}
			sum += a[i]
		}
		if !haveOdd {
			fmt.Println("No")
		} else if !haveEven {
			if x % 2 == 1 {
				fmt.Println("Yes")
			} else {
				fmt.Println("No")
			}
		} else {
			if x == n && sum % 2 == 0 {
				fmt.Println("No")
			} else {
				fmt.Println("Yes")
			}
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		var n, x int
		fmt.Fscan(in, &n, &x)
		cntEven := 0
		cntOdd := 0
		var a int
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a)
			if a%2 == 0 {
				cntEven++
			} else {
				cntOdd++
			}
		}
		x -= cntEven
		if cntOdd > 0 && (x < cntOdd || cntOdd%2 != 0) {
			fmt.Fprintln(out, "Yes")
		} else {
			fmt.Fprintln(out, "No")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanf("%d", &t)
	for t > 0 {
		t--
		var n, x int
		fmt.Scanf("%d%d", &n, &x)
		var a int
		cntEven := 0
		cntOdd := 0
		for i := 0; i < n; i++ {
			fmt.Scanf("%d", &a)
			if a%2 == 0 {
				cntEven++
			} else {
				cntOdd++
			}
		}
		x -= cntEven
		if cntOdd > 0 && (x < cntOdd || cntOdd%2 != 0) {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

package main

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

func isOdd(a int) bool {
	if a&1 == 1 {
		return true
	}
	return false
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		cntOdd, cntEven := 0, 0
		n, x := 0, 0
		fmt.Fscan(in, &n, &x)
		for ; n > 0; n-- {
			a := 0
			fmt.Fscan(in, &a)
			if isOdd(a) {
				cntOdd++
			} else {
				cntEven++
			}
		}
		gapOdd := x - cntEven
		if isOdd(gapOdd) || (isOdd(cntOdd) && cntOdd >= gapOdd+1) {
			fmt.Fprintln(out, "Yes")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

func isOdd(a int) bool {
	if a&1 == 1 {
		return true
	}
	return false
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		cntOdd, cntEven := 0, 0
		n, x := 0, 0
		fmt.Fscan(in, &n, &x)
		for ; n > 0; n-- {
			a := 0
			fmt.Fscan(in, &a)
			if isOdd(a) {
				cntOdd++
			} else {
				cntEven++
			}
		}
		gapOdd := x - cntEven
		if isOdd(gapOdd) || cntOdd >= gapOdd+1 {
			fmt.Fprintln(out, "Yes")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

func isOdd(a int) bool {
	if a&1 == 1 {
		return true
	}
	return false
}

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		cntOdd, cntEven := 0, 0
		n, x := 0, 0
		fmt.Fscan(in, &n, &x)
		for ; n > 0; n-- {
			a := 0
			fmt.Fscan(in, &a)
			if isOdd(a) {
				cntOdd++
			} else {
				cntEven++
			}
		}
		//gapOdd := x - cntEven
		gapOdd := min(x, cntEven)

		if !isOdd(gapOdd) {
			if gapOdd != x && cntOdd > gapOdd {
				fmt.Fprintln(out, "Yes")
			} else {
				fmt.Fprintln(out, "No")
			}
		} else {
			if cntOdd > 0 {
				fmt.Fprintln(out, "Yes")
			} else {
				fmt.Fprintln(out, "No")
			}
		}
	}
}

package main

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

func isOdd(a int) bool {
	if a&1 == 1 {
		return true
	}
	return false
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		cntOdd, cntEven := 0, 0
		n, x := 0, 0
		fmt.Fscan(in, &n, &x)
		for ; n > 0; n-- {
			a := 0
			fmt.Fscan(in, &a)
			if isOdd(a) {
				cntOdd++
			} else {
				cntEven++
			}
		}
		gapOdd := x - cntEven

		if !isOdd(gapOdd) {
			if gapOdd != x && cntOdd > gapOdd {
				fmt.Fprintln(out, "Yes")
			} else {
				fmt.Fprintln(out, "No")
			}
		} else {
			fmt.Fprintln(out, "Yes")
		}
	}
}

package main

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

func isOdd(a int) bool {
	if a&1 == 1 {
		return true
	}
	return false
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		cntOdd, cntEven := 0, 0
		n, x := 0, 0
		fmt.Fscan(in, &n, &x)
		for ; n > 0; n-- {
			a := 0
			fmt.Fscan(in, &a)
			if isOdd(a) {
				cntOdd++
			} else {
				cntEven++
			}
		}
		gapOdd := x - cntEven
		if isOdd(gapOdd) || (isOdd(gapOdd+1) && cntOdd >= gapOdd+1) {
			fmt.Fprintln(out, "Yes")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

func isOdd(a int) bool {
	if a&1 == 1 {
		return true
	}
	return false
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		cntOdd, cntEven := 0, 0
		n, x := 0, 0
		fmt.Fscan(in, &n, &x)
		for ; n > 0; n-- {
			a := 0
			fmt.Fscan(in, &a)
			if isOdd(a) {
				cntOdd++
			} else {
				cntEven++
			}
		}
		// zero OR an even number of odds = even number -> fail
		if !isOdd(cntOdd) {
			fmt.Fprintln(out, "No")
		} else {
			fmt.Fprintln(out, "Yes")
		}
	}
}

package main

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

func isOdd(a int) bool {
	if a&1 == 1 {
		return true
	}
	return false
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		cntOdd, cntEven := 0, 0
		n, x := 0, 0
		fmt.Fscan(in, &n, &x)
		for ; n > 0; n-- {
			a := 0
			fmt.Fscan(in, &a)
			if isOdd(a) {
				cntOdd++
			} else {
				cntEven++
			}
		}
		gapOdd := x - cntEven

		if !isOdd(gapOdd) {
			if cntOdd > gapOdd {
				fmt.Fprintln(out, "Yes")
			} else {
				fmt.Fprintln(out, "No")
			}
		} else {
			fmt.Fprintln(out, "Yes")
		}
	}
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var t int
	fmt.Fscan(r, &t)
	for ; t > 0; t-- {
		var n, x int
		fmt.Fscan(r, &n, &x)
		var odd, even int
		for i := 0; i < n; i++ {
			var a int
			fmt.Fscan(r, &a)
			if a%2 == 1 {
				odd++
			} else {
				even++
			}
		}
		if odd == 0 {
			fmt.Fprintln(w, "No")
			continue
		}
		if even+(odd-1)/2*2 >= x-1 {
			fmt.Fprintln(w, "Yes")
		} else {
			fmt.Fprintln(w, "No")
		}
	}
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var t int
	fmt.Fscan(r, &t)
	for ; t > 0; t-- {
		var n, x int
		fmt.Fscan(r, &n, &x)
		var odd, even int
		for i := 0; i < n; i++ {
			var a int
			fmt.Fscan(r, &a)
			if a%2 == 1 {
				odd++
			} else {
				even++
			}
		}
		if odd > 0 && (even >= x-1 || (x-even)%2 == 1) {
			fmt.Fprintln(w, "Yes")
		} else {
			fmt.Fprintln(w, "No")
		}

	}
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var t int
	fmt.Fscan(r, &t)
	for ; t > 0; t-- {
		var n, x int
		fmt.Fscan(r, &n, &x)
		var odd, even int
		for i := 0; i < n; i++ {
			var a int
			fmt.Fscan(r, &a)
			if a%2 == 1 {
				odd++
			} else {
				even++
			}
		}
		if odd == 0 {
			fmt.Fprintln(w, "No")
			continue
		}
		if odd%2 == 0 && x == n {
			fmt.Println(w, "No")
			continue
		}
		if x%2 == 0 {
			if even > 0 {
				fmt.Fprintln(w, "Yes")
			} else {
				fmt.Fprintln(w, "No")
			}
		} else {
			fmt.Fprintln(w, "Yes")
		}
	}
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var t int
	fmt.Fscan(r, &t)
	for ; t > 0; t-- {
		var n, x int
		fmt.Fscan(r, &n, &x)
		var odd, even int
		for i := 0; i < n; i++ {
			var a int
			fmt.Fscan(r, &a)
			if a%2 == 1 {
				odd++
			} else {
				even++
			}
		}
		if odd == 0 {
			fmt.Fprintln(w, "No")
			continue
		}
		if odd%2 == 0 {
			odd--
		}
		if odd+even >= x {
			fmt.Fprintln(w, "Yes")
		} else {
			fmt.Fprintln(w, "No")
		}
	}
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var t int
	fmt.Fscan(r, &t)
	for ; t > 0; t-- {
		var n, x int
		fmt.Fscan(r, &n, &x)
		var odd, even int
		for i := 0; i < n; i++ {
			var a int
			fmt.Fscan(r, &a)
			if a%2 == 1 {
				odd++
			} else {
				even++
			}
		}
		if odd == 0 {
			fmt.Fprintln(w, "No")
			continue
		}
		if even >= x-1 {
			fmt.Fprintln(w, "Yes")
			continue
		}
		if (x-even)%2 == 1 {
			fmt.Fprintln(w, "Yes")
		} else if odd >= x-even+1 {
			fmt.Fprintln(w, "Yes")
		} else {
			fmt.Fprintln(w, "No")
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		n, m := 0, 0
		fmt.Fscanf(in, "%d %d\n", &n, &m)
		a := make([]int, n)
		odd := 0
		even := 0
		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d", &a[i])
			if a[i]%2 == 1 {
				odd++
			} else {
				even++
			}
		}
		fmt.Fscanf(in, "\n")
		if odd < 1 {
			fmt.Fprintf(out, "No\n")
		} else {
			if m == n && odd%2 == 0 {
				fmt.Fprintf(out, "No\n")
			} else {
				fmt.Fprintf(out, "Yes\n")
			}
		}
	}
	return
}

func minDigit(a int64) int64 {
	ans := a % 10
	for a > 0 {
		ans = min(ans, a%10)
		a /= 10
	}
	return ans
}

func maxDigit(a int64) int64 {
	ans := a % 10
	for a > 0 {
		ans = max(ans, a%10)
		a /= 10
	}
	return ans
}

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

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

package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		fmt.Println(solver())
	}
}

func no() string {
	return "No"
}
func yes() string {
	return "Yes"
}
func solver() string {
	var n, x, tmp, odd, even int
	fmt.Fscan(input, &n, &x)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &tmp)
		if tmp & 1 > 0 {
			odd++
		} else {
			even++
		}
	}
	if odd <= 0  {
		return no()
	}
	x-=even + 1
	odd--
	if x < 0 {
		x = 0
	}
	if x - odd/2 <= 0 {
		return yes()
	}

	return no()
}

package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		fmt.Println(solver())
	}
}

func no() string {
	return "No"
}
func yes() string {
	return "Yes"
}
func solver() string {
	var n, x, tmp, odd, even int
	fmt.Fscan(input, &n, &x)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &tmp)
		if tmp & 1 > 0 {
			odd++
		} else {
			even++
		}
	}
	odd--
	x--
	if odd < 0  {
		return no()
	}
	x-=even
	if x <= 0 { return yes() }
	if x % 2 == 0 && x <= odd {
		return yes()
	}
	return no()

}

package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		fmt.Println(solver())
	}
}

func no() string {
	return "No"
}
func yes() string {
	return "Yes"
}
func solver() string {
	var n, x, tmp, odd, even int
	fmt.Fscan(input, &n, &x)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &tmp)
		if tmp & 1 > 0 {
			odd++
		} else {
			even++
		}
	}
	odd--
	x--
	if odd < 0  {
		return no()
	}
	if x <= (even + odd/2) {
		return yes()
	}
	return no()

}

package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		fmt.Println(solver())
	}
}

func no() string {
	return "No"
}
func yes() string {
	return "Yes"
}
func solver() string {
	var n, x, tmp, odd, even int
	fmt.Fscan(input, &n, &x)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &tmp)
		if tmp & 1 > 0 {
			odd++
		} else {
			even++
		}
	}
	odd--
	x--
	if odd < 0  {
		return no()
	}
	//fmt.Println("X is:", x, odd)
	x-=even
	if x <= 0 {return yes()}
	if x % 2 == 0 && x <= (odd>>1)<<1 {
		return yes()
	}
	return no()
}

package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		fmt.Println(solver())
	}
}

func no() string {
	return "No"
}
func yes() string {
	return "Yes"
}
func solver() string {
	var n, x, tmp, odd, even int
	fmt.Fscan(input, &n, &x)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &tmp)
		if tmp & 1 > 0 {
			odd++
		} else {
			even++
		}
	}
	odd--
	x--
	if odd < 0  {
		return no()
	}
	x-=(odd>>1)<<1
	if x <= even {
		return yes()
	}
	return no()
}

package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		fmt.Println(solver())
	}
}

func no() string {
	return "No"
}
func yes() string {
	return "Yes"
}
func solver() string {
	var n, x, tmp, odd, even int
	fmt.Fscan(input, &n, &x)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &tmp)
		if tmp % 2 > 0 {
			odd++
		} else {
			even++
		}
	}
	if odd <= 0  {
		return no()
	}
	if odd % 2 == 0 {
		odd--
	}
	x-=even + odd/2
	if x <= 1 {
		return yes()
	}

	return no()
}

package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		fmt.Println(solver())
	}
}

func no() string {
	return "No"
}
func yes() string {
	return "Yes"
}
func solver() string {
	var n, x, tmp, odd, even int
	fmt.Fscan(input, &n, &x)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &tmp)
		if tmp & 1 > 0 {
			odd++
		} else {
			even++
		}
	}
	odd--
	x--
	if odd < 0  {
		return no()
	}
	x-=odd/2*2
	if x <= even {
		return yes()
	}
	return no()
}

package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		fmt.Println(solver())
	}
}

func no() string {
	return "No"
}
func yes() string {
	return "Yes"
}
func solver() string {
	var n, x, tmp, odd, even int
	fmt.Fscan(input, &n, &x)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &tmp)
		if tmp & 1 > 0 {
			odd++
		} else {
			even++
		}
	}
	odd--
	x--
	if odd < 0  {
		return no()
	}
	x-=odd/2*2
	if x <= 0 {return yes()}
	if x <= even {
		return yes()
	}
	return no()
}

package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		fmt.Println(solver())
	}
}

func no() string {
	return "No"
}
func yes() string {
	return "Yes"
}
func solver() string {
	var n, x, tmp, odd, even int
	fmt.Fscan(input, &n, &x)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &tmp)
		if tmp & 1 > 0 {
			odd++
		} else {
			even++
		}
	}
	odd--
	x--
	if odd < 0  {
		return no()
	}
	x-=even
	if x <= 0 { return yes() }
	if x % 2 == 0 && x <= odd/2 {
		return yes()
	}
	return no()

}

package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		fmt.Println(solver())
	}
}

func no() string {
	return "No"
}
func yes() string {
	return "Yes"
}
func solver() string {
	var n, x, tmp, odd, even int
	fmt.Fscan(input, &n, &x)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &tmp)
		if tmp & 1 > 0 {
			odd++
		} else {
			even++
		}
	}
	odd--
	x--
	if odd < 0  {
		return no()
	}
	x-=even
	if x <= 0 {return yes()}
	if x % 2 == 0 && x <= odd {
		return yes()
	}
	return no()
}


package main

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

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	var n, x, y, count int64
	fmt.Fscanf(reader, "%d %d %d\n", &n, &x, &y)
	var s string
	fmt.Fscanf(reader, "%s", &s)
	var prev byte = '1'
	for i := 0;i < len(s);i ++ {
		if prev == '1' && s[i] == '0' {
			count ++
		}
		prev = s[i]
	}
	var cost1 int64 = x * (count - 1) + y
	var cost2 int64 = count * y
	if count == 0 {
		fmt.Printf("0")
	} else if cost1 < cost2 {
		fmt.Printf("%d", cost1)
	} else {
		fmt.Printf("%d", cost2)
	}
}

package main

import (
	"fmt"
)

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

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

func main() {
	n, x, y := 0, 0, 0
	fmt.Scan(&n, &x, &y)
	s := ""
	fmt.Scan(&s)
	cnt := 1
	for i := 1; i < n; i++ {
		if s[i-1] != s[i] {
			cnt++
		}
	}
	if s[0] == '0' {
		cnt++
	}
	cnt /= 2
	ans := int64(0)
	if cnt > 1 {
		ans += int64(min(x, y)) * int64(cnt-1)
	}
	if cnt > 0 {
		ans += int64(y)
	}
	fmt.Println(ans)
}

package main

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

var n int
var a, b, ans int64
var s string

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d %d\n%s", &n, &a, &b, &s)
	groups := int64(0)
	for i := 0; i < n; i++ {
		if s[i] == '0' {
			for ; i < n && s[i] == '0'; i++ {
			}
			groups++
		}
	}
	if groups == 0 {
		fmt.Println(0)
		return
	}
	if a < b {
		fmt.Println((groups-1)*a+b)
	} else {
		fmt.Println(groups*b)
	}
}

package main

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

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

func write(format string, a ...interface{}) {
	fmt.Fprintf(writer, format, a...)
}

func read(format string, a ...interface{}) {
	fmt.Fscanf(reader, format, a...)
}

func check(a, b []int, x, y int) int {
	n := len(a)
	for i := 0; i < n; i++ {
		if a[i] == x || b[i] == x {
			continue
		}
		if a[i] == y || b[i] == y {
			continue
		}
		return i
	}
	return -1
}

func main() {
	defer writer.Flush()

	var n, x, y int
	read("%d %d %d\n", &n, &x, &y)
	var s string
	read("%s\n", &s)

	blocks := 0

	j := -1
	for i := 0; i < n; i++ {
		if s[i] == '0' {
			if j == -1 {
				j = i
			}
		} else {
			if j != -1 {
				blocks++
				j = -1
			}
		}
	}
	if j != -1 {
		blocks++
		j = -1
	}

	if blocks == 0 {
		write("0\n")
		return
	}

	if x > y {
		write("%d\n", int64(y) * int64(blocks))
	} else {
		write("%d\n", int64(blocks - 1) * int64(x) + int64(y))
	}
}

package main

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

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	var n, x, y, count int64
	fmt.Fscanf(reader, "%d %d %d\n", &n, &x, &y)
	var s string
	fmt.Fscanf(reader, "%s", &s)
	var prev byte = '1'
	for i := 0;i < len(s);i ++ {
		if prev == '1' && s[i] == '0' {
			count ++
		}
		prev = s[i]
	}
	var cost1 int64 = x * (count - 1) + y
	var cost2 int64 = count * y
	if cost1 < cost2 {
		fmt.Printf("%d", cost1)
	} else {
		fmt.Printf("%d", cost2)
	}
}

package main

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

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	var n, x, y int
	fmt.Fscanf(reader, "%d %d %d\n", &n, &x, &y)
	var s string
	fmt.Fscanf(reader, "%s", &s)
	var prev byte = '1'
	count := 0
	for i := 0;i < len(s);i ++ {
		if prev == '1' && s[i] == '0' {
			count ++
		}
		prev = s[i]
	}
	cost1 := x * (count - 1) + y
	cost2 := count * y
	if cost1 < cost2 {
		fmt.Printf("%d", cost1)
	} else {
		fmt.Printf("%d", cost2)
	}
}


package main

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

const (
	MaxN = 200005
)

var n int
var a []int
var m map[int][]int
var dp []int
var b []int

func bt(ind int) {
	if ind == -1 {
		return
	}
	bt(b[ind])
	fmt.Printf("%d ", ind + 1)
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d\n", &n)
	a = make([]int, n)
	m = make(map[int][]int, n)
	dp = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%d", &a[i])
		if _, ok := m[a[i]]; !ok {
			m[a[i]] = make([]int, 0)
		}
		m[a[i]] = append(m[a[i]], i)
	}

	dp[0] = 1
	b[0] = -1
	for i := 1; i < n; i++ {
		dp[i] = 1
		b[i] = -1
		if arr, ok := m[a[i] - 1]; ok {
			index := sort.Search(len(arr), func(ind int) bool {
				return arr[ind] >= i
			})
			if index == 0 {
				continue
			} else {
				dp[i] = dp[arr[index - 1]] + 1
				b[i] = arr[index - 1]
			}
		}
	}

	ind := 0
	for i := 1; i < n; i++ {
		if dp[ind] < dp[i] {
			ind = i
		}
	}
	fmt.Println(dp[ind])
	bt(ind)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	I := bufio.NewReader(os.Stdin)
	O := bufio.NewWriter(os.Stdout)
	defer O.Flush()

	f := map[int]int{}
	var n, e int
	Fscan(I, &n)
	a := make([]int, n)
	for i := range a {
		Fscan(I, &a[i])
		if f[a[i]] = f[a[i]-1] + 1; f[a[i]] > f[e] {
			e = a[i]
		}
	}
	t := e - f[e] + 1
	p := []interface{}{}
	for i, v := range a {
		if v == t {
			t++
			p = append(p, i+1)
		}
	}
	Fprintln(O, len(p))
	Fprint(O, p...)
}

package main

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

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

func main() {
	defer out.Flush()

	var n int
	fmt.Fscan(in, &n)
	a := make([]int, n+1)
	mp := make(map[int]int)
	mx, ret := -1, -1
	for i := 1; i <= n; i++ {
		fmt.Fscan(in, &a[i])
		mp[a[i]] = mp[a[i]-1] + 1
		if mp[a[i]] > mx {
			mx = mp[a[i]]
			ret = a[i]
		}
	}
	fmt.Fprintln(out, mx)
	t := ret - mx + 1
	for i := 1; i <= n && t <= ret; i++ {
		if a[i] == t {
			fmt.Fprintf(out, "%d ", i)
			t++
		}
	}
}

package main

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

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

	dp := map[int]int{}
	var n, end int
	Fscan(in, &n)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
		if dp[a[i]] = dp[a[i]-1] + 1; dp[a[i]] > dp[end] {
			end = a[i]
		}
	}
	st := end - dp[end] + 1
	ans := []interface{}{}
	for i, v := range a {
		if v == st {
			st++
			ans = append(ans, i+1)
		}
	}
	Fprintln(out, len(ans))
	Fprint(out, ans...)
}

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

package main

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

const (
	MaxN = 200005
)

var n int
var a []int
var m map[int][]int
var dp []int
var b []int

func bt(ind int) {
	if ind == -1 {
		return
	}
	bt(b[ind])
	fmt.Printf("%d ", ind + 1)
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d\n", &n)
	a = make([]int, n)
	m = make(map[int][]int, n)
	dp = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%d", &a[i])
		if _, ok := m[a[i]]; !ok {
			m[a[i]] = make([]int, 0)
		}
		m[a[i]] = append(m[a[i]], i)
	}
	fmt.Println(m)

	dp[0] = 1
	b[0] = -1
	for i := 1; i < n; i++ {
		dp[i] = 1
		b[i] = -1
		if arr, ok := m[a[i] - 1]; ok {
			index := sort.Search(len(arr), func(ind int) bool {
				return arr[ind] >= i
			})
			if index == 0 {
				continue
			} else {
				dp[i] = dp[arr[index - 1]] + 1
				b[i] = arr[index - 1]
			}
		}
	}

	ind := 0
	for i := 1; i < n; i++ {
		if dp[ind] < dp[i] {
			ind = i
		}
	}
	fmt.Println(dp[ind])
	bt(ind)
}

package main

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

const (
	MaxN = 200005
)

type num struct {
	v, index int
}
type sortable []num

func (s sortable) Len() int {
	return len(s)
}

func (s sortable) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

func (s sortable) Less(i, j int) bool {
	return a[i].v < a[j].v
}

var n int
var a []num
var i1, i2 int

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d\n", &n)
	a = make([]num, 0)
	m := make(map[int]bool)
	for i := 0; i < n; i++ {
		var t int
		fmt.Fscanf(buf, "%d", &t)
		if m[t] {
			continue
		}
		m[t] = true
		a = append(a, num{t, i + 1})
	}
	sort.Sort(sortable(a))
	i1 = 0
	i2 = 0
	k := 0
	for {
		if k == len(a) {
			break
		}
		var j int
		for j = k + 1; j < len(a); j++ {
			if a[j - 1].v + 1 == a[j].v && a[j - 1].index < a[j].index {
				if j - k > i2 - i1 {
					i1 = k
					i2 = j
				}
			} else {
				break
			}
		}
		k = j
	}
	fmt.Println(i2 - i1 + 1)
	for i := i1; i <= i2; i++ {
		fmt.Printf("%d ", a[i].index)
	}
	fmt.Println()
}

package main

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

const (
	MaxN = 200005
)

var n int
var a []int
var m map[int]int
var dp []int
var b []int

func bt(ind int) {
	if ind == -1 {
		return
	}
	bt(b[ind])
	fmt.Printf("%d ", ind + 1)
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d\n", &n)
	a = make([]int, n)
	m = make(map[int]int, n)
	dp = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%d", &a[i])
		if _, ok := m[a[i]]; !ok {
			m[a[i]] = i
		}
	}

	dp[0] = 1
	b[0] = -1
	for i := 1; i < n; i++ {
		dp[i] = 1
		b[i] = -1
		if k, ok := m[a[i] - 1]; ok && k < i {
			dp[i] = 1 + dp[k]
			b[i] = k
		}
	}

	ind := 0
	for i := 1; i < n; i++ {
		if dp[ind] < dp[i] {
			ind = i
		}
	}
	fmt.Println(dp[ind])
	bt(ind)
}


package main

import "fmt"

func main(){
	var a, b string
	fmt.Scan(&a)
	fmt.Scan(&b)
	aa := make([]int, len(a))
	bb := make([]int, len(a))
	hasil := 0
	hasil2 := 0
	for i:=0; i<len(a); i++ {
		aa[i] = int(a[i] - '0')
		bb[i] = int(b[i] - '0')
		if aa[i] != bb[i] {
			if aa[i] == 7 {
				hasil += 1
			} else {
				hasil2 +=1
			}
		}
	}
	if hasil > hasil2 {
		fmt.Println(hasil)
	} else {
		fmt.Println(hasil2)
	}
}

package main

import "fmt"

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

func main() {
    var a,b string
    fmt.Scan(&a)
    fmt.Scan(&b)
    four, seven := 0, 0
    for i := 0; i < len(a); i++ {
        if a[i] != b[i] {
            if a[i] == '4' { four++ }
            if a[i] == '7' { seven++ }
        }
    }
    fmt.Println(max(four,seven))
}

// 145A
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b string
	var x, y float64
	fmt.Scan(&a, &b)
	for i := 0; i < len(a); i++ {
		if a[i] == b[i] {
			continue
		}
		if a[i] == '4' {
			x++
		} else {
			y++
		}
	}
	fmt.Println(math.Max(x, y))
}

// 145A-mic_rizal
package main

import (
    "fmt"
    "math"
)

func main() {
    var str1, str2 string
    fmt.Scan(&str1, &str2)
    var a, b int
    for i := 0; i < len(str1); i++ {
        if str1[i] != str2[i] {
            if str1[i] == '4' {
                a++
            } else {
                b++
            }
        }
    }
    fmt.Println(int(math.Min(float64(a), float64(b))) + int(math.Abs(float64(a)-float64(b))))
}

package main

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

var scanner *bufio.Scanner

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

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

  r, _ := reader.ReadString('\n')
  r = strings.Trim(r, "\r\n")
  s, _ := reader.ReadString('\n')
  s = strings.Trim(s, "\r\n")
  n := len(r)

  a, b := 0, 0
  for i := 0; i < n; i++ {
    if r[i] != s[i] {
      if r[i] == '4' {
        a++
      } else {
        b++
      }
    }
  }
  result := 0
  if a < b {
    result = b
  } else {
    result = a
  }

  writer.WriteString(fmt.Sprintf("%d\n", result))
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var count, a7, a4, b7, b4 int
	count = 0
	var a, b string
	fmt.Scanf("%s\n%s", &a, &b)
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			count ++

			if a[i] == '7' {
				a7 ++
			} else {
				a4++
			}
			if b[i] == '7' {
				b7++
			} else {
				b4++
			}
		}
	}
	result := math.Max(float64(a7),float64(a4))
	//result += float64(count)
	fmt.Println(result)
}

package main

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

func main(){
	var a, b string
	r := bufio.NewScanner(os.Stdin)
	r.Scan()
	a = r.Text()
	r.Scan()
	b = r.Text()
	len := len(a)
	aa := make([]int, len)
	bb := make([]int, len)
	for i:=0; i<len; i++ {
		aa[i] = int(a[i] - '0')
		bb[i] = int(b[i] - '0')
	}
	hasil := 0
	swap := 0
	for i:=0; i<len; i++ {
		if aa[i] != bb[i] {
			hasil += 1
		}
	}

	for j:=0; j<len; j++ {
		if aa[j] != bb[j] {
			if j < len-1 {
				for k:=j+1; k<len; k++ {
					if aa[j] == bb[k] && bb[j] == aa[k] {
						swap += 1
						aa[j], aa[k] = aa[k], aa[j]
						break
					} else {
						swap = swap
					}
				}
			}
		}
	}
	fmt.Println(hasil-swap)
}

package main

import "fmt"

func main(){
	var a, b string
	fmt.Scanln(&a)
	fmt.Scanln(&b)
	len := len(a)
	hasil := 0
	swap := 0
	for i:=0; i<len; i++ {
		if a[i] != b[i] {
			hasil += 1
		}
	}
	for j:=0; j<len; j++ {
		if a[j] != b[j] {
			if j<len-1 {
				for k:=0; k<len-1; k++ {
					if a[j] == b[k+1] && b[j] == a[k+1] {
						swap += 1
					} else {
						swap = swap
					}
				}
			}
		}
	}
	if swap < hasil {
		fmt.Println(hasil-swap)
	} else {
		fmt.Println(hasil)
	}
}

package main

import "fmt"

func main(){
	var a, b string
	fmt.Scanln(&a)
	fmt.Scanln(&b)
	len := len(a)
	hasil := 0
	swap := 0
	for i:=0; i<len; i++ {
		if a[i] != b[i] {
			hasil += 1
		}
	}
	for j:=0; j<len-1; j++ {
		if a[j] == b[j+1] && b[j] == a[j+1] {
			swap += 1
		} else {
			swap = swap
		}
	}
	fmt.Println(hasil-swap)
}

package main

import "fmt"

func main(){
	var a, b string
	fmt.Scanln(&a)
	fmt.Scanln(&b)
	len := len(a)
	hasil := 0
	swap := 0
	for i:=0; i<len; i++ {
		if a[i] != b[i] {
			hasil += 1
		}
	}
	for j:=0; j<len-1; j++ {
		if a[j] == b[j+1] && b[j] == a[j+1] {
			swap += 1
		} else {
			swap = swap
		}
	}
	if swap < hasil {
		fmt.Println(hasil-swap)
	} else {
		fmt.Println(hasil)
	}
}

package main

import "fmt"

func main() {
    var a,b string
    fmt.Scan(&a)
    fmt.Scan(&b)
    ans := 0
    for i := 0; i < len(a); i++ {
        if a[i] != b[i] {
            ans++
            if (i != 0) && (a[i-1] != b[i-1]) && (a[i] != a[i-1]) {
                ans--
            }
        }
    }
    fmt.Println(ans)
}


package main

import (
  "fmt"
  "strings"
  "sort"
)

var n, num int
var name, phone string
var ans = map[string][]string{}
var flag bool

type ByLen []string

func (a ByLen) Len() int {
  return len(a)
}

func (a ByLen) Less(i, j int) bool {
  return len(a[i]) < len(a[j])
}

func (a ByLen) Swap(i, j int) {
  a[i], a[j] = a[j], a[i]
}

func main() {
  fmt.Scan(&n)
  for entry := 0; entry < n; entry++ {
    fmt.Scan(&name)
    fmt.Scan(&num)
    for i := 0; i < num; i++ {
      fmt.Scan(&phone)
      ans[name] = append(ans[name], phone)
    }
  }
  fmt.Println(len(ans))
  for k, v := range ans {
    sort.Sort(ByLen(v))
    var filterred = []string{}
    for i := len(v) - 1; i >= 0; i-- {
      flag = false
      for j := i + 1; j < len(v); j++ {
        if strings.HasSuffix(v[j], v[i]) {
          flag = true
          break
        }
      }
      if !flag {
        filterred = append(filterred, v[i])
      }
    }
    fmt.Printf("%v %v", k, len(filterred))
    for _, value := range filterred {
      fmt.Printf(" %v", value)
    }
    fmt.Print("\n")
  }
}

//package codeforces
package main

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

func readIntoMap(r io.Reader) {
	entries := map[string][]string{}
	for scan := bufio.NewScanner(r); scan.Scan(); {
		if txt := scan.Text(); len(txt) > 2 {
			s := strings.Split(txt, " ")
			if _, ok := entries[s[0]]; ok {
				appendUnique(s[0], s[2:], entries)
			} else {
				entries[s[0]] = s[2:]
			}
		}
	}

	filterPhoneBook(entries)
	removeSuffix(entries)
	printer(entries)
}

func appendUnique(k string, arr []string, e map[string][]string) {
	uniq := map[string]bool{}

	for i := range e[k] {
		uniq[e[k][i]] = true
	}

	for j := range arr {
		uniq[arr[j]] = true
	}

	e[k] = []string{}
	for key := range uniq {
		e[k] = append(e[k], key)
	}
}

func filterPhoneBook(e map[string][]string) {
	for k := range e {
		arr := e[k]
		sort.Slice(arr, func(i, j int) bool {
			return len(arr[i]) < len(arr[j])
		})

		e[k] = arr
	}
}

func removeSuffix(e map[string][]string) {
	for k := range e {
		for i := 0; i < len(e[k]); i++ {
			for j := 1 + i; ; j++ {
				if j == len(e[k]) {
					break
				}

				if strings.HasSuffix(e[k][j], e[k][i]) {
					e[k][i] = ""
					break
				}
			}
		}
	}
}

func shrink(e map[string][]string) {
	for k := range e {
		s := []string{}
		for i := range e[k] {
			if e[k][i] != "" {
				s = append(s, e[k][i])
			}
		}
		e[k] = s
	}
}

func printer(e map[string][]string) {
	shrink(e)
	fmt.Println(len(e))
	for k, v := range e {
		fmt.Printf("%v %v ", k, len(v))
		for i := range v {
			if v[i] != "" {
				fmt.Printf("%v ", v[i])
			}
		}
		fmt.Printf("\n")
	}
}

func main() {
	readIntoMap(os.Stdin)
}

package main

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

type person struct {
	name   string
	phones []string
}

func solve() {
	n := readInt()
	book := make(map[string]*person)
	for i := 0; i < n; i++ {
		name := readString()
		k := readInt()
		p, ok := book[name]
		if !ok {
			p = &person{name: name}
			book[name] = p
		}
		for j := 0; j < k; j++ {
			p.phones = append(p.phones, readString())
		}
	}
	for _, p := range book {
		sort.Sort(ByLength(p.phones))
		a := make([]string, 0)
		for i := 0; i < len(p.phones); i++ {
			ok := true
			for j := 0; j < len(a); j++ {
				if strings.HasSuffix(a[j], p.phones[i]) {
					ok = false
					break
				}
			}
			if ok {
				a = append(a, p.phones[i])
			}
		}
		p.phones = a
	}
	fmt.Println(len(book))
	names := make([]string, 0)
	for name, _ := range book {
		names = append(names, name)
	}
	sort.Strings(names)
	for _, name := range names {
		p := book[name]
		fmt.Println(name, len(p.phones), strings.Join(p.phones, " "))
	}
}

type ByLength []string

func (s ByLength) Len() int {
	return len(s)
}
func (s ByLength) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}
func (s ByLength) Less(i, j int) bool {
	if len(s[i]) == len(s[j]) {
		return strings.Compare(s[i], s[j]) < 0
	}
	return len(s[i]) > len(s[j])
}

var scanner *bufio.Scanner

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

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

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

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

//package codeforces

package main

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

type array struct {
	slice []string
	check map[string]bool
}

func (a *array) insert(s string) {
	if a.slice == nil {
		a.slice = make([]string, 0)
		a.check = map[string]bool{}
	}
	_, ok := a.check[s]
	if !ok {
		a.slice = append(a.slice, s)
		a.check[s] = true
	} else {
		return
	}

	if sort.StringsAreSorted(a.slice) {
		return
	}

	sort.Slice(a.slice, func(i, j int) bool {
		return len(a.slice[i]) < len(a.slice[j])
	})
}

func readIntoMap(r io.Reader) {
	entries := map[string]array{}
	for scan := bufio.NewScanner(r); scan.Scan(); {
		if txt := scan.Text(); len(txt) > 2 {
			s := strings.Split(txt, " ")
			e := entries[s[0]]
			a := s[2:]
			for i := 0; i < len(a); i++ {
				e.insert(a[i])
			}
			entries[s[0]] = e
		}
	}

	removeSuffix(entries)
	printer(entries)
}

func removeSuffix(entries map[string]array) {
	for k := range entries {
		e := entries[k].slice
		for i := 0; i < len(e); i++ {
			for j := i + 1; ; j++ {
				if j == len(e) {
					break
				}
				if strings.HasSuffix(e[j], e[i]) {
					e[i] = ""
				}
			}
		}
		et := entries[k]
		et.slice = e
		entries[k] = et
	}
}

func count(a []string) []string {
	r := []string{}
	for i := range a {
		if a[i] != "" {
			r = append(r, a[i])
		}
	}

	return r
}

func printer(entries map[string]array) {
	fmt.Println(len(entries))
	for k := range entries {
		slice := count(entries[k].slice)
		fmt.Printf("%v %v ", k, len(slice))
		for i := 0; i < len(slice); i++ {
			fmt.Printf("%v ", slice[i])
		}
		fmt.Printf("\n")
	}
}

// code
func main() {
	readIntoMap(os.Stdin)
}

//package codeforces
package main

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

func readIntoMap(r io.Reader) {
	entries := map[string][]string{}
	for scan := bufio.NewScanner(r); scan.Scan(); {
		if txt := scan.Text(); len(txt) > 2 {
			s := strings.Split(txt, " ")
			if _, ok := entries[s[0]]; ok {
				appendUnique(s[0], s[2:], entries)
			} else {
				entries[s[0]] = s[2:]
			}
		}
	}

	filterPhoneBook(entries)
	removeSuffix(entries)
	printer(entries)
}

func appendUnique(k string, arr []string, e map[string][]string) {
	uniq := map[string]bool{}

	for i := range e[k] {
		uniq[e[k][i]] = true
	}

	for j := range arr {
		uniq[arr[j]] = true
	}

	e[k] = []string{}
	for key := range uniq {
		e[k] = append(e[k], key)
	}
}

func filterPhoneBook(e map[string][]string) {
	for k := range e {
		arr := e[k]
		sort.Slice(arr, func(i, j int) bool {
			return len(arr[i]) < len(arr[j])
		})

		e[k] = arr
	}
}

func removeSuffix(e map[string][]string) {
	for k := range e {
		for i := 0; i < len(e[k]); i++ {
			for j := 1 + i; ; j++ {
				if j == len(e[k]) {
					break
				}

				if strings.HasSuffix(e[k][j], e[k][i]) {
					e[k][i] = ""
					break
				}
			}
		}
	}
}

func shrink(e map[string][]string) {
	for k := range e {
		s := []string{}
		for i := range e[k] {
			if e[k][i] != "" {
				s = append(s, e[k][i])
			}
		}
		e[k] = s
	}
}

func printer(e map[string][]string) {
	shrink(e)
	for k, v := range e {
		fmt.Printf("%v %v ", k, len(v))
		for i := range v {
			if v[i] != "" {
				fmt.Printf("%v ", v[i])
			}
		}
		fmt.Printf("\n")
	}
}

func main() {
	readIntoMap(os.Stdin)
}

//package codeforces

package main

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

type array struct {
	slice []string
	check map[string]bool
}

func (a *array) insert(s string) {
	if a.slice == nil {
		a.slice = make([]string, 0)
		a.check = map[string]bool{}
	}
	_, ok := a.check[s]
	if !ok {
		a.slice = append(a.slice, s)
		a.check[s] = true
	}
	sort.Slice(a.slice, func(i, j int) bool {
		return len(a.slice[i]) < len(a.slice[j])
	})
}

func readIntoMap(r io.Reader) {
	entries := map[string]array{}
	for scan := bufio.NewScanner(r); scan.Scan(); {
		if txt := scan.Text(); len(txt) > 2 {
			s := strings.Split(txt, " ")
			e := entries[s[0]]
			a := s[2:]
			for i := 0; i < len(a); i++ {
				e.insert(a[i])
			}
			entries[s[0]] = e
		}
	}

	removeSuffix(entries)
	printer(entries)
}

func removeSuffix(entries map[string]array) {
	for k := range entries {
		e := entries[k].slice
		for i := 0; i < len(e); i++ {
			for j := i + 1; ; j++ {
				if j == len(e) {
					break
				}
				if strings.HasSuffix(e[j], e[i]) {
					e[i] = ""
				}
			}
		}
		et := entries[k]
		et.slice = e
		entries[k] = et
	}
}

func printer(entries map[string]array) {
	fmt.Println(len(entries))
	for k := range entries {
		fmt.Printf("%v ", k)
		for i := 0; i < len(entries[k].slice); i++ {
			if entries[k].slice[i] != "" {
				fmt.Printf("%v ", entries[k].slice[i])
			}
		}
		fmt.Printf("\n")
	}
}

// code
func main() {
	readIntoMap(os.Stdin)
}

//package codeforces

package main

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

type array struct {
	slice []string
	check map[string]bool
}

func (a *array) insert(s string) {
	if a.slice == nil {
		a.slice = make([]string, 0)
		a.check = map[string]bool{}
	}
	_, ok := a.check[s]
	if !ok {
		a.slice = append(a.slice, s)
		a.check[s] = true
	}
	sort.Slice(a.slice, func(i, j int) bool {
		return len(a.slice[i]) < len(a.slice[j])
	})
}

func readIntoMap(r io.Reader) {
	entries := map[string]array{}
	for scan := bufio.NewScanner(r); scan.Scan(); {
		if txt := scan.Text(); len(txt) > 2 {
			s := strings.Split(txt, " ")
			e := entries[s[0]]
			a := s[2:]
			for i := 0; i < len(a); i++ {
				e.insert(a[i])
			}
			entries[s[0]] = e
		}
	}

	removeSuffix(entries)
	printer(entries)
}

func removeSuffix(entries map[string]array) {
	for k := range entries {
		e := entries[k].slice
		for i := 0; i < len(e); i++ {
			for j := i + 1; ; j++ {
				if j == len(e) {
					break
				}
				if strings.HasSuffix(e[j], e[i]) {
					e[i] = ""
				}
			}
		}
		et := entries[k]
		et.slice = e
		entries[k] = et
	}
}

func printer(entries map[string]array) {
	fmt.Println(len(entries))
	for k := range entries {
		fmt.Printf("%v ", k)
		for i := 0; i < len(entries[k].slice); i++ {
			if entries[k].slice[i] != "" {
				fmt.Printf("%v ", entries[k].slice[i])
			}
		}
		fmt.Printf("\n")
	}
}

func main() {
	readIntoMap(os.Stdin)
}

package main

import (
  "fmt"
  "strings"
  "sort"
)

var n, num int
var name, phone string
var ans = map[string][]string{}
var flag bool

func main() {
  fmt.Scan(&n)
  for entry := 0; entry < n; entry++ {
    fmt.Scan(&name)
    fmt.Scan(&num)
    for i := 0; i < num; i++ {
      fmt.Scan(&phone)
      ans[name] = append(ans[name], phone)
    }
  }
  fmt.Println(len(ans))
  for k, v := range ans {
    sort.Sort(sort.StringSlice(v))
    var filterred = []string{}
    for i := len(v) - 1; i >= 0; i-- {
      flag = false
      for j := i + 1; j < len(v); j++ {
        if strings.HasSuffix(v[j], v[i]) {
          flag = true
          break
        }
      }
      if !flag {
        filterred = append(filterred, v[i])
      }
    }
    fmt.Printf("%v %v", k, len(filterred))
    for _, value := range filterred {
      fmt.Printf(" %v", value)
    }
    fmt.Print("\n")
  }
}