package main

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

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

func main() {

	var T, n, k1, k2, i, j, k, temp  uint
	scanf("%d \n", &T)

	results := []string{}

	for i=0; i<T; i++ {
		scanf("%d %d %d \n", &n, &k1, &k2)
		p1Cards := []uint{}
		p2Cards := []uint{}

		for j=0; j<k1; j++ {
			if j == k1 - 1 {
				scanf("%d \n", &temp)
			}else {
				scanf("%d ", &temp)
			}
			p1Cards = append(p1Cards, temp)
		}

		for k=0; k<k2; k++ {
			if k == k2 - 1 {
				scanf("%d \n", &temp)
			}else {
				scanf("%d ", &temp)
			}
			p2Cards = append(p2Cards, temp)
		}

		if getMax(p2Cards) > getMax(p1Cards) {
			results = append(results, "NO")
		}else {
			results = append(results, "YES")
		}

	}

	for _, v := range results {
		fmt.Println(v)
	}
}

func getMax(a []uint) uint{
	var max uint
	for _, v := range a {
		if v > max {
			max = v
		}
	}

	return max
}

package main

import "fmt"

func main(){
    var n int
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        var t, p1, p2, m1, m2 int
        fmt.Scan(&t, &p1, &p2)
        for x := 0; x < p1; x++ {
            fmt.Scan(&t)
            if (t > m1) {
                m1 = t
            }
        }
        for x := 0; x < p2; x++ {
            fmt.Scan(&t)
            if (t > m2) {
                m2 = t
            }
        }
        if (m1 > m2) {
            fmt.Println("YES")
        } else {
            fmt.Println("NO")
        }
    }
}

package main

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

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

	var t, n, k1, k2 int
	fmt.Fscanf(reader, "%d\n", &t)
	for i := 1; i <= t; i++ {
		fmt.Fscanf(reader, "%d %d %d\n", &n, &k1, &k2)
		var temp int
		found := false
		for j := 1; j <= k1; j++ {
			fmt.Fscanf(reader, "%d", &temp)
			if temp == n {
				found = true
			}
		}
		fmt.Fscanf(reader, "\n")
		for j := 1; j <= k2; j++ {
			fmt.Fscanf(reader, "%d", &temp)
		}
		fmt.Fscanf(reader, "\n")
		if found {
			fmt.Fprintf(writer, "YES\n")
		} else {
			fmt.Fprintf(writer, "NO\n")
		}
	}
}

package main

import (
  "fmt"
  "sort"
)

type heap struct {
  array []int
}

func (h *heap) push(val int) {
  h.array = append(h.array, val)
  cur := len(h.array) - 1
  for cur > 0 {
    var parent int
    if (cur & 1) == 1 {
      parent = (cur - 1) / 2
    } else {
      parent = (cur - 2) / 2
    }
    if h.array[cur] < h.array[parent] {
      h.array[cur], h.array[parent] = h.array[parent], h.array[cur]
      cur = parent
    } else {
      break
    }
  }
}

func (h *heap) pop() int {
  res := h.array[0]
  h.array[0], h.array[len(h.array)-1] = h.array[len(h.array)-1], h.array[0]
  h.array = h.array[:len(h.array)-1]
  cur := 0
  for cur < len(h.array) {
    smallest := cur
    if cur*2+1 < len(h.array) && h.array[smallest] > h.array[cur*2+1] {
      smallest = cur*2 + 1
    }
    if cur*2+2 < len(h.array) && h.array[smallest] > h.array[cur*2+2] {
      smallest = cur*2 + 2
    }
    if smallest != cur {
      h.array[smallest], h.array[cur] = h.array[cur], h.array[smallest]
      cur = smallest
    } else {
      break
    }
  }
  return res
}

func main() {
  var T int
  fmt.Scan(&T)
  for T > 0 {
    T--
    var n, k1, k2 int
    fmt.Scan(&n, &k1, &k2)
    p1, p2 := make([]int, k1), make([]int, k2)
    for i, _ := range p1 {
      fmt.Scan(&p1[i])
    }
    for i, _ := range p2 {
      fmt.Scan(&p2[i])
    }
    sort.Ints(p1)
    sort.Ints(p2)
    if p1[k1-1]>p2[k2-1]{
      fmt.Println("YES")
    }else{
      fmt.Println("NO")
    }
  }

}

// A. Card Game
/*
Two players decided to play one interesting card game.

There is a deck of 𝑛 cards, with values from 1 to 𝑛. The values of cards are pairwise different (this means that no two different cards have equal values). At the beginning of the game, the deck is completely distributed between players such that each player has at least one card.

The game goes as follows: on each turn, each player chooses one of their cards (whichever they want) and puts on the table, so that the other player doesn't see which card they chose. After that, both cards are revealed, and the player, value of whose card was larger, takes both cards in his hand. Note that as all cards have different values, one of the cards will be strictly larger than the other one. Every card may be played any amount of times. The player loses if he doesn't have any cards.

For example, suppose that 𝑛=5, the first player has cards with values 2 and 3, and the second player has cards with values 1, 4, 5. Then one possible flow of the game is:

    The first player chooses the card 3. The second player chooses the card 1. As 3>1, the first player gets both cards. Now the first player has cards 1, 2, 3, the second player has cards 4, 5.

	 	The first player chooses the card 3. The second player chooses the card 4. As 3<4, the second player gets both cards. Now the first player has cards 1, 2. The second player has cards 3, 4, 5.

	 	The first player chooses the card 1. The second player chooses the card 3. As 1<3, the second player gets both cards. Now the first player has only the card 2. The second player has cards 1, 3, 4, 5.

	 	The first player chooses the card 2. The second player chooses the card 4. As 2<4, the second player gets both cards. Now the first player is out of cards and loses. Therefore, the second player wins.

Who will win if both players are playing optimally? It can be shown that one of the players has a winning strategy.

Input
Each test contains multiple test cases. The first line contains the number of test cases 𝑡(1≤𝑡≤100). The description of the test cases follows.

The first line of each test case contains three integers 𝑛, 𝑘1, 𝑘2 (2≤𝑛≤100,1≤𝑘1≤𝑛−1,1≤𝑘2≤𝑛−1,𝑘1+𝑘2=𝑛) — the number of cards, number of cards owned by the first player and second player correspondingly.

The second line of each test case contains 𝑘1 integers 𝑎1,…,𝑎𝑘1 (1≤𝑎𝑖≤𝑛) — the values of cards of the first player.

The third line of each test case contains 𝑘2 integers 𝑏1,…,𝑏𝑘2 (1≤𝑏𝑖≤𝑛) — the values of cards of the second player.

It is guaranteed that the values of all cards are different.

Output
For each test case, output "YES" in a separate line, if the first player wins. Otherwise, output "NO" in a separate line. You can print each letter in any case (upper or lower).

Example
Input
2
2 1 1
2
1
5 2 3
2 3
1 4 5

Output
YES
NO

Note
In the first test case of the example, there is only one possible move for every player: the first player will put 2, the second player will put 1. 2>1, so the first player will get both cards and will win.

In the second test case of the example, it can be shown that it is the second player who has a winning strategy. One possible flow of the game is illustrated in the statement.
*/
package main

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

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

	for ; t > 0; t-- {
		input2, _ := reader.ReadString('\n')
		arr1 := strings.Split(strings.TrimSpace(input2), " ")
		k1, _ := strconv.Atoi(arr1[1])
		k2, _ := strconv.Atoi(arr1[2])

		input3, _ := reader.ReadString('\n')
		arr2 := strings.Split(strings.TrimSpace(input3), " ")

		input4, _ := reader.ReadString('\n')
		arr3 := strings.Split(strings.TrimSpace(input4), " ")

		max1, max2 := 0, 0
		for i := 0; i < k1; i++ {
			v, _ := strconv.Atoi(arr2[i])
			if v > max1 {
				max1 = v
			}
		}
		for i := 0; i < k2; i++ {
			v, _ := strconv.Atoi(arr3[i])
			if v > max2 {
				max2 = v
			}
		}

		if max1 > max2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

func solve() {
	var n, k1, k2, a, b, winner int
	fmt.Scan(&n, &k1, &k2)
	for ; k1 > 0; k1-- {
		fmt.Scan(&a)
		if a == n {
			winner = 1
		}
	}
	for ; k2 > 0; k2-- {
		fmt.Scan(&b)
	}
	if winner == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		solve()
	}
}

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, k1, k2 := 0, 0, 0
		fmt.Fscanf(in, "%d %d %d\n", &n, &k1, &k2)
		a := 0
		for i := 0; i < k1; i++ {
			tmp := 0
			fmt.Fscanf(in, "%d", &tmp)
			if tmp > a {
				a = tmp
			}
		}
		fmt.Fscanf(in, "\n")
		b := 0
		for i := 0; i < k2; i++ {
			tmp := 0
			fmt.Fscanf(in, "%d", &tmp)
			if tmp > b {
				b = tmp
			}
		}
		fmt.Fscanf(in, "\n")
		if a > b {
			fmt.Fprintf(out, "YES\n")
		} else {
			fmt.Fprintf(out, "NO\n")
		}
	}
	return
}

func same(s string, ss string) bool {
	a := make([]int, 26)
	for i := 0; i < len(s); i++ {
		b := int(s[i] - 'a')
		a[b]++
	}
	for i := 0; i < len(ss); i++ {
		b := int(ss[i] - 'a')
		a[b]--
		if a[b] == -1 {
			return false
		}
	}
	for i := 0; i < 26; i++ {
		if a[i] != 0 {
			return false
		}
	}
	return true
}

package main

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

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

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

	t, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	for i := int64(0); i < t; i++ {
		readLine(reader)
		checkError(err)
		max1, max2 := int64(0), int64(0)
		line := strings.Split(readLine(reader), " ")
		for _, s := range line {
			v, err := strconv.ParseInt(s, 10, 64)
			checkError(err)
			if v > max1 {
				max1 = v
			}
		}
		line = strings.Split(readLine(reader), " ")
		for _, s := range line {
			v, err := strconv.ParseInt(s, 10, 64)
			checkError(err)
			if v > max2 {
				max2 = v
			}
		}

		if max1 > max2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func readLine(reader *bufio.Reader) string {
	str, err := reader.ReadString('\n')
	if err == io.EOF {
		return ""
	}

	return strings.TrimSpace(str)
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var t, n, k1, k2, c, max1, max2 int
	fmt.Fscanln(reader, &t)
	for i := 0; i < t; i++ {
		fmt.Fscanln(reader, &n, &k1, &k2)
		max1 = 0
		for j := 0; j < k1; j++ {
			if j == k1-1 {
				fmt.Fscanf(reader, "%d\n", &c)
			} else {
				fmt.Fscanf(reader, "%d", &c)
			}
			if c > max1 {
				max1 = c
			}
		}
		max2 = 0
		for j := 0; j < k2; j++ {
			if j == k2-1 && i < t - 1 {
				fmt.Fscanf(reader, "%d\n", &c)
			} else {
				fmt.Fscanf(reader, "%d", &c)
			}
			if c > max2 {
				max2 = c
			}
		}
		if max1 > max2 {
			fmt.Fprintln(writer, "YES")
		} else {
			fmt.Fprintln(writer, "NO")
		}
	}
}

package main

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

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

	testCount := 0
	fmt.Fscanf(in, "%d\n", &testCount)

	for i := 0; i < testCount; i++ {
		n, k1, k2 := 0, 0, 0
		fmt.Fscanf(in, "%d %d %d\n", &n, &k1, &k2)

		p1max := -1
		p2max := -1

		for j := 0; j < k1; j++ {
			cardNumber := 0
			fmt.Fscanf(in, "%d", &cardNumber)
			if cardNumber > p1max {
				p1max = cardNumber
			}
		}
		fmt.Fscanf(in, "\n")

		for j := 0; j < k2; j++ {
			cardNumber := 0
			fmt.Fscanf(in, "%d", &cardNumber)
			if cardNumber > p2max {
				p2max = cardNumber
			}
		}
		fmt.Fscanf(in, "\n")

		if p1max > p2max {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	_, _ = fmt.Scan(&t)

	for i := 0; i < t; i++ {
		var n, k1, k2 int
		_, _ = fmt.Scan(&n, &k1, &k2)
		var mx1, mx2, cur int
		for c := 0; c < k1; c++ {
			_, _ = fmt.Scan(&cur)
			if mx1 < cur {
				mx1 = cur
			}
		}
		for c := 0; c < k2; c++ {
			_, _ = fmt.Scan(&cur)
			if mx2 < cur {
				mx2 = cur
			}
		}

		if mx1 > mx2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	sc := NewScanner()
	t := sc.NextInt()
	for i := 0; i < t; i++ {
		_, _, _ = sc.NextInt(), sc.NextInt(), sc.NextInt()
		a := sc.NextIntArray()
		q1 := maxA(a...)
		b := sc.NextIntArray()
		q2 := maxA(b...)
		if q1 > q2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}
func maxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = max(s, v)
	}
	return s
}

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

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var t, n int
	var k1, k2 int
	var a[100] int
	var b[100] int

	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		fmt.Scan(&n, &k1, &k2)
		for j:=0; j<k1; j++ {
			fmt.Scan(&a[j])
		}
		for m:=0; m<k2; m++ {
			fmt.Scan(&b[m])
		}
		sa := a[0 : k1]
		sb := b[0 : k2]
		sort.Slice(sa, func(i, j int) bool { return sa[i] > sa[j] })
		sort.Slice(sb, func(i, j int) bool { return sb[i] > sb[j] })
		if sa[0] > sb[0] {
			fmt.Print("\nYES")
		} else {
			fmt.Print("\nNO")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int

	fmt.Scan(&t)

	for t > 0 {
	    var n, k1, k2, l1, l2 int

		fmt.Scan(&n, &k1, &k2)

		for i := 0; i < k1; i++ {
		    var t1 int
			fmt.Scan(&t1)
			l1 = Max(t1, l1)
		}
		for i := 0; i < k2; i++ {
		    var t2 int
			fmt.Scan(&t2)
			l2 = Max(t2, l2)
		}

		if l1 > l2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

		t--
	}
}

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

package main

import "fmt"

func solve() {
	var n, k1, k2, a, b, maxA int
	fmt.Scan(&n, &k1, &k2)
	for ; k1 > 0; k1-- {
		fmt.Scan(&a)
		if maxA < a {
			maxA = a
		}
	}
	for ; k2 > 0; k2-- {
		fmt.Scan(&b)
		if maxA < b {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		solve()
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, n, k1, k2, t1, t2 int

	fmt.Scan(&t)

	for t > 0 {
		fmt.Println(t)
		fmt.Scan(&n, &k1, &k2)
		var a = make([]int, k1)
		var b = make([]int, k2)

		for i := 0; i < k1; i++ {
			if _, err := fmt.Scan(&a[i]); err != nil {
				panic(err)
			}
			if i == 0 {
				t1 = a[0]
			}
			if i > 0 && a[i-1] < a[i] {
				t1 = a[i]
			}
		}
		for i := 0; i < k2; i++ {
			if _, err := fmt.Scan(&b[i]); err != nil {
				panic(err)
			}
			if i == 0 {
				t2 = b[0]
			}
			if i > 0 && b[i-1] < b[i] {
				t2 = b[i]
			}
		}

		if t1 > t2 {
			fmt.Print("YES")
		} else {
			fmt.Print("NO")
		}

		t--
		if t > 0 {
			fmt.Println()
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, n, k1, k2, t1, t2 int

	fmt.Scan(&t)

	for t > 0 {
		fmt.Scan(&n, &k1, &k2)

		var k1A = make([]int, k1)
		var k2A = make([]int, k2)

		for i := 0; i < k1; i++ {
			if _, err := fmt.Scan(&k1A[i]); err != nil {
				panic(err)
			}
			if i == 0 {
				t1 = k1A[0]
			}
			if i > 0 && k1A[i-1] < k1A[i] {
				t1 = k1A[i]
			}
		}
		for i := 0; i < k2; i++ {
			if _, err := fmt.Scan(&k2A[i]); err != nil {
				panic(err)
			}
			if i == 0 {
				t2 = k2A[0]
			}
			if i > 0 && k2A[i-1] < k2A[i] {
				t2 = k2A[i]
			}
		}

		if t1 > t2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

		t--
	}

}

package main

import (
	"fmt"
)

func main() {
	var t, n, k1, k2, t1, t2 int

	if _, err := fmt.Scan(&t); err != nil {
		panic(err)
	}

	for t > 0 {
		if _, err := fmt.Scan(&n, &k1, &k2); err != nil {
			panic(err)
		}

		var a = make([]int, k1)
		var b = make([]int, k2)

		for i := 0; i < k1; i++ {
			if _, err := fmt.Scan(&a[i]); err != nil {
				panic(err)
			}
			if i == 0 {
				t1 = a[0]
			}
			if i > 0 && a[i-1] < a[i] {
				t1 = a[i]
			}
		}
		for i := 0; i < k2; i++ {
			if _, err := fmt.Scan(&b[i]); err != nil {
				panic(err)
			}
			if i == 0 {
				t2 = b[0]
			}
			if i > 0 && b[i-1] < b[i] {
				t2 = b[i]
			}
		}

		if t1 > t2 {
			fmt.Print("YES")
		} else {
			fmt.Print("NO")
		}

		t--
		if t > 0 {
			fmt.Println()
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, n, k1, k2, t1, t2 int

	fmt.Scan(&t)

	for t > 0 {
		fmt.Scan(&n, &k1, &k2)
		var a = make([]int, k1)
		var b = make([]int, k2)

		for i := 0; i < k1; i++ {
			if _, err := fmt.Scan(&a[i]); err != nil {
				panic(err)
			}
			if i == 0 {
				t1 = a[0]
			}
			if i > 0 && a[i-1] < a[i] {
				t1 = a[i]
			}
		}
		for i := 0; i < k2; i++ {
			if _, err := fmt.Scan(&b[i]); err != nil {
				panic(err)
			}
			if i == 0 {
				t2 = b[0]
			}
			if i > 0 && b[i-1] < b[i] {
				t2 = b[i]
			}
		}

		if t1 > t2 {
			fmt.Print("YES")
		} else {
			fmt.Print("NO")
		}

		t--
		if t > 0 {
			fmt.Println()
		}
	}
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF999D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ i, v int }

	var n, m int
	Fscan(in, &n, &m)
	sz := n / m
	a := make([]int, n)
	id := make([][]int, m)
	for i := range a {
		Fscan(in, &a[i])
		id[a[i]%m] = append(id[a[i]%m], i)
	}

	ans := int64(0)
	var todo []pair
	for v := 0; v < 2*m; v++ {
		i := v % m
		for len(id[i]) > sz {
			j := id[i][0]
			id[i] = id[i][1:]
			todo = append(todo, pair{j, v})
		}
		for len(todo) > 0 && len(id[i]) < sz {
			p := todo[0]
			todo = todo[1:]
			id[i] = append(id[i], p.i)
			d := v - p.v
			a[p.i] += d
			ans += int64(d)
		}
	}
	Fprintln(out, ans)
	for _, v := range a {
		Fprint(out, v, " ")
	}
}

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

package main

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

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	var m, n int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	a := make([]int, n)
	mod := make([]int, m)
	plus := make([][]int, m)
	for i := 0;i < n;i ++ {
		fmt.Fscanf(reader, "%d ", &a[i])
		mod[a[i] % m] ++
	}
	for i := 0;i < m;i ++ {
		plus[i] = make([]int, 0, mod[i])
	}
	stack := make([]int, 0, n)
	var ans uint64
	for i := 0;i < 2 * m - 1;i ++ {
		if mod[i % m] > n / m {
			stack = append(stack, i % m)
		} else if mod[i % m] < n / m {
			for mod[i % m] != n / m && len(stack) != 0 {
				pos := stack[len(stack) - 1]
				d1, d2 := n / m - mod[i % m], mod[pos] - n / m
				if d2 >= d1 {
					ans += uint64(d1) * uint64((i + 2 * m - pos) % m)
					for j := 0;j < d1;j ++ {
						plus[pos] = append(plus[pos], (i + 2 * m - pos) % m)
					}
					mod[pos], mod[i % m] = mod[pos] - d1, mod[i % m] + d1
				} else {
					ans += uint64(d2) * uint64((i + 2 * m - pos) % m)
					for j := 0;j < d2;j ++ {
						plus[pos] = append(plus[pos], (i + 2 * m - pos) % m)
					}
					mod[pos], mod[i % m] = mod[pos] - d2, mod[i % m] + d2
					stack = stack[:len(stack) - 1]
				}
			}
		}
	}
	fmt.Printf("%d\n", ans)
	for i := 0;i < n;i ++ {
		if len(plus[a[i] % m]) > 0 {
			plus[a[i] % m], a[i] = plus[a[i] % m][1:], a[i] + plus[a[i] % m][0]
		}
		fmt.Printf("%d ", a[i])
	}
}

package main

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

const (
	MaxN = 200005
)

type rem struct {
	r, index int64
}

var n, m, k int64
var a [MaxN]int64
var remainders []int64
var indexes [][]int64

func main() {
	inBuf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(inBuf, "%d %d\n", &n, &m)
	k = n / m
	remainders = make([]int64, m)
	indexes = make([][]int64, m)
	for i := int64(0); i < n; i++ {
		fmt.Fscanf(inBuf, "%d ", &a[i])
		r := a[i] % m
		remainders[r]++
		indexes[r] = append(indexes[r], i)
	}

	ans := int64(0)
	q := make([]rem, 0)
	for i := int64(0); i < 2*m; i++ {
		r := i % m
		for l := len(indexes[r]); remainders[r] > k; l-- {
			q = append(q, rem{r: r, index: indexes[r][l-1]})
			indexes[r] = indexes[r][:l-1]
			remainders[r]--
		}
		for l := len(q); remainders[r] < k && l > 0; l-- {
			remainders[r]++
			t := q[l-1]
			q = q[:l-1]
			step := (m + i - t.r) % m
			ans += step
			a[t.index] += step
		}
	}
	fmt.Println(ans)
	for i := int64(0); i < n; i++ {
		fmt.Print(a[i], " ")
	}
}

package main

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

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	var m, n int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	a := make([]int, n)
	mod := make([]int, m)
	plus := make([][]int, m)
	for i := 0;i < n;i ++ {
		fmt.Fscanf(reader, "%d ", &a[i])
		mod[a[i] % m] ++
	}
	for i := 0;i < m;i ++ {
		plus[i] = []int{}
	}
	stack := make([]int, 0, n)
	ans := 0
	for i := 0;i < 2 * m - 1;i ++ {
		if mod[i % m] > n / m {
			stack = append(stack, i % m)
		} else if mod[i % m] < n / m {
			for mod[i % m] != n / m && len(stack) != 0 {
				pos := stack[len(stack) - 1]
				d1, d2 := n / m - mod[i % m], mod[pos] - n / m
				if d2 >= d1 {
					ans += d1 * ((i + 2 * m - pos) % m)
					for j := 0;j < d1;j ++ {
						plus[pos] = append(plus[pos], (i + 2 * m - pos) % m)
					}
					mod[pos], mod[i % m] = mod[pos] - d1, mod[i % m] + d1
				} else {
					ans += d2 * ((i + 2 * m - pos) % m)
					for j := 0;j < d2;j ++ {
						plus[pos] = append(plus[pos], (i + 2 * m - pos) % m)
					}
					mod[pos], mod[i % m] = mod[pos] - d2, mod[i % m] + d2
				}
			}
		}
	}
	fmt.Printf("%d\n", ans)
	for i := 0;i < n;i ++ {
		if len(plus[a[i] % m]) > 0 {
			plus[a[i] % m], a[i] = plus[a[i] % m][1:], a[i] + plus[a[i] % m][0]
		}
		fmt.Printf("%d ", a[i])
	}
}

package main

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

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

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

	var n, m ,d int
	Fscan(in, &n, &m)
	d=n/m

	arr:=make([]int, n)

	for i := 0; i < n; i++ {
		Fscan(in, &arr[i])
		arr[i]%=m
	}

	sort.Ints(arr)

	ans := int64(0)
	for i := 0; i < n; i++ {
		ans+=int64(abs(arr[i] - i/d))
	}

	Fprintln(out, ans)
}

package main

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

const (
	MaxN = 200005
)

type rem struct {
	r, count int
}

var n, m, k int64
var a [MaxN]int64
var remainders []int64
var lesser []int64

func main() {
	inBuf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(inBuf, "%d %d\n", &n, &m)
	k = n / m
	remainders = make([]int64, m)
	for i := int64(0); i < n; i++ {
		fmt.Fscanf(inBuf, "%d ", &a[i])
		remainders[a[i] % m]++
	}
	lesser = make([]int64, 0)
	for i := int64(0); i < m; i++ {
		if remainders[i] < k {
			lesser = append(lesser, i)
		}
	}
	ans := int64(0)
	p1 := 0
	for i := int64(0); i < n; i++ {
		r := a[i] % m
		if remainders[r] > k {
			remainders[r]--
			steps := lesser[p1] - r
			if r > lesser[p1] {
				steps = m - r + lesser[p1]
			}
			ans += steps
			a[i] += steps
			remainders[lesser[p1]]++
			if remainders[lesser[p1]] == k {
				p1++
			}
		}
	}
	fmt.Println(ans)
	for i := int64(0); i < n; i++ {
		fmt.Print(a[i], " ")
	}
}

package main

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

const (
	MaxN = 200005
)

type rem struct {
	r, count int
}

var n, m, k int
var a [MaxN]int
var remainders []int
var lesser []int

func main() {
	inBuf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(inBuf, "%d %d\n", &n, &m)
	k = n / m
	remainders = make([]int, m)
	for i := 0; i < n; i++ {
		fmt.Fscanf(inBuf, "%d ", &a[i])
		remainders[a[i] % m]++
	}
	lesser = make([]int, 0)
	for i := 0; i < m; i++ {
		if remainders[i] < k {
			lesser = append(lesser, i)
		}
	}
	ans := 0
	p1 := 0
	for i := 0; i < n; i++ {
		r := a[i] % m
		if remainders[r] > k {
			remainders[r]--
			steps := lesser[p1] - r
			if r > lesser[p1] {
				steps = n - r + lesser[p1]
			}
			ans += steps
			a[i] += steps
			remainders[lesser[p1]]++
			if remainders[lesser[p1]] == k {
				p1++
			}
		}
	}
	fmt.Println(ans)
	for i := 0; i < n; i++ {
		fmt.Print(a[i], " ")
	}
}

package main

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

const (
	MaxN = 200005
)

type rem struct {
	r, count int
}

var n, m, k int64
var a [MaxN]int64
var remainders []int64
var lesser []int64

func main() {
	inBuf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(inBuf, "%d %d\n", &n, &m)
	k = n / m
	remainders = make([]int64, m)
	for i := int64(0); i < n; i++ {
		fmt.Fscanf(inBuf, "%d ", &a[i])
		remainders[a[i] % m]++
	}
	lesser = make([]int64, 0)
	for i := int64(0); i < m; i++ {
		if remainders[i] < k {
			lesser = append(lesser, i)
		}
	}
	ans := int64(0)
	p1 := 0
	for i := int64(0); i < n; i++ {
		r := a[i] % m
		if remainders[r] > k {
			remainders[r]--
			steps := lesser[p1] - r
			if r > lesser[p1] {
				steps = n - r + lesser[p1]
			}
			ans += steps
			a[i] += steps
			remainders[lesser[p1]]++
			if remainders[lesser[p1]] == k {
				p1++
			}
		}
	}
	fmt.Println(ans)
	for i := int64(0); i < n; i++ {
		fmt.Print(a[i], " ")
	}
}

package main

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

const (
	MaxN = 200005
)

type rem struct {
	r, count int
}

var n, m, k int64
var a [MaxN]int64
var remainders []int64
var lesser []int64

func main() {
	inBuf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(inBuf, "%d %d\n", &n, &m)
	k = n / m
	remainders = make([]int64, m)
	for i := int64(0); i < n; i++ {
		fmt.Fscanf(inBuf, "%d ", &a[i])
		remainders[a[i] % m]++
	}
	lesser = make([]int64, 0)
	for i := int64(m - 1); i >= 0; i-- {
		if remainders[i] < k {
			lesser = append(lesser, i)
		}
	}
	ans := int64(0)
	p1, p2 := 0, len(lesser) - 1
	for i := int64(0); i < n; i++ {
		r := a[i] % m
		if remainders[r] > k {
			remainders[r]--
			steps1 := lesser[p1] - r
			if r > lesser[p1] {
				steps1 = m - r + lesser[p1]
			}
			steps2 := lesser[p2] - r
			if r > lesser[p2] {
				steps1 = m - r + lesser[p2]
			}
			if steps1 > steps2 {
				ans += steps1
				a[i] += steps1
				remainders[lesser[p1]]++
				if remainders[lesser[p1]] == k {
					p1++
				}
			} else {
				ans += steps2
				a[i] += steps2
				remainders[lesser[p2]]++
				if remainders[lesser[p2]] == k {
					p2--
				}
			}
		}
	}
	fmt.Println(ans)
	for i := int64(0); i < n; i++ {
		fmt.Print(a[i], " ")
	}
}

package main

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

const (
	MaxN = 200005
)

type rem struct {
	r, count int
}

var n, m, k int64
var a [MaxN]int64
var remainders []int64
var lesser []int64

func main() {
	inBuf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(inBuf, "%d %d\n", &n, &m)
	k = n / m
	remainders = make([]int64, m)
	for i := int64(0); i < n; i++ {
		fmt.Fscanf(inBuf, "%d ", &a[i])
		remainders[a[i] % m]++
	}
	lesser = make([]int64, 0)
	for i := int64(m - 1); i >= 0; i-- {
		if remainders[i] < k {
			lesser = append(lesser, i)
		}
	}
	ans := int64(0)
	p1 := 0
	for i := int64(0); i < n; i++ {
		r := a[i] % m
		if remainders[r] > k {
			remainders[r]--
			steps := lesser[p1] - r
			if r > lesser[p1] {
				steps = m - r + lesser[p1]
			}
			ans += steps
			a[i] += steps
			remainders[lesser[p1]]++
			if remainders[lesser[p1]] == k {
				p1++
			}
		}
	}
	fmt.Println(ans)
	for i := int64(0); i < n; i++ {
		fmt.Print(a[i], " ")
	}
}

package main

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

const (
	MaxN = 200005
)

type rem struct {
	r, index int64
}

var n, m, k int64
var a [MaxN]int64
var remainders []int64
var indexes [][]int64

func main() {
	inBuf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(inBuf, "%d %d\n", &n, &m)
	k = n / m
	remainders = make([]int64, m)
	indexes = make([][]int64, m)
	for i := int64(0); i < n; i++ {
		fmt.Fscanf(inBuf, "%d ", &a[i])
		r := a[i] % m
		remainders[r]++
		indexes[r] = append(indexes[r], i)
	}

	ans := int64(0)
	q := make([]rem, 0)
	for i := int64(0); i < 2*m; i++ {
		r := i % m
		for l := len(indexes[r]); remainders[r] > k; l-- {
			q = append(q, rem{r: r, index: indexes[r][l-1]})
			indexes[r] = indexes[r][:l-1]
			remainders[r]--
		}
		for l := len(q); remainders[r] < k && l > 0; l-- {
			remainders[r]++
			t := q[l-1]
			q = q[:l-1]
			step := (m + i - t.r) % m
			ans += step
			a[i] += step
		}
	}
	fmt.Println(ans)
	for i := int64(0); i < n; i++ {
		fmt.Print(a[i], " ")
	}
}


package main

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

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	// even = filler -> present or not they don't affect the outcome
	defer out.Flush()
	q := 0
	fmt.Fscan(in, &q)
	for ; q > 0; q-- {
		n, k := 0, 0
		cntOdd := 0
		fmt.Fscan(in, &n, &k)
		as := make([]int, n)
		for i := range as {
			fmt.Fscan(in, &as[i])
			if isOdd(as[i]) {
				cntOdd++
			}
		}
		restOdd := cntOdd - (k - 1)
		if k > cntOdd ||
			// too many odds -> reduce to a single one ( require odd number of exceeding odds )
			cntOdd > k && !isOdd(restOdd) {
			fmt.Fprintln(out, "NO")
			continue
		}
		fmt.Fprintln(out, "YES")
		i := 0
		// k - ( 1 last segment: the rest of odds )
		for k-1 > 0 {
			if isOdd(as[i]) {
				fmt.Fprintf(out, "%d ", i+1)
				k--
			}
			i++
		}
		// rest of odds
		fmt.Fprintf(out, "%d\n", n)
	}
}

package main

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

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	// even = filler -> present or not they don't affect the outcome
	defer out.Flush()
	q := 0
	fmt.Fscan(in, &q)
	for ; q > 0; q-- {
		n, k := 0, 0
		cntOdd := 0
		fmt.Fscan(in, &n, &k)
		as := make([]int, n)
		for i := range as {
			fmt.Fscan(in, &as[i])
			if isOdd(as[i]) {
				cntOdd++
			}
		}
		restOdd := cntOdd - (k - 1)
		if k > cntOdd ||
			// too many odds -> reduce to a single one ( require odd number of exceeding odds )
			cntOdd > k && !isOdd(restOdd) {
			fmt.Fprintln(out, "NO")
			continue
		}
		fmt.Fprintln(out, "YES")
		subseg := cntOdd - restOdd
		i := 0
		for subseg > 0 {
			if isOdd(as[i]) {
				fmt.Fprintf(out, "%d ", i+1)
				subseg--
			}
			i++
		}
		// rest of odds
		fmt.Fprintf(out, "%d\n", n)
	}
}

package main

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

func main() {

	//stdin, err := os.Open("test.txt")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdin.Close()
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	//stdout, err := os.Create("test.txt")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdout.Close()
	stdout := os.Stdout
	writer := bufio.NewWriterSize(stdout, 1024*1024)

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

	for i := 0; i < q; i++ {
		var n, k, odd int
		r := make([]int, 0)
		fmt.Fscanf(reader, "%d %d\n", &n, &k)
		for j := 0; j < n; j++ {
			var a int64
			fmt.Fscanf(reader, "%d", &a)
			if a%2 == 1 {
				odd++
				r = append(r, j)
			}
		}
		fmt.Fscanf(reader, "\n")
		if odd < k {
			fmt.Fprintf(writer, "NO\n")
		} else {
			if odd-k > 0 && (odd-k)%2 == 1 {
				fmt.Fprintf(writer, "NO\n")
			} else {
				fmt.Fprintf(writer, "YES\n")
				for j := 0; j < k; j++ {
					if k-1 == j {
						fmt.Fprintf(writer, "%d ", n)
					} else {
						fmt.Fprintf(writer, "%d ", r[j]+1)
					}
				}
				fmt.Fprintf(writer, "\n")
			}
		}
	}

	writer.Flush()
}

package main

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

/* solution */

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

func solveOne() {
	n, k := readInt(), readInt()
	sum := 0
	cnt := 0
	ans := make([]int, k)
	for i := 0; i < n; i++ {
		sum = (sum + readInt()) % 2
		if cnt == k-1 {
			continue
		}
		if sum == 1 {
			sum = 0
			ans[cnt] = i + 1
			cnt++
		}
	}
	if cnt == k-1 && sum == 1 {
		println("YES")
		for i := 0; i < k-1; i++ {
			printInt(ans[i])
		}
		printInt(n)
		println("")
	} else {
		println("NO")
	}
}

/* stubs */

func main() {

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

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

	reader = bufio.NewScanner(f)

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

	reader.Split(bufio.ScanWords)

	solve()

}

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

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

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

func println(s string) {
	if len(s) > 0 {
		writer.WriteString(s)
	}
	writer.WriteString("\n")
}

func print(s string) {
	if len(s) > 0 {
		writer.WriteString(s)
	}
	writer.WriteString(" ")
}

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

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

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

package main

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

type Solution struct {
	Exists bool
	Array  []int
}

func readArray(size int, reader *bufio.Reader) []int {
	a := make([]int, size)
	for i := 0; i < size; i++ {
		fmt.Fscanf(reader, "%d", &a[i])
	}
	fmt.Fscanf(reader, "\n")
	return a
}

func printSolution(solution Solution, writer *bufio.Writer) {
	if solution.Exists {
		fmt.Fprintf(writer, "YES\n")
		for _, elem := range solution.Array {
			fmt.Fprintf(writer, "%d ", elem)
		}
		fmt.Fprintf(writer, "\n")
	} else {
		fmt.Fprintf(writer, "NO\n")
	}
}

func lastXOdd(a []int, x int, odd int) []int {
	array := []int{}
	for i, elem := range a {
		if elem%2 == 1 && odd > x {
			odd -= 1
		} else if elem%2 == 1 {
			array = append(array, i+1)
		}
	}
	return array
}

func Solve(n int, k int, a []int) Solution {
	oddCount := 0
	for _, elem := range a {
		if elem%2 == 1 {
			oddCount += 1
		}
	}
	if oddCount < k {
		return Solution{Exists: false}
	} else if (oddCount-k)%2 == 0 {
		arr := lastXOdd(a, k, oddCount)
		arr[k-1] = n
		return Solution{Exists: true, Array: arr}
	}
	return Solution{Exists: false}
}

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

	var q int
	fmt.Fscanf(reader, "%d\n", &q)
	for i := 0; i < q; i++ {
		var n, k int
		fmt.Fscanf(reader, "%d %d\n", &n, &k)
		a := readArray(n, reader)
		solution := Solve(n, k, a)
		printSolution(solution, writer)
	}
}

package main

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

func main() {
	var n, s, q, d int64

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Scanln(&q)

	for i := int64(0); i < q; i++ {

		fmt.Fscanln(scr, &n, &s)
		a := make([]int64, n)
		sum := int64(0)

		for i := int64(0); i < n; i++ {
			fmt.Fscanf(scr, "%d", &a[i])
			sum += a[i]
		}
		fmt.Fscanln(scr, &d)

		res := make([]int64, 0)
		sumRes := int64(0)

		for x, y := range a {
			sumRes += int64(y)
			if sumRes%2 == 1 && s > 2 {
				res = append(res, int64(x+1))
				sum -= sumRes
				sumRes = 0
				s--
			} else if sumRes%2 == 1 && s == 2 && int64(x+1) < n {
				if (sum-sumRes)%2 == 1 {
					res = append(res, int64(x+1))
					res = append(res, n)
					s = 0
					break
				}
			}
		}
		if s == 0 {
			fmt.Println("YES")
			for _, y := range res {
				fmt.Printf("%d ", y)
			}
			fmt.Println()
		} else if s == 1 {
			if sum%2 == 1 {
				fmt.Println("YES")
				fmt.Println(n)
			} else {
				fmt.Println("NO")
			}
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	var q, n, k, x, cnt int64

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &q)

	for i := int64(0); i < q; i++ {
		fmt.Fscanln(scr, &n, &k)
		var sum = int64(0)
		var res = int64(0)
		cnt = 0

		a := make([]int64, n)

		for i := int64(0); i < n; i++ {
			fmt.Fscanf(scr, "%d", &a[i])
			sum += a[i]
		}
		fmt.Fscanln(scr, &x)
		res1 := make([]int64, 0)

		if k >= 2 {
			for x, y := range a {
				cnt += y

				if k == 2 && cnt%2 != 0 && x < len(a)-1 {
					if (sum-cnt)%2 != 0 {
						res = 5
						res1 = append(res1, int64(x+1))
						res1 = append(res1, int64(len(a)))
						break
					}
				} else {
					if cnt%2 != 0 {
						res1 = append(res1, int64(x+1))
						sum -= cnt
						cnt = 0
						k--
					}
				}
			}
		} else {
			if sum%2 != 0 {
				res = 5
				res1 = append(res1, int64(len(a)))
			}
		}

		if res == 5 {
			fmt.Println("YES")

			for x, y := range res1 {
				if x == len(res1)-1 {
					fmt.Printf("%d\n", y)
				} else {
					fmt.Printf("%d ", y)
				}
			}
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {

	var testCase int
	reader := bufio.NewReader(os.Stdin)

	_, _ = fmt.Fscanf(reader, "%d\n", &testCase)

	for testCase > 0 {
		testCase -= 1
		var (
			totalNum int
			subNum   int
			crt      int
		)
		_, _ = fmt.Fscanf(reader, "%d %d\n", &totalNum, &subNum)
		nums := make([]int, totalNum)
		odds := make([]string, totalNum)

		for i := 0; i < totalNum; i += 1 {
			_, _ = fmt.Fscanf(reader, "%d", &nums[i])
			if nums[i]%2 == 1 {
				odds[crt] = strconv.Itoa(i + 1)
				crt += 1
			}
		}
		_, _ = fmt.Fscanf(reader, "\n")

		if crt < subNum {
			fmt.Println("NO")
			continue
		}

		if (crt-subNum)%2 == 1 {
			fmt.Println("NO")
			continue
		}

		fmt.Println("YES")
		odds = append(odds[:subNum-1], strconv.Itoa(totalNum))
		fmt.Println(strings.Join(odds, " "))
	}

}

package main

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

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

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

	for i := 0; i < q; i++ {
		var n, k int
		fmt.Fscanf(input, "%d %d\n", &n, &k)

		var count int
		var ans []int
		for j := 0; j < n; j++ {
			var x int
			fmt.Fscanf(input, "%d", &x)
			if x%2 == 1 {
				if len(ans) == k-1 {
					count++
				} else {
					ans = append(ans, j+1)
				}
			}
		}
		fmt.Fscanf(input, "\n")
		if count%2 == 1 {
			fmt.Println("YES")
			ans = append(ans, n)
			for j := range ans {
				fmt.Printf("%d", ans[j])
				if j < len(ans)-1 {
					fmt.Printf(" ")
				}
			}
			fmt.Printf("\n")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	var num int

	_, err := fmt.Fscanf(input, "%d\n", &num)
	if err != nil {
	}

	for num > 0 {
		num -= 1
		var n, k, j int

		_, err := fmt.Fscanf(input, "%v %v\n", &n, &k)
		if err != nil {
		}

		var arr = make([]int, n)
		var result = make([]string, n)

		for i := 0; i < n; i++ {
			_, err := fmt.Fscanf(input, "%v", &arr[i])
			if err != nil {
			}

			if arr[i]%2 == 1 {
				result[j] = strconv.Itoa(i + 1)
				j++
			}
		}
		_, err = fmt.Fscanf(input, "\n")
		if err != nil {
		}

		if j < k || (j-k)%2 != 0 {
			fmt.Println("NO")
			continue
		}
		fmt.Println("YES")

		total := result[:k-1]
		total = append(total, strconv.Itoa(n))

		fmt.Println(strings.Join(total, " "))
	}

}

package main

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

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	q := 0
	fmt.Fscan(in, &q)
	for ; q > 0; q-- {
		n, k := 0, 0
		cntOdd := 0
		fmt.Fscan(in, &n, &k)
		as := make([]int, n)
		// even = filler -> present or not they don't affect the outcome
		for i := range as {
			fmt.Fscan(in, &as[i])
			if isOdd(as[i]) {
				cntOdd++
			}
		}
		restOdd := cntOdd - (k - 1)
		if k > cntOdd ||
			// too many odds -> reduce to a single one ( require odd number of exceeding odds )
			cntOdd > k && !isOdd(restOdd) {
			fmt.Fprintln(out, "NO")
			continue
		}
		fmt.Fprintln(out, "YES")
		subseg := cntOdd - restOdd
		i := 0
		for subseg > 0 {
			if isOdd(as[i]) {
				fmt.Fprintf(out, "%d ", i+1)
				subseg--
			}
			i++
		}
		// rest of odds
		fmt.Fprintf(out, "%d\n", n)
	}
}

package main

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

func main() {
	var n, s, q, d int

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Scanln(&q)

	for i := 0; i < q; i++ {

		fmt.Fscanln(scr, &n, &s)
		a := make([]int, n)
		sum := 0

		for i := 0; i < n; i++ {
			fmt.Fscanf(scr, "%d", &a[i])
			sum += a[i]
		}
		fmt.Fscanln(scr, &d)

		res := make([]int, 0)
		sumRes := 0

		for x, y := range a {
			sumRes += y
			if sumRes%2 == 1 && s > 2 {
				res = append(res, x+1)
				sum -= sumRes
				sumRes = 0
				s--
			} else if sumRes%2 == 1 && s == 2 && x+1 < n {
				if (sum-sumRes)%2 == 1 {
					res = append(res, x+1)
					res = append(res, n)
					s = 0
					break
				}
			}
		}
		if s == 0 {
			fmt.Println("YES")
			for _, y := range res {
				fmt.Printf("%d ", y)
			}
			fmt.Println()
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {
	var n, s, q, d int

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Scanln(&q)

	for i := 0; i < q; i++ {

		fmt.Fscanln(scr, &n, &s)
		a := make([]int, n)
		sum := 0

		for i := 0; i < n; i++ {
			fmt.Fscanf(scr, "%d", &a[i])
			sum += a[i]
		}
		fmt.Fscanln(scr, &d)

		res := make([]int, 0)
		sumRes := 0

		for x, y := range a {
			sumRes += y
			if sumRes%2 == 1 && s > 2 {
				res = append(res, x+1)
				sum -= sumRes
				sumRes = 0
				s--
			} else if sumRes%2 == 1 && s == 2 && x+1 < n {
				if (sum-sumRes)%2 == 1 {
					res = append(res, x+1)
					res = append(res, n)
					s = 0
					break
				}
			}
		}
		if s == 0 {
			fmt.Println("YES")
			for _, y := range res {
				fmt.Printf("%d ", y)
			}
			fmt.Println()
		} else if s == 1 {
			if sum%2 == 1 {
				fmt.Println("YES")
				fmt.Println(n)
			} else {
				fmt.Println("NO")
			}
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {
	var n, s, q, d int

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Scanln(&q)

	for i := 0; i < q; i++ {

		fmt.Fscanln(scr, &n, &s)
		a := make([]int, n)
		sum := 0

		for i := 0; i < n; i++ {
			fmt.Fscanf(scr, "%d", &a[i])
			sum += a[i]
		}
		fmt.Fscanln(scr, &d)

		res := make([]int, 0)
		sumRes := 0

		for x, y := range a {
			sumRes += y
			if sumRes%2 == 1 && s > 2 {
				res = append(res, x+1)
				sum -= sumRes
				sumRes = 0
				s--
			} else if sumRes%2 == 1 && s == 2 {
				if (sum-sumRes)%2 == 1 {
					res = append(res, x+1)
					res = append(res, n)
					s = 0
					break
				}
			}
		}
		if s == 0 {
			fmt.Println("YES")
			for _, y := range res {
				fmt.Printf("%d ", y)
			}
			fmt.Println()
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {
	var q, n, k, x, cnt int64

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &q)

	for i := int64(0); i < q; i++ {
		fmt.Scanln(&n, &k)
		var sum = int64(0)
		var res = int64(0)
		cnt = 0

		a := make([]int64, n)

		for i := int64(0); i < n; i++ {
			fmt.Scanf("%d", &a[i])
			sum += a[i]
		}
		fmt.Scanln(&x)
		res1 := make([]int64, 0)

		for x, y := range a {
			cnt += y

			if k == 2 && cnt%2 != 0 && x < len(a)-1 {
				if (sum-cnt)%2 != 0 {
					res = 5
					res1 = append(res1, int64(x+1))
					res1 = append(res1, int64(len(a)))
					break
				}
			} else {
				if cnt%2 != 0 {
					res1 = append(res1, int64(x+1))
					sum -= cnt
					cnt = 0
					k--
				}
			}
		}

		if res == 5 {
			fmt.Println("YES")

			for x, y := range res1 {
				if x == len(res1)-1 {
					fmt.Printf("%d\n", y)
				} else {
					fmt.Printf("%d ", y)
				}
			}
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {
	var q, n, k, x, cnt int64

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &q)

	for i := int64(0); i < q; i++ {
		fmt.Fscanln(scr, &n, &k)
		var sum = int64(0)
		var res = int64(0)
		cnt = 0

		a := make([]int64, n)

		for i := int64(0); i < n; i++ {
			fmt.Fscanf(scr, "%d", &a[i])
			sum += a[i]
		}
		fmt.Fscanln(scr, &x)
		res1 := make([]int64, 0)

		for x, y := range a {
			cnt += y

			if k == 2 && cnt%2 != 0 && x < len(a)-1 {
				if (sum-cnt)%2 != 0 {
					res = 5
					res1 = append(res1, int64(x+1))
					res1 = append(res1, int64(len(a)))
					break
				}
			} else {
				if cnt%2 != 0 {
					res1 = append(res1, int64(x+1))
					sum -= cnt
					cnt = 0
					k--
				}
			}
		}

		if res == 5 {
			fmt.Println("YES")

			for x, y := range res1 {
				if x == len(res1)-1 {
					fmt.Printf("%d\n", y)
				} else {
					fmt.Printf("%d ", y)
				}
			}
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {
	var q, n, k, x, cnt int64

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &q)

	for i := int64(0); i < q; i++ {
		fmt.Scanln(&n, &k)
		var sum = int64(0)
		var res = int64(0)
		cnt = 0

		a := make([]int64, n)

		for i := int64(0); i < n; i++ {
			fmt.Scanf("%d", &a[i])
			sum += a[i]
		}
		fmt.Scanln(&x)
		res1 := make([]int64, 0)

		for x, y := range a {
			cnt += y

			if k == 2 && cnt%2 != 0 && x < len(a)-1 {
				if (sum-cnt)%2 != 0 {
					res = 5
					res1 = append(res1, int64(x+1))
					res1 = append(res1, int64(len(a)))
					break
				}
			} else {
				if cnt%2 != 0 {
					res1 = append(res1, int64(x+1))
					sum -= cnt
					cnt = 0
					k--
				}
			}
		}

		if res == 5 {
			fmt.Println("YES")

			for _, y := range res1 {
				fmt.Printf("%d ", y)
			}
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {
	var q, n, k, x, cnt int64

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &q)

	for i := int64(0); i < q; i++ {
		fmt.Scanln(&n, &k)
		var sum = int64(0)
		var res = int64(0)
		cnt = 0

		a := make([]int64, n)

		for i := int64(0); i < n; i++ {
			fmt.Scanf("%d", &a[i])
			sum += a[i]
		}
		fmt.Scanln(&x)
		res1 := make([]int64, 0)

		for x, y := range a {
			cnt += y

			if k == 2 && cnt%2 != 0 && x < len(a)-1 {
				if (sum-cnt)%2 != 0 {
					res = 5
					res1 = append(res1, int64(x+1))
					res1 = append(res1, int64(len(a)))
					break
				}
			} else {
				if cnt%2 != 0 {
					res1 = append(res1, int64(x+1))
					sum -= cnt
					cnt = 0
					k--
				}
			}
		}

		if res == 5 {
			fmt.Println("YES")

			for _, y := range res1 {
				fmt.Printf("%d ", y)
			}
			fmt.Println()
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {
	var n, s, q, d int

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Scanln(&q)

	for i := 0; i < q; i++ {

		fmt.Fscanln(scr, &n, &s)
		a := make([]int, n)
		sum := 0

		for i := 0; i < n; i++ {
			fmt.Fscanf(scr, "%d", &a[i])
			sum += a[i]
		}
		fmt.Println(a, n, s)
		fmt.Fscanln(scr, &d)

		res := make([]int, 0)
		sumRes := 0

		for x, y := range a {
			sumRes += y
			if sumRes%2 == 1 && s > 2 {
				res = append(res, x+1)
				sum -= sumRes
				sumRes = 0
				s--
			} else if sumRes%2 == 1 && s == 2 {
				if (sum-sumRes)%2 == 1 {
					res = append(res, x+1)
					res = append(res, n)
					s = 0
					break
				}
			}
		}
		if s == 0 {
			fmt.Println("YES")
			for _, y := range res {
				fmt.Printf("%d ", y)
			}
			fmt.Println()
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {
	var q, n, k, x, cnt int64

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &q)

	for i := int64(0); i < q; i++ {
		fmt.Fscanln(scr, &n, &k)
		var sum = int64(0)
		var res = int64(0)
		cnt = 0

		a := make([]int64, n)

		for i := int64(0); i < n; i++ {
			fmt.Fscanf(scr, "%d", &a[i])
			sum += a[i]
		}
		fmt.Fscanln(scr, &x)
		res1 := make([]int64, 0)

		if k > 2 {
			for x, y := range a {
				cnt += y

				if k == 2 && cnt%2 != 0 && x < len(a)-1 {
					if (sum-cnt)%2 != 0 {
						res = 5
						res1 = append(res1, int64(x+1))
						res1 = append(res1, int64(len(a)))
						break
					}
				} else {
					if cnt%2 != 0 {
						res1 = append(res1, int64(x+1))
						sum -= cnt
						cnt = 0
						k--
					}
				}
			}
		} else {
			if sum%2 != 0 {
				res = 5
				res1 = append(res1, int64(len(a)))
			}
		}

		if res == 5 {
			fmt.Println("YES")

			for x, y := range res1 {
				if x == len(res1)-1 {
					fmt.Printf("%d\n", y)
				} else {
					fmt.Printf("%d ", y)
				}
			}
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {
	var q, n, k, x, cnt int64

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &q)

	for i := int64(0); i < q; i++ {
		fmt.Scanln(&n, &k)
		var sum = int64(0)
		var res = int64(0)
		cnt = 0

		a := make([]int64, n)

		for i := int64(0); i < n; i++ {
			fmt.Scanf("%d", &a[i])
			sum += a[i]
		}
		fmt.Scanln(&x)
		res1 := make([]int64, 0)

		for x, y := range a {
			cnt += y

			if k == 2 && cnt%2 != 0 && x < len(a)-1 {
				if (sum-cnt)%2 != 0 {
					res = 5
					res1 = append(res1, int64(x+1))
					res1 = append(res1, int64(len(a)))
					break
				}
			} else {
				if cnt%2 != 0 {
					res1 = append(res1, int64(x+1))
					sum -= cnt
					cnt = 0
					k--
				}
			}
		}

		if res == 5 {
			fmt.Println("YES")

			for _, y := range res1 {
				fmt.Printf("%d", y)
			}
		} else {
			fmt.Println("NO")
		}

	}

}

package main

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

func main() {

	var testCase int
	reader := bufio.NewReader(os.Stdin)

	_, _ = fmt.Fscanf(reader, "%d\n", &testCase)

	for testCase > 0 {
		testCase -= 1
		var (
			totalNum int
			subNum   int
			crt      int
		)
		_, _ = fmt.Fscanf(reader, "%d %d\n", &totalNum, &subNum)
		nums := make([]int, totalNum)
		odds := make([]string, totalNum)

		for i := 0; i < totalNum; i += 1 {
			_, _ = fmt.Fscanf(reader, "%d", &nums[i])
			if nums[i]%2 == 1 {
				odds[crt] = strconv.Itoa(i + 1)
				crt += 1
			}
		}
		_, _ = fmt.Fscanf(reader, "\n")

		if crt < subNum {
			fmt.Println("NO")
			continue
		}

		if (crt-subNum)%2 == 1 {
			fmt.Println("NO")
			continue
		}

		fmt.Println("YES")
		fmt.Println(strings.Join(odds[:subNum], " "))
	}

}

package main

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

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	// even = filler -> present or not they don't affect the outcome
	defer out.Flush()
	q := 0
	fmt.Fscan(in, &q)
	for ; q > 0; q-- {
		n, k := 0, 0
		cntOdd := 0
		fmt.Fscan(in, &n, &k)
		as := make([]int, n)
		for i := range as {
			fmt.Fscan(in, &as[i])
			if isOdd(as[i]) {
				cntOdd++
			}
		}
		restOdd := cntOdd - (k - 1)
		if k > cntOdd ||
			// too many odds -> reduce to a single one ( require odd number of exceeding odds )
			cntOdd > k && !isOdd(restOdd) {
			fmt.Fprintln(out, "NO")
			continue
		}
		fmt.Fprintln(out, "YES")
		for i, a := range as {
			if isOdd(a) {
				fmt.Fprintf(out, " %d", i+1)
			}
		}
		fmt.Fprintln(out)
	}
}

package main

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

func main() {

	//stdin, err := os.Open("test.txt")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdin.Close()
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	//stdout, err := os.Create("test.txt")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdout.Close()
	stdout := os.Stdout
	writer := bufio.NewWriterSize(stdout, 1024*1024)

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

	for i := 0; i < q; i++ {
		var n, k, odd int
		r := make([]int, 0)
		fmt.Fscanf(reader, "%d %d\n", &n, &k)
		for j := 0; j < n; j++ {
			var a int64
			fmt.Fscanf(reader, "%d", &a)
			if a%2 == 1 {
				odd++
				r = append(r, j)
			}
		}
		fmt.Fscanf(reader, "\n")
		if odd < k {
			fmt.Fprintf(writer, "NO\n")
		} else {
			if odd%2 == 0 {
				fmt.Fprintf(writer, "NO\n")
			} else {
				fmt.Fprintf(writer, "YES\n")
				for j := 0; j < k; j++ {
					if k-1 == j {
						fmt.Fprintf(writer, "%d ", n)
					} else {
						fmt.Fprintf(writer, "%d ", r[j]+1)
					}
				}
				fmt.Fprintf(writer, "\n")
			}
		}
	}

	writer.Flush()
}

package main

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

func main() {

	//stdin, err := os.Open("test.txt")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdin.Close()
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	//stdout, err := os.Create("test.txt")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdout.Close()
	stdout := os.Stdout
	writer := bufio.NewWriterSize(stdout, 1024*1024)

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

	for i := 0; i < q; i++ {
		var n, k, odd int
		r := make([]int, 0)
		fmt.Fscanf(reader, "%d %d\n", &n, &k)
		for j := 0; j < n; j++ {
			var a int64
			fmt.Fscanf(reader, "%d", &a)
			if a%2 == 1 {
				odd++
				r = append(r, j)
			}
		}
		fmt.Fscanf(reader, "\n")
		if odd < k {
			fmt.Fprintf(writer, "NO\n")
		} else {
			if odd%2 == 0 {
				fmt.Fprintf(writer, "NO\n")
			} else {
				fmt.Fprintf(writer, "YES\n")
				for j := 0; j < k; j++ {
					fmt.Fprintf(writer, "%d ", r[j]+1)
				}
				fmt.Fprintf(writer, "\n")
			}
		}
	}

	writer.Flush()
}


package main

import "fmt"

func main() {
	var n, d int
	fmt.Scanln(&n, &d)

	all := ""
	for i := 0; i < n; i++ {
		all = fmt.Sprintf("%s1", all)
	}

	var current, best int
	for i := 0; i < d; i++ {
		var line string
		fmt.Scanln(&line)
		if line != all {
			current++
			if best < current {
				best = current
			}
		} else {
			current = 0
		}
	}

	fmt.Println(best)
}

package main

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

var (
	scan   = fmt.Scan
	writer = bufio.NewWriter(os.Stdout)
	print  = writer.WriteString
)

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

func main() {

	var ans int
	var n, m int
	scan(&m, &n)
	var cnt int
	for i := 1; i <= n; i++ {
		var ok = false
		var s string
		scan(&s)
		for i := 0; i < len(s); i++ {
			if s[i] == '0' {
				ok = true
				break
			}
		}
		if ok == true {
			cnt++
		} else {
			cnt = 0
		}
		ans = max(ans, cnt)
	}
	fmt.Println(ans)
}

package main

import (
    "fmt"
)

func main() {
    var s string
    var n, d, curr, max int

    fmt.Scanf("%d%d\n", &n, &d)

    for i := 0; i < d; i++ {
        fmt.Scanf("%s\n", &s)

        var win = false
        for j := 0; j < n; j++ {
            win = win || (s[j] == '0')
        }

        if curr++; !win {
            curr = 0
        }

        if curr > max {
            max = curr
        }
    }

    fmt.Println(max)
}

package main

import (
	"fmt"
	"strings"
)

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

	var s string
	days := 0
	max := 0
	for i := 0; i < d; i++ {
		fmt.Scan(&s)
		if strings.Count(s, "1") < n {
			days++
			if days > max {
				max = days
			}
		} else {
			days = 0
		}
	}

	fmt.Println(max)
}

package main

import "fmt"

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

func main() {
    var buff string;
    var n, d int;
    fmt.Scanf("%d%d\n", &n, &d);
    ans, cnt := 0, 0;

    for i := 0; i < d; i++ {
        fmt.Scanf("%s\n", &buff);
        //fmt.Println("buff =", buff);
        flag := false;
        for j := 0; j < n; j++ {
            if buff[j] == '0' {
                flag = true;
                break;
            }
        }
        if flag {
            cnt += 1;
            ans = max(ans, cnt);
            //fmt.Printf("ans = %d\n", ans);
        } else {
            cnt = 0;
            //fmt.Printf("clear: %d\n", i);
        }
    }

    fmt.Printf("%d\n", ans);
}

package main

import "fmt"

func main() {
    var n, d int
    fmt.Scan(&n, &d)
    presents := make([]int, d+1)
    for i:=0; i<d; i++ {
        var s string
        fmt.Scan(&s)
        var allPresent bool = true
        for _, c := range s {
            if c == '0' {
                allPresent = false
            }
        }
        if allPresent {
            presents[i] = 1
        }
    }
    presents[d] = 1
    maxDays := 0
    curDays := 0
    for i:=0; i <= d; i++ {
        if presents[i] == 0 {
            curDays++
            if maxDays < curDays {
                maxDays = curDays
            }
        } else {
            curDays = 0
        }
    }
    fmt.Print(maxDays)
}

package main

import (
	"fmt"
)

func check(s string) bool {
	for _, v := range s {
		if v == '0' {
			return true
		}
	}
	return false
}
func main() {
	var n, d int
	fmt.Scan(&n, &d)
	mx := 0
	cont := 0
	for i := 0; i < d; i++ {
		var s string
		fmt.Scan(&s)
		if check(s) {
			cont++
			mx = max(mx, cont)
		} else {
			cont = 0
		}

	}
	fmt.Println(mx)
}
func max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	s := strings.Split(scanner.Text(), " ")
	n, _ := strconv.ParseInt(s[0], 10, 64)

	var i int64
	comp := ""
	for i = 0; i < n; i++ {
		comp += "1"
	}
	c := 0
	mc := 0
	for scanner.Scan() {
		s := scanner.Text()
		if s != comp {
			c++
		} else {
			if c > mc {
				mc = c
			}
			c = 0
		}
	}
	if c > mc {
		mc = c
	}
	fmt.Printf("%d", mc)
}

package main

import (
	"fmt"
)

func main() {
	var n,d int
	fmt.Scan(&n,&d)
	var v,l int
	var x string
	for i :=0;i<n;i++ {
		x += "1"
	}
	for i:=0;i<d;i++{
		var s string
		fmt.Scan(&s)
		if  s != x{
			l++
		} else {
			l = 0
		}
		if l>v {
			v = l
		}
	}
	fmt.Println(v)
}

package main

import (
	"fmt"
)

func main() {
	var n, d int;

	if c, err := fmt.Scanf("%d %d\n", &n, &d); c != 2 || err != nil {
		panic("invalid input")
	}

	var line string
	maxWinLen, winLen := 0, 0;

	for i := 0; i < d; i++ {
		fmt.Scanln(&line)

		if isWin(line, n) {
			winLen++;

			if winLen > maxWinLen {
				maxWinLen = winLen;
			}
		} else {
			winLen = 0;
		}
	}

	fmt.Println(maxWinLen)
}

func isWin(line string, n int) bool {
	for j := 0; j < n; j++ {
		if line[j] != '1' {
			return true;
		}
	}

	return false;
}

package main

import "fmt"

func main() {
	var n, d int
	var s string
	max_wins := 0
	wins := 0
	fmt.Scan(&n, &d)
	for i := 0; i < d; i++ {
		flag := false
		fmt.Scan(&s)
		for j := 0; j < n; j++ {
			if s[j] == '0' {
				wins++
				flag = true
				break
			}
		}
		if !flag {
			if wins > max_wins {
				max_wins = wins
			}
			wins = 0
		}
	}
	if wins > max_wins {
		max_wins = wins
	}
	fmt.Println(max_wins)
}

package main

import "fmt"

func main(){
    var(
       n int
       d int
    )
    fmt.Scanf("%d %d\n",&n,&d)
    var ans int
    ans=-1
    var str [104]string
    for i:=0; i<d; i++ {
	var ss string
	fmt.Scanf("%s\n",&ss)
	str[i]=ss
    }
    count:=0
    for i:=0; i<d; i++ {
	var ones int
	ones = 0
	for j:=0; j<n; j++ {
	    if str[i][j]==49 {
		ones+=1
	    }
	}
	if ones!=n{
	    count++;
	}else {
	    if ans < count{
		ans=count
	    }
		count=0
	}
	if i==d-1{
	    if ans < count{
		ans=count
	    }
	}
    }
    fmt.Printf("%d\n",ans)
}

package main

import "fmt"

func main(){
    var(
       n int
       d int
    )
    fmt.Scanf("%d %d\n",&n,&d)
    var ans int
    ans=-1
    var str [104]string
    for i:=0; i<d; i++ {
	var ss string
	fmt.Scanf("%s\n",&ss)
	str[i]=ss
    }
    count:=0
    for i:=0; i<d; i++ {
	var ones int
	ones = 0
	for j:=0; j<n; j++ {
	    if str[i][j]==49 {
		ones+=1
	    }
	}
	if ones!=n{
	    count++;
	}else {
	    if ans < count{
		ans=count
		count=0
	    }
	}
	if i==d-1{
	    if ans < count{
		ans=count
	    }
	}
    }
    fmt.Printf("%d\n",ans)
}

package main

import "fmt"

func main() {
    var n, d int
    fmt.Scan(&n, &d)
    presents := make([]int, d+1)
    for i:=0; i<n; i++ {
        var s string
        fmt.Scan(&s)
        for d, c := range s {
            if c == '1' {
                presents[d]++
            }
        }
    }
    for i:=0; i<d; i++ {
        presents[i] /= d
    }
    presents[d] = 1
    maxDays := 0
    curDays := 0
    for i:=0; i <= d; i++ {
        if presents[i] == 0 {
            curDays++
            if maxDays < curDays {
                maxDays = curDays
            }
        } else {
            curDays = 0
        }
    }
    fmt.Print(maxDays)
}

package main

import "fmt"

func main() {
    var n, d int
    fmt.Scan(&n, &d)
    presents := make([]int, d+1)
    for i:=0; i<n; i++ {
        var s string
        fmt.Scan(&s)
        for d, c := range s {
            if c == '1' {
                presents[d]++
            }
        }
    }
    for i:=0; i<d; i++ {
        presents[i] /= d
    }
    presents[d] = 1
    maxDays := 0
    curDays := 0
    for i:=0; i <= d; i++ {
        if presents[i] == 0 {
            curDays++
            if maxDays < curDays {
                maxDays = curDays
            }
        } else {
            curDays = 0
        }
    }
}

package main

import (
	"fmt"
	"strconv"
	"math"
)

func main() {
	var n,d int
	fmt.Scan(&n,&d)
	var v,l int
	for i:=0;i<d;i++{
		var s string
		fmt.Scan(&s)
		j,_ := strconv.ParseInt(s,2,64)
		if  j != int64(math.Pow(2,float64(n)))-1 {
			l++
		} else {
			l = 0
		}
		if l>v {
			v = l
		}
	}
	fmt.Println(v)
}


package main

import "fmt"

func main() {
	var a, b int64
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		fmt.Scan(&a, &b)
		if a%b == 0 {
			fmt.Println(0)
		} else {
			var mul = a / b
			fmt.Println((mul+1)*b - a)
		}
	}
}

package main

import "fmt"

func main() {
    var t, a, b int

    fmt.Scan(&t)
    for i := 0; i < t; i++ {
        fmt.Scan(&a)
        fmt.Scan(&b)
        fmt.Println((b - a % b) % b)
    }
}

package main

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

//func Max(a, b int64) int64 {
//	if a > b {
//		return a
//	}
//	return b
//}
//
//func Min(a, b int64) int64 {
//	if a > b {
//		return b
//	}
//	return a
//}

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

func main() {
	var t int
	fmt.Fscan(scanner, &t)
	for ; t > 0; t-- {
		var a, b int
		fmt.Fscan(scanner, &a, &b)
		if a%b == 0 {
			fmt.Fprintln(writer, 0)
		} else {
			fmt.Fprintln(writer, (a/b+1)*b-a)
		}
	}
	writer.Flush()
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	// reader := fileReader("/Users/bmancini/code/go/src/github.com/bmancini55/go-playpen/codeforces/p1328a/input.txt")

	t, err := readInt(reader)
	if err != nil {
		log.Fatal(err)
	}

	tuples, err := readInts(reader, t)
	if err != nil {
		log.Fatal(err)
	}

	for _, tuple := range tuples {
		a := tuple[0]
		b := tuple[1]

		// fmt.Printf("a: %d, b %d, mod: %d, eq: %v\n", a, b, a%b, a%b == 0)
		if a%b == 0 {
			fmt.Printf("%d\n", 0)
		} else {
			r := b - (a % b)
			fmt.Printf("%d\n", r)
		}
	}

}

func fileReader(path string) *bufio.Reader {
	var (
		f   *os.File
		r   *bufio.Reader
		err error
	)

	f, err = os.Open(path)
	if err != nil {
		log.Fatal(err)
	}

	r = bufio.NewReader(f)
	return r
}

func readInt(reader *bufio.Reader) (int, error) {
	var (
		result int
		err    error
	)

	line, err := reader.ReadString('\n')
	if err != nil {
		return 0, err
	}

	fields := strings.Fields(line)
	result, err = strconv.Atoi(fields[0])

	if err != nil {
		return 0, err
	}

	return result, nil
}

func readInts(reader *bufio.Reader, n int) ([][]int, error) {
	results := [][]int{}

	for i := 0; i < n; i++ {
		line, err := reader.ReadString('\n')
		if err != nil {
			return nil, err
		}

		nums, err := parseInts(line)
		if err != nil {
			return nil, err
		}

		results = append(results, nums)
	}
	return results, nil
}

func parseInts(s string) ([]int, error) {
	var (
		fields = strings.Fields(s)
		ints   = make([]int, len(fields))
		err    error
	)
	for i, f := range fields {
		ints[i], err = strconv.Atoi(f)
		if err != nil {
			return nil, err
		}
	}
	return ints, nil
}

package main

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

// https://codeforces.com/problemset/problem/1328/A
// A. Divisibility Problem
// time limit per test
// 1 second
// memory limit per test
// 256 megabytes
// input
// standard input
// output
// standard output

// You are given two positive integers a
// and b. In one move you can increase a by 1 (replace a with a+1). Your task is to find the minimum number of moves you need to do in order to make a divisible by b. It is possible, that you have to make 0 moves, as a is already divisible by b. You have to answer t

// independent test cases.
// Input

// The first line of the input contains one integer t
// (1≤t≤104) — the number of test cases. Then t

// test cases follow.

// The only line of the test case contains two integers a
// and b (1≤a,b≤109

// ).
// Output

// For each test case print the answer — the minimum number of moves you need to do in order to make a
// divisible by b.

func main() {
	bufStdin := bufio.NewReader(os.Stdin)
	bufStdout := bufio.NewWriter(os.Stdout)

	var t int
	_, _ = fmt.Fscan(bufStdin, &t)

	for i := 0; i < t; i++ {
		var a, b int
		_, _ = fmt.Fscan(bufStdin, &a, &b)

		if a <= b {
			fmt.Fprintln(bufStdout, b-a)
		} else {
			// if a is already divisible by b, we don't need take any steps
			if a%b == 0 {
				fmt.Fprintln(bufStdout, 0)
			} else {
				bsInA := a / b
				nextMultiple := (bsInA + 1) * b
				fmt.Fprintln(bufStdout, nextMultiple-a)
			}

		}
	}

	_ = bufStdout.Flush()
}

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

    var t int
    fmt.Fscan(r, &t)
    for i := 0; i < t; i++ {
        var a, b, c int
        fmt.Fscan(r, &a, &b)
        if a%b == 0 {
            c = 0
        } else {
            c = b - (a%b)
        }
        fmt.Fprintln(w, c)
    }
}

package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

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

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

var sc = newScanner()

func main() {
	t := scanInt()
	for i := 0; i < t; i++ {
		a, b := scanInt(), scanInt()
		if a%b == 0 {
			fmt.Println(0)
		} else {
			fmt.Println(b - a%b)
		}
	}
}

package main

import (
	"fmt"
	"strings"
)

type numpair struct {
	a int
	b int
}

// https://codeforces.com/problemset/problem/1328/A
// комментарий к решению
// Т.к. требуется арифметика с числами, то используем fmt.Scan для считывания массива.
// Для вывода воспользуемся fmt.Sprint переведя массив необходимых операций в строку.
// Т.к. fmt.Sprint выводит данные через пробел, то задействуем strings.Replace .
// Компилятор видит, что заменяется 1 однобайтовый символ unicode на 1 однобайтовый символ unicode,
// плюс мы указываем кол-во замен, поэтому будет сгенерирован оптимальный код, как если бы мы
// производили свою арифметику с []byte
func taskSolution(a []numpair) string {
	ans := []int{}
	for _, p := range a {
		ans = append(ans, (p.b-(p.a%p.b))%p.b)
	}
	res := fmt.Sprint(ans)
	return strings.Replace(res[1:len(res)-1], " ", "\n", len(ans)-1)
}

func main() {
	var t int
	if _, err := fmt.Scan(&t); err != nil {
		panic(err)
	}

	in := []numpair{}
	for i := 0; i < t; i += 1 {
		var a, b int
		if _, err := fmt.Scan(&a, &b); err != nil {
			panic(err)
		}
		in = append(in, numpair{a: a, b: b})
	}

	fmt.Println(taskSolution(in))
}

// Author: sighduck
// URL: https://codeforces.com/contest/1328/problem/A

package main

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

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

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

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

package main

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

type WordScanner interface {
	NextInt() int
	NextInt64() int64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt() int {
	impl.Scan()
	bb := impl.Bytes()
	i := 0
	for _, b := range bb {
		i *= 10
		i += int(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextInt64() int64 {
	impl.Scan()
	bb := impl.Bytes()
	i := int64(0)
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}

type Writer interface {
	Printf(format string, a ...interface{})
	Flush()
}

type writerImpl struct {
	*bufio.Writer
}

func NewWriter(writer io.Writer) Writer {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
	fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
	impl.Writer.Flush()
}

func main() {
	reader := NewWordScanner(os.Stdin)
	writer := NewWriter(os.Stdout)
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		a := reader.NextInt64()
		b := reader.NextInt64()
		mod := a % b
		if mod != 0 {
			writer.Printf("%d\n", b-mod)
		} else {
			writer.Printf("0\n")
		}
	}
}

package main

import "fmt"

func main() {
	var t int
	_, _ = fmt.Scanf("%d\n", &t)

	for i := 0; i < t; i++ {
		var a,b int
		_, _ = fmt.Scanf("%d %d\n", &a,&b)
		if a%b == 0{
			fmt.Println(0)
		}else{
			fmt.Println(b - (a%b))
		}
	}

}

package main;
import (
    "fmt"
)
func main() {
    var test_count int
    fmt.Scanf("%d\n", &test_count)
    for i := 0; i < test_count; i++ {
        solve_test();
    }
}

func solve_test() {
    var a, b int
    fmt.Scanf("%d%d\n", &a, &b);
    if a % b == 0 {
        fmt.Println(0)
    } else {
        fmt.Println(b - a%b);
    }
}

package main

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

func main() {
	var t, x, y int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &x, &y)
		reminder := x % y
		if reminder == 0 {
			fmt.Println(0)
		} else {
			fmt.Println(y - x%y)
		}
	}
}

package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

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

// Sort
type RuneSlice []rune

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

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()
	for i := 0; i < N; i++ {
		a, b := sc.nextInt(), sc.nextInt()
		q := ceil(a, b)
		fmt.Fprintln(wtr, q*b-a)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, a, b int
	fmt.Scan(&t)
	answers := make([]int, t)
	for i := 0; i < t; i++ {
		fmt.Scan(&a, &b)
		if a%b == 0 {
			answers[i] = 0
		} else {
			answers[i] = (a/b+1)*b - a
		}
	}
	for i := 0; i < t; i++ {
		fmt.Println(answers[i])
	}
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var a, b uint32
	scanner.Scan() // ignore first input
	for scanner.Scan() {
		fmt.Sscanf(scanner.Text(), "%d %d", &a, &b)
		if a%b == 0 {
			fmt.Println(0)
		} else {
			fmt.Println(b - a%b)
		}
	}
	if err := scanner.Err(); err != nil {
		log.Println(err)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		var a, b int
		fmt.Fscan(in, &a, &b)
		if a%b == 0 {
			fmt.Fprintln(out, 0)
		} else {
			fmt.Fprintln(out, b-a%b)
		}
	}
	out.Flush()
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		var a, b int
		fmt.Fscan(in, &a, &b)
		fmt.Fprintln(out, ((a-1)/b+1)*b-a)
	}
	out.Flush()
}

package main

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

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

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func scanAllStr() (string, error) {
	str, err := reader.ReadString('\n')
	if err != nil {
		return "", err
	}
	return strings.TrimRight(str, "\n\r"), nil
}

func main() {
	defer writer.Flush()

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

	for i := 0; i < casesNumb; i++ {
		exec()
	}
}

func exec() {
	var a, b int
	scanf("%d %d\n", &a, &b)

	switch {
	case a%b == 0:
		printf("%d\n", 0)
		return
	case a < b:
		printf("%d\n", b-a)
		return
	default:
		printf("%d\n", ((a/b+1)*b)-a)
		return
	}
}

package main

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

func main(){
    var(
        t,a,b   int
        sc      =bufio.NewScanner(os.Stdin)
    )
    sc.Scan()
    t,_=strconv.Atoi(sc.Text())
    for t>0{
        sc.Scan()
        s:=strings.Split(sc.Text()," ")
        a,_=strconv.Atoi(s[0])
        b,_=strconv.Atoi(s[1])
        if a%b==0{
            fmt.Println(0)
        }else{
            fmt.Println(b*((a/b)+1)-a)
        }
        t--
    }
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	var a, b int
	for i := 0; i < t; i++ {
		fmt.Scanf("%d %d\n", &a, &b)
		fmt.Println(solve(a, b))
	}
}

func solve(a, b int) int {
	if a < b {
		return b - a
	}
	if a%b == 0 {
		return 0
	}
	return b - a%b
}

package main

import (
	"fmt"
)

func main () {
	var t, a, b, c int
	var mas []int
	fmt.Scan(&t)
	for i:=0; i<t; i++ {
		fmt.Scan(&a, &b)
		if a % b == 0 {
			mas = append(mas, 0)
		} else {
			c = b-a%b
			mas = append(mas, c)
		}
	}
	for i:=0; i<len(mas); i++ {
		fmt.Println(mas[i])
	}
}

// @problemURL url.com
package main

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

func next(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}

func atoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	// var inFile, _ = os.Open("in.txt")
	// var in = bufio.NewReader(inFile)
	var in = bufio.NewReader(os.Stdin)
	s := bufio.NewScanner(in)
	s.Split(bufio.ScanWords)

	for T := atoi(next(s)); T > 0; T-- {
		a, b := atoi(next(s)), atoi(next(s))
		if a%b == 0 {
			fmt.Println(0)
			continue
		}
		t := a % b
		fmt.Println(b - t)
	}

	// Code
}

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}
func NextInt64() int64 {
	bytes := NextBytes()
	i, err := Atoi64(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func Atoi64(b []byte) (int64, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	var n int64
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int64(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

func reverseInts(a []int) {
	for l, r := 0, len(a)-1; l < r; l, r = l+1, r-1 {
		a[l], a[r] = a[r], a[l]
	}
}

func unique(a []int) int {
	newLen := 0
	n := len(a)
	for i := 0; i < n; i++ {
		if newLen == 0 || a[i] != a[newLen-1] {
			a[newLen] = a[i]
			newLen++
		}
	}
	return newLen
}

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

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

func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	// inf, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(inf, 1000010)

	T := NextInt()

	for t := 0; t < T; t++ {
		a, b := NextInt(), NextInt()

		t := a % b
		if t != 0 {
			t = b - t
		}
		fmt.Fprintln(out, t)
	}
}

package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	for i := 0; i < N; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		fmt.Println((b - (a % b)) % b)
	}
}

package main

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

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

	var t int
	fmt.Fscanf(in, "%d\n", &t)
	for T := 0 ; T < t ; T ++ {
		var a, b int
		fmt.Fscanf(in, "%d %d\n", &a, &b)

		output := a % b
		if output > 0{
			output = b - output
		}
		fmt.Println(output)
	}

}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		if a % b == 0 {
			fmt.Println(0)
		}else{
			fmt.Println(b - (a % b))
		}
	}
}

package main

import (
	"bufio"
	"fmt"
)

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var a, b int64
		fmt.Scanf("%d %d\n", &a, &b)
		x := a / b
		y := a % b
		if y == 0 {
			fmt.Println(0)
			continue
		}
		x = (x + 1) * b - a
		fmt.Println(x)
	}
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

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

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1024 * 1024)
	n := 0
	fmt.Sscanf(readLine(reader), "%d", &n)

	for i := 0; i < n; i++ {
		line := readLine(reader)
		a,b := 0, 0
		fmt.Sscanf(line, "%d %d", &a, &b)
		if a % b == 0 {
			fmt.Println(0)
			continue
		}
		d := ((a / b) + 1)*b
		fmt.Println(d - a)
	}
}

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

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

package main

import(
	"fmt"
)

func main() {
	t := 0
	ans := []int{}
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		a := 0
		b := 0
		fmt.Scanf("%d %d\n", &a, &b)
		if a%b == 0 {
			ans = append(ans, 0)
		} else {
			ans = append(ans, (b-(a%b)))
		}
	}

	for _, x := range ans {
		fmt.Println(x)
	}
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		scanner.Scan()
		a, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		b, _ := strconv.Atoi(scanner.Text())
		if a % b == 0 {
			fmt.Println(0)
		} else {
			fmt.Println(b - a % b)
		}

	}
}

package main

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

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

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

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)
	for t>0 {
		t--
		var a,b int
		scanf("%d %d\n", &a, &b)

		if(a%b == 0) {
			printf("0\n")
		} else {
			printf("%d\n", b - (a%b))
		}
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var T, a, b int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &a, &b)
		Fprintln(out, (b-a%b)%b)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n uint16
	var a, b uint32
	fmt.Fscanf(in, "%d\n", &n)
	for i := uint16(0); i < n; i++ {
		fmt.Fscanf(in, "%d %d\n", &a, &b)
		if a%b == 0 {
			fmt.Println(a % b)
		} else {
			fmt.Println(b - a%b)
		}
	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	buf := make([]int, 0, 10)
	for i := 1; i < t+1; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		if a%b == 0 {
			buf = append(buf, 0)
		} else {
			buf = append(buf, b-(a%b))
		}
	}
	for i := 0; i < t; i++ {
		fmt.Println(buf[i])
	}

}

package main

import (
	"fmt"
)

// 5
// 10 4
// 13 9
// 100 13
// 123 456
// 92 46

func main() {
	var t int

	fmt.Scan(&t)

	for t != 0 {
		var a, b int
		fmt.Scan(&a, &b)
		if a%b == 0 {
			fmt.Println(0)
		} else {
			fmt.Println((int(a/b)+1)*b - a)
		}
		t--
	}
}

package main

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

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

	var nt, a, b int
	fmt.Fscanf(reader, "%d\n", &nt)
	for kk:=0; kk < nt; kk++ {
		fmt.Fscanf(reader, "%d %d\n", &a, &b)
		var ret = (b - a % b) % b
		fmt.Fprintf(writer, "%d\n", ret)
	}
}

package main

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

func main() {
	for t := ScanInt64(); t > 0; t-- {
		a, b := ScanInt64(), ScanInt64()
		if a % b == 0{
			P(0)
			continue
		}
		remainder := a/b
		P((b*(remainder + 1)) - a)
	}

	close(O)
	oWg.Wait()
}

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

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

func init() {
	P = fmt.Println

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

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

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

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

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

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

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

package main

import (
	"fmt"
)

func solve() {
	var a, b int
	fmt.Scan(&a, &b)
	if a%b == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(b - (a % b))
	}
}

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

package main
import (
	"fmt"
)

func main() {
    var t int
    fmt.Scan(&t)
    for i := 0; i < t; i++ {
        var a,b int
        fmt.Scan(&a)
        fmt.Scan(&b)
        c:= a%b
        if(c==0){
            fmt.Print(0)
        } else{
            fmt.Print(b-c)
        }
        fmt.Print("\n")
    }
}

package main

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

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

func read() int {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	return n
}
func wr(n int) {
	writer.WriteString(strconv.Itoa(n))
}
func wrs(st string) {
	writer.WriteString(st)
}
func main() {
	scanner.Split(bufio.ScanWords)
	var t = read()
	for ; t > 0; t-- {
		a, b := read(), read()
		wr(((a-1)/b+1)*b - a)
		wrs("\n")
	}
	writer.Flush()
}

package main

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

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

func main() {
	var t int
	Fscan(scanner, &t)
	for ; t > 0; t-- {
		var a, b int
		Fscan(scanner, &a, &b)
		Fprintln(writer, ((a-1)/b+1)*b-a)
	}
	writer.Flush()
}

package main

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

func main() {
	var t, x, y int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &x, &y)
		fmt.Println(y - x%y)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, a, b int
	fmt.Scan(&t)
	answers := make([]int, t)
	for i := 0; i > t; i++ {
		fmt.Scan(&a, &b)
		if a%b == 0 {
			answers[i] = 0
		} else {
			answers[i] = (a/b+1)*b - a
		}
	}
	for i := 0; i < t; i++ {
		fmt.Println(answers[i])
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"math/rand"
	"os"
	"strings"
)

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

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func scanAllStr() (string, error) {
	str, err := reader.ReadString('\n')
	if err != nil {
		return "", err
	}
	return strings.TrimRight(str, "\n\r"), nil
}

func main() {
	defer writer.Flush()

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

	for i := 0; i < casesNumb; i++ {
		exec()
	}

}

func exec() {
	var a, b int
	scanf("%d %d\n", &a, &b)

	if a < b {
		printf("%d\n", b-a)
		return
	}

	if isPrimeByFerma(b) {
		printf("%d\n", a-b)
		return
	}

	i := 0
	for {
		if a%b == 0 {
			break
		}
		a += 1
		i += 1
	}
	printf("%d\n", i)
}

func isPrimeByFerma(x int) bool {
	if x <= 1 || x == 4 {
		return false
	}
	if x <= 3 {
		return true
	}

	for i := 0; i < 100; i++ {
		a := 2 + rand.Int()%(x-4)

		if gcd(x, a) != 1 {
			return false
		}

		if int(math.Pow(float64(a), float64(x-1)))%x != 1 {
			return false
		}
	}

	return true
}

func gcd(a, b int) int {
	switch {
	case a < b:
		return gcd(b, a)
	case a%b == 0:
		return b
	default:
		return gcd(b, a%b)
	}
}

/**
 * Copyright shopee
 * @Author : Yuxiang.Lei
 * @MailBox: Yuxiang.Lei@shopee.com
 * @Date : 2020-03-26
 * @Version: v2.4
 **/

package main

import (
	"bufio"
	"fmt"
)

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var a, b int64
		fmt.Scanf("%d %d\n", &a, &b)
		x := a / b
		y := a % b
		if y == 0 {
			fmt.Println(0)
			break
		}
		x = (x + 1) * b - a

		fmt.Println(x)
	}
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

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

type WordScanner interface {
	NextInt() int
	NextInt64() int64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt() int {
	impl.Scan()
	bb := impl.Bytes()
	i := 0
	for _, b := range bb {
		i *= 10
		i += int(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextInt64() int64 {
	impl.Scan()
	bb := impl.Bytes()
	i := int64(0)
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}

type Writer interface {
	Printf(format string, a ...interface{})
	Flush()
}

type writerImpl struct {
	*bufio.Writer
}

func NewWriter(writer io.Writer) Writer {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
	fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
	impl.Writer.Flush()
}

func main() {
	reader := NewWordScanner(os.Stdin)
	writer := NewWriter(os.Stdout)
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		a := reader.NextInt64()
		b := reader.NextInt64()
		mod := a % b
		if mod != 0 {
			writer.Printf("%d\n", b-mod)
		} else {
			writer.Printf("0")
		}
	}
}