Vasya's bicycle chain drive consists of two parts: n stars are attached to the pedal axle, m stars are attached to the rear wheel axle. The chain helps to rotate the rear wheel by transmitting the pedal rotation.We know that the i-th star on the pedal axle has ai (0 < a1 < a2 < ... < an) teeth, and the j-th star on the rear wheel axle has bj (0 < b1 < b2 < ... < bm) teeth. Any pair (i, j) (1 ≤ i ≤ n; 1 ≤ j ≤ m) is called a gear and sets the indexes of stars to which the chain is currently attached. Gear (i, j) has a gear ratio, equal to the value .Since Vasya likes integers, he wants to find such gears (i, j), that their ratios are integers. On the other hand, Vasya likes fast driving, so among all "integer" gears (i, j) he wants to choose a gear with the maximum ratio. Help him to find the number of such gears.In the problem, fraction  denotes division in real numbers, that is, no rounding is performed.

The first input line contains integer n (1 ≤ n ≤ 50) — the number of stars on the bicycle's pedal axle. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 104) in the order of strict increasing. The third input line contains integer m (1 ≤ m ≤ 50) — the number of stars on the rear wheel axle. The fourth line contains m integers b1, b2, ..., bm (1 ≤ bi ≤ 104) in the order of strict increasing. It is guaranteed that there exists at least one gear (i, j), that its gear ratio is an integer. The numbers on the lines are separated by spaces.

Print the number of "integer" gears with the maximum ratio among all "integer" gears.

NoteIn the first sample the maximum "integer" gear ratio equals 3. There are two gears that have such gear ratio. For one of them a1 = 4, b1 = 12, and for the other a2 = 5, b3 = 15.

package main
import (
	"fmt"
)
func main() {
	var n,m,b int
	ma,c:=0,1
	fmt.Scan(&n)
	a:=make([]int,n)
	for i:=0;i<n;i++ {
		fmt.Scan(&a[i])
	}
	fmt.Scan(&m)
	for i:=0;i<m;i++ {
		fmt.Scan(&b)
		for j:=0;j<n;j++ {
			if b%a[j]==0 {
				x:=b/a[j]
				if x>ma {
					ma=x
					c=1
				} else if x==ma {
					c++
				}
				break
			}
		}
	}

	fmt.Println(c)
}

package main

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	n := scanInt(scanner)
	arr := make([]int, n)
	for i := range arr {
		arr[i] = scanInt(scanner)
	}
	bestRatio, bestCount := 0, 0
	m := scanInt(scanner)
	for i := 0; i < m; i++ {
		b := scanInt(scanner)
		for _, a := range arr {
			if b%a == 0 {
				if b/a == bestRatio {
					bestCount++
				} else if b/a > bestRatio {
					bestRatio = b/a
					bestCount = 1
				}
			}
		}
	}
	writer.WriteString(fmt.Sprintf("%d\n", bestCount))
}

package main

import "fmt"

func main() {
    var n,m int
    var a,b [55]int
    fmt.Scan(&n)
    for i := 0; i < n; i++ { fmt.Scan(&a[i]) }
    fmt.Scan(&m)
    for i := 0; i < m; i++ { fmt.Scan(&b[i]) }
    max, cnt := 0, 0
    for i := 0; i < n; i++ {
        for j := 0; j < m; j++ {
            if (b[j]%a[i]) == 0 {
                r := b[j]/a[i]
                if max == r {
                    cnt++
                } else if max < r {
                    max = r
                    cnt = 1
                }
            }
        }
    }
    fmt.Println(cnt)
}

package main

import "fmt"

func main() {
    var n,m int                                 // membuat variabel n dan m dengan tipe data int
    var a,b [55]int                             // membuat variabel a dan b dengan tipe data array of int dengan ukuran 55
    fmt.Scan(&n)                                // menerima input n
    for i := 0; i < n; i++ { fmt.Scan(&a[i]) }  // looping sebanyak n kali dan menerima input ai
    fmt.Scan(&m)                                // menerima input m
    for i := 0; i < m; i++ { fmt.Scan(&b[i]) }  // looping sebanyak m kali dan menerima input bi
    max, cnt := 0, 0                            // membuat variabel max dan cnt dengan tipe data int dengan nilai awal 0
    for i := 0; i < n; i++ {                    // looping sebanyak n kali
        for j := 0; j < m; j++ {                // looping sebanyak m kali
            if (b[j]%a[i]) == 0 {               // jika bj habis dibagi ai
                r := b[j]/a[i]                  // membuat variabel r dengan tipe data int dengan nilai bj/ai
                if max == r {                   // jika max sama dengan r
                    cnt++                       // tambahkan nilai cnt sebesar 1
                } else if max < r {             // jika max lebih kecil dari r
                    max = r                     // max diisi dengan r
                    cnt = 1                     // cnt diisi dengan 1
                }
            }
        }
    }
    fmt.Println(cnt)                            // mencetak output nilai cnt
}


Doremy is asked to test $$$n$$$ contests. Contest $$$i$$$ can only be tested on day $$$i$$$. The difficulty of contest $$$i$$$ is $$$a_i$$$. Initially, Doremy's IQ is $$$q$$$. On day $$$i$$$ Doremy will choose whether to test contest $$$i$$$ or not. She can only test a contest if her current IQ is strictly greater than $$$0$$$.If Doremy chooses to test contest $$$i$$$ on day $$$i$$$, the following happens:   if $$$a_i>q$$$, Doremy will feel she is not wise enough, so $$$q$$$ decreases by $$$1$$$;  otherwise, nothing changes.  If she chooses not to test a contest, nothing changes.Doremy wants to test as many contests as possible. Please give Doremy a solution.

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 10^5$$$, $$$1 \le q \le 10^9$$$) — the number of contests and Doremy's IQ in the beginning. The second line contains $$$n$$$ integers $$$a_1,a_2,\cdots,a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the difficulty of each contest. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case, you need to output a binary string $$$s$$$, where $$$s_i=1$$$ if Doremy should choose to test contest $$$i$$$, and $$$s_i=0$$$ otherwise. The number of ones in the string should be maximum possible, and she should never test a contest when her IQ is zero or less. If there are multiple solutions, you may output any.

NoteIn the first test case, Doremy tests the only contest. Her IQ doesn't decrease.In the second test case, Doremy tests both contests. Her IQ decreases by $$$1$$$ after testing contest $$$2$$$.In the third test case, Doremy tests contest $$$1$$$ and $$$2$$$. Her IQ decreases to $$$0$$$ after testing contest $$$2$$$, so she can't test contest $$$3$$$.

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		t--
		var n, q int
		fmt.Fscan(in, &n, &q)
		a := make([]int, n+5)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
		}

		vis := make([]int, n+5)
		iq := 0
		for i := n; i >= 1; i-- {
			if a[i] <= iq {
				vis[i] = 1
			} else if iq < q {
				iq++
				vis[i] = 1
			}
		}
		ret := []byte{}
		for i := 1; i <= n; i++ {
			if vis[i] == 1 {
				ret = append(ret, '1')
			} else {
				ret = append(ret, '0')
			}
		}
		fmt.Fprintln(out, string(ret))
	}
}

package main

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

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

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n, k := readTwoNums(reader)
		A := readNNums(reader, n)
		res := solve(A, k)
		buf.WriteString(fmt.Sprintf("%s\n", res))
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

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

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

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

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

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

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

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

	return i
}

func solve(A []int, iq int) string {
	n := len(A)
	res := make([]byte, n)

	var cur int

	for i := n - 1; i >= 0; i-- {
		if A[i] > cur && cur == iq {
			res[i] = '0'
		} else {
			res[i] = '1'
			if A[i] > cur {
				cur++
			}
		}
	}

	return string(res)
}
func solve1(A []int, iq int) string {
	// when iq > A[i], always to test
	// when iq <= A[i], may test, but iq--, else not stay no change
	// only when iq > 0, can test
	n := len(A)

	check := func(x int) bool {
		// if x is the first bad contest
		// can we start from x, and take all the contests
		cur := iq
		for i := x; i < n; i++ {
			if cur == 0 {
				return false
			}
			if A[i] > cur {
				cur--
			}
		}
		return true
	}

	l, r := 0, n
	for l < r {
		mid := (l + r) / 2
		if check(mid) {
			r = mid
		} else {
			l = mid + 1
		}
	}
	res := make([]byte, n)

	for i := 0; i < r; i++ {
		if iq >= A[i] {
			res[i] = '1'
		} else {
			res[i] = '0'
		}
	}

	for i := r; i < n; i++ {
		res[i] = '1'
	}

	return string(res)
}

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

package main

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

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

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n, k := readTwoNums(reader)
		A := readNNums(reader, n)
		res := solve(A, k)
		buf.WriteString(fmt.Sprintf("%s\n", res))
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

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

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

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

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

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

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

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

	return i
}

func solve(A []int, iq int) string {
	// when iq > A[i], always to test
	// when iq <= A[i], may test, but iq--, else not stay no change
	// only when iq > 0, can test
	n := len(A)

	check := func(x int) bool {
		// if x is the first bad contest
		// can we start from x, and take all the contests
		cur := iq
		for i := x; i < n; i++ {
			if cur == 0 {
				return false
			}
			if A[i] > cur {
				cur--
			}
		}
		return true
	}

	l, r := 0, n
	for l < r {
		mid := (l + r) / 2
		if check(mid) {
			r = mid
		} else {
			l = mid + 1
		}
	}
	res := make([]byte, n)

	for i := 0; i < r; i++ {
		if iq >= A[i] {
			res[i] = '1'
		} else {
			res[i] = '0'
		}
	}

	for i := r; i < n; i++ {
		res[i] = '1'
	}

	return string(res)
}

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

package main

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

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

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

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

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

func run_test_case(in *bufio.Reader) {

	line1 := readArrInt(in)
	contests := line1[0]
	start_iq := line1[1]

	contest_difficulty := readArrInt(in)
	contest_tested := make([]int, 0, 10)
	for i := 0; i < contests; i++ {
		contest_tested = append(contest_tested, 0)
	}

	// Work backwards from the end, from an IQ of 0
	current_iq := 0

	for i := contests - 1; i >= 0; i-- {
		if contest_difficulty[i] > current_iq {
			if current_iq < start_iq {
				contest_tested[i] = 1
				current_iq++
			} else {
				contest_tested[i] = 0
			}
		} else {
			contest_tested[i] = 1
		}
	}

	for i := 0; i < contests; i++ {
		fmt.Printf("%d", contest_tested[i])
	}
	fmt.Printf("\n")
}

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

	for i := 0; i < number_of_cases; i++ {
		run_test_case(in)
	}

}

package main

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

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

	var count int
	fmt.Fscan(reader, &count)

	for i := 0; i < count; i++ {
		var n, q int
		fmt.Fscan(reader, &n, &q)
		bin := make([]string, n)
		a := make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(reader, &a[j])
		}

		ns := 0
		for j := n - 1; j >= 0; j-- {
			if a[j] <= ns {
				bin[j] = "1"
			} else if ns < q {
				ns++
				bin[j] = "1"
			} else {
				bin[j] = "0"
			}
		}
		for j := 0; j < n; j++ {
			fmt.Fprint(writer, bin[j])
		}

		fmt.Fprint(writer, "\n")
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)

func canSkip(k, q int, a []int) bool {
	skipLeft := k
	for _, ai := range a {
		if ai > q {
			if skipLeft > 0 {
				skipLeft--
			} else if q > 0 {
				q--
			} else {
				return false
			}
		}
	}
	return true
}

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

	a := make([]int, n)
	for i := range a {
		fmt.Fscan(in, &a[i])
	}

	result := -1
	left, right := 0, n
	for left <= right {
		mid := left + (right-left)/2
		if canSkip(mid, q, a) {
			result = mid
			right = mid - 1
		} else {
			left = mid + 1
		}
	}

	trials := make([]byte, n)
	skipLeft := result
	curQ := q
	for i, ai := range a {
		if ai > curQ && skipLeft > 0 {
			trials[i] = '0'
			skipLeft--
		} else {
			trials[i] = '1'
		}
	}
	fmt.Println(string(trials))
}

func main() {
	var t int
	fmt.Fscan(in, &t)

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

package main

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

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

func CF1708C(in io.Reader, out io.Writer) {
	_r := bufio.NewReader(in)
	_w := bufio.NewWriter(out)
	defer _w.Flush()

	var T int64
	fmt.Fscan(_r, &T)
	for ; T > 0; T-- {
		var n, q int64
		fmt.Fscan(_r, &n, &q)
		arr := make([]int64, n)
		for i := int64(0); i < n; i++ {
			fmt.Fscan(_r, &arr[i])
		}
		s,cq := make([]byte, n), int64(0)
		for i := n-1; i >= 0; i-- {
			if cq >= arr[i] {
				s[i] = '1'
			} else if cq < q {
				cq++
				s[i] = '1'
			} else {
				s[i] = '0'
			}
		}
		fmt.Fprintln(_w, string(s))
	}

}

package main

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

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

//1
//11
//110
//1110
//01111

func a1707(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T int
	var n int
	var q int
	var x int

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &q)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &x)
			a[i] = x
		}

		ans := make([]byte, n)
		t := 0 // 到i之前
		for i := n - 1; i >= 0; i-- {
			if a[i] > t {
				if t < q {
					t++
					ans[i] = '1'
				} else {
					ans[i] = '0'
				}
			} else {
				ans[i] = '1'
			}
		}
		Fprintln(out, string(ans))
	}
}

// 00
package main

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

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

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n, q int
		fmt.Fscan(reader, &n, &q)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		low := 0
		high := n
		for low < high {
			mid := (low + high) >> 1
			now := q
			ok := true
			for i := mid; i < n; i++ {
				if now == 0 {
					ok = false
					break
				}
				if a[i] > now {
					now--
				}
			}
			if ok {
				high = mid
			} else {
				low = mid + 1
			}
		}
		for i := 0; i < low; i++ {
			if a[i] <= q {
				fmt.Print(1)
			} else {
				fmt.Print(0)
			}
		}
		for i := low; i < n; i++ {
			fmt.Print(1)
		}
		fmt.Println()
	}
}

package main

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

const cf = true

func solve() {
	var n, q int
	fmt.Fscan(in, &n, &q)
	diff := make([]int, n)
	for i := range diff {
		fmt.Fscan(in, &diff[i])
	}
	curQ := 0
	ans := make([]int, n)
	for i := n - 1; i >= 0; i-- {
		if curQ < q {
			ans[i] = 1
			if diff[i] > curQ {
				curQ++
			}
		} else {
			if diff[i] <= curQ {
				ans[i] = 1
			}
		}
	}
	for i := range ans {
		fmt.Fprint(out, ans[i])
	}
	fmt.Fprintln(out)
}

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

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

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

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

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

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

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

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

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

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

var exists = struct{}{}

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

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

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

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

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

type Ordered interface {
	Integer | Float | ~string
}

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

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

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

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

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

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

package main

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

const cf = true

func solve() {
	var n, q int
	fmt.Fscan(in, &n, &q)
	diff := make([]int, n)
	for i := range diff {
		fmt.Fscan(in, &diff[i])
	}
	l, r := 0, n
	for l <= r {
		mid := (l + r) / 2
		curQ := q
		for i := range diff {
			if i >= mid {
				if diff[i] > curQ {
					curQ--
				}
			}
		}
		if curQ >= 0 {
			r = mid - 1
		} else {
			l = mid + 1
		}
	}
	r++
	ansArr := make([]int, n)
	for i := range diff {
		if i < r {
			if diff[i] <= q {
				ansArr[i] = 1
			}
		} else {
			if diff[i] <= q {
				ansArr[i] = 1
			} else if q > 0 {
				q--
				ansArr[i] = 1
			}
		}
	}
	for _, item := range ansArr {
		fmt.Fprint(out, item)
	}
	fmt.Fprintln(out)
}

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

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

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

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

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

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

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

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

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

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

var exists = struct{}{}

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

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

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

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

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

type Ordered interface {
	Integer | Float | ~string
}

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

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

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

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

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

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

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var loops int
	fmt.Fscan(reader, &loops)
	for lnum := 0; lnum < loops; lnum++ {
		var n, q int
		fmt.Fscan(reader, &n, &q)
		slc := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &slc[i])
		}
		var sb strings.Builder
		targetq := 0
	inner:
		for i := n - 1; i >= 0; i-- {
			if targetq > q {
				val := slc[i]
				if q >= val {
					sb.WriteString("1")
				} else {
					sb.WriteString("0")
				}
				continue inner
			}
			val := slc[i]
			if targetq >= val {
				//free ride
				sb.WriteString("1")
				continue inner
			} else {
				if targetq == q {
					targetq++
					sb.WriteString("0")
				} else {
					targetq++
					sb.WriteString("1")
				}
			}
		}
		resstr := sb.String()
		runes := []rune(resstr)
		for ir, jr := 0, len(runes)-1; ir < jr; ir, jr = ir+1, jr-1 {
			runes[ir], runes[jr] = runes[jr], runes[ir]
		}
		fmt.Println(string(runes))
	}
}

package main

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

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

func Print(a ...interface{})   { _, _ = fmt.Fprint(writer, a...) }
func Println(a ...interface{}) { _, _ = fmt.Fprintln(writer, a...) }

func main() {
	defer func() {
		_ = writer.Flush()
	}()

	T := ReadInt()
	for t := 0; t < T; t++ {
		Solve()
	}
}

func Solve() {
	n, q := ReadInt(), ReadInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = ReadInt()
	}
	max := 1
	first := true
	for i := n - 1; i >= 0; i-- {
		if a[i] > max {
			if first {
				a[i] = max
			} else {
				a[i] = max + 1
			}
			max += 1
		} else if a[i] == max {
			first = false
		}
	}
	for i := 0; i < n; i++ {
		if q >= a[i] {
			Print(1)
		} else {
			Print(0)
		}
	}
	Println()
}

func ReadInt() (value int) {
	_, _ = fmt.Fscan(reader, &value)
	return
}

package main

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

const mod = 998244353
const mx = int64(1e9 + 7)

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()
	var n, iq int
	Fscan(in, &n, &iq)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		Fscan(in, &arr[i])
	}
	ans := make([]byte, n)
	cq := 0
	for i := n - 1; i >= 0; i-- {
		if cq >= arr[i] {
			ans[i] = '1'
		} else if iq != 0 {
			ans[i] = '1'
			cq++
			iq--
		} else {
			ans[i] = '0'
		}
	}
	Fprintln(out, string(ans))
}

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

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
}
func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

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

package main

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

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n, q int
		fmt.Fscan(in, &n, &q)

		aa := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
		}

		bb := make([]rune, n)
		var g int
		for i := n - 1; i >= 0; i-- {
			if aa[i] <= g {
				bb[i] = '1'
			} else if g < q {
				bb[i] = '1'
				g++
			} else {
				bb[i] = '0'
			}
		}
		fmt.Fprintln(out, string(bb))
	}
}

package main

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

var rr = bufio.NewReader(os.Stdin)
var ww = bufio.NewWriter(os.Stdout)

func slove() {
	var n, q int
	fmt.Fscan(rr, &n, &q)
	nums := make([]int, n)
	for i:=0;i<len(nums);i++ {
		fmt.Fscan(rr, &nums[i])
	}
	i := sort.Search(n, func(i int) bool {
		cur := q
		j := i
		for ;j<n&&cur>0;j++ {
			if nums[j] > cur {
				cur--
			}
		}
		if j == n {
			return true
		} else {
			return false
		}
	})
	ans := make([]byte, n)
	for j:=0;j<i;j++ {
		if nums[j] <= q {
			ans[j] = '1'
		} else {
			ans[j] = '0'
		}
	}
	for j:=i;j<n;j++ {
		ans[j] = '1'
	}
	fmt.Fprintln(ww, string(ans))
}

func main() {
	defer ww.Flush()
	var n int
	fmt.Fscan(rr, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		t--
		var n, q int
		fmt.Fscan(in, &n, &q)
		a := make([]int, n+5)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
		}

		vis := make([]int, n+5)
		iq := 0
		for i := n; i >= 1; i-- {
			if a[i] <= iq {
				iq++
				vis[i] = 1
			} else if iq < q {
				vis[i] = 1
				iq++
			} else {
				vis[i] = 0
			}
		}
		ret := []byte{}
		for i := 1; i <= n; i++ {
			if vis[i] == 1 {
				ret = append(ret, '1')
			} else {
				ret = append(ret, '0')
			}
		}
		fmt.Fprintln(out, string(ret))
	}
}

package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		t--
		var n, q int
		fmt.Fscan(in, &n, &q)
		a := make([]int, n+5)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
		}

		vis := make([]int, n+5)
		iq := 0
		for i := n; i >= 1; i-- {
			if a[i] <= iq {
				iq++
				vis[i] = 1
			} else if iq < q {
				vis[i] = 1
				iq++
				continue
			}
		}
		ret := []byte{}
		for i := 1; i <= n; i++ {
			if vis[i] == 1 {
				ret = append(ret, '1')
			} else {
				ret = append(ret, '0')
			}
		}
		fmt.Fprintln(out, string(ret))
	}
}

package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		t--
		var n, q int
		fmt.Fscan(in, &n, &q)
		a := make([]int, n+5)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
		}

		vis := make([]int, n+5)
		iq := 0
		for i := n; i >= 1; i-- {
			if iq < q && a[i] > iq {
				vis[i] = 1
				iq++
				continue
			}
			if a[i] <= iq {
				iq++
				vis[i] = 1
			}
		}
		ret := []byte{}
		for i := 1; i <= n; i++ {
			if vis[i] == 1 {
				ret = append(ret, '1')
			} else {
				ret = append(ret, '0')
			}
		}
		fmt.Fprintln(out, string(ret))
	}
}

package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	x := 0
	for t > 0 {
		x++
		var n, q int
		fmt.Fscan(in, &n, &q)
		a := make([]int, n+5)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
		}
		if x == 5509 {
			fmt.Fprintln(out, q)
			break
		}
		//1 1 1 3 1 2
		mi := make([]int, n+5)
		ma := make([]int, n+5)
		for i := n; i >= 1; i-- {
			if i == n {
				mi[i] = a[i]
				ma[i] = a[i]
			} else {
				mi[i] = min(a[i], mi[i+1])
				ma[i] = max(a[i], ma[i+1])
			}
		}

		ans := 0
		vis := make([]int, n+5)
		for i := 1; i <= n; i++ {
			if q == 0 {
				break
			}
			if i == n-1 || i == n {
				if q < a[i] {
					q--
				}
				ans++
				vis[i] = 1
				continue
			}
			if a[i] <= q {
				vis[i] = 1
				ans++
				continue
			}
			if mi[i+1] > q || ma[i+1] < q || n-i+1 <= q {
				q--
				ans++
				vis[i] = 1
			}
		}
		t--
		ret := []byte{}
		for i := 1; i <= n; i++ {
			if vis[i] == 0 {
				ret = append(ret, '0')
			} else {
				ret = append(ret, '1')
			}
		}
		fmt.Fprintln(out, string(ret))
	}
}

package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	x := 0
	for t > 0 {
		x++
		var n, q int
		fmt.Fscan(in, &n, &q)
		a := make([]int, n+5)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
		}
		if x == 5509 {
			fmt.Fprintln(out, a[6])
			break
		}
		//1 1 1 3 1
		mi := make([]int, n+5)
		ma := make([]int, n+5)
		for i := n; i >= 1; i-- {
			if i == n {
				mi[i] = a[i]
				ma[i] = a[i]
			} else {
				mi[i] = min(a[i], mi[i+1])
				ma[i] = max(a[i], ma[i+1])
			}
		}

		ans := 0
		vis := make([]int, n+5)
		for i := 1; i <= n; i++ {
			if q == 0 {
				break
			}
			if i == n-1 || i == n {
				if q < a[i] {
					q--
				}
				ans++
				vis[i] = 1
				continue
			}
			if a[i] <= q {
				vis[i] = 1
				ans++
				continue
			}
			if mi[i+1] > q || ma[i+1] < q || n-i+1 <= q {
				q--
				ans++
				vis[i] = 1
			}
		}
		t--
		ret := []byte{}
		for i := 1; i <= n; i++ {
			if vis[i] == 0 {
				ret = append(ret, '0')
			} else {
				ret = append(ret, '1')
			}
		}
		fmt.Fprintln(out, string(ret))
	}
}

package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	x := 0
	for t > 0 {
		x++
		var n, q int
		fmt.Fscan(in, &n, &q)
		a := make([]int, n+5)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
		}
		if x == 5509 {
			fmt.Fprintln(out, a[5])
			break
		}
		//1 1 1 3
		mi := make([]int, n+5)
		ma := make([]int, n+5)
		for i := n; i >= 1; i-- {
			if i == n {
				mi[i] = a[i]
				ma[i] = a[i]
			} else {
				mi[i] = min(a[i], mi[i+1])
				ma[i] = max(a[i], ma[i+1])
			}
		}

		ans := 0
		vis := make([]int, n+5)
		for i := 1; i <= n; i++ {
			if q == 0 {
				break
			}
			if i == n-1 || i == n {
				if q < a[i] {
					q--
				}
				ans++
				vis[i] = 1
				continue
			}
			if a[i] <= q {
				vis[i] = 1
				ans++
				continue
			}
			if mi[i+1] > q || ma[i+1] < q || n-i+1 <= q {
				q--
				ans++
				vis[i] = 1
			}
		}
		t--
		ret := []byte{}
		for i := 1; i <= n; i++ {
			if vis[i] == 0 {
				ret = append(ret, '0')
			} else {
				ret = append(ret, '1')
			}
		}
		fmt.Fprintln(out, string(ret))
	}
}

package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	x := 0
	for t > 0 {
		x++
		var n, q int
		fmt.Fscan(in, &n, &q)
		a := make([]int, n+5)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
		}
		if x == 5509 {
			fmt.Fprintln(out, a[4])
			break
		}
		//1 1 1
		mi := make([]int, n+5)
		ma := make([]int, n+5)
		for i := n; i >= 1; i-- {
			if i == n {
				mi[i] = a[i]
				ma[i] = a[i]
			} else {
				mi[i] = min(a[i], mi[i+1])
				ma[i] = max(a[i], ma[i+1])
			}
		}

		ans := 0
		vis := make([]int, n+5)
		for i := 1; i <= n; i++ {
			if q == 0 {
				break
			}
			if i == n-1 || i == n {
				if q < a[i] {
					q--
				}
				ans++
				vis[i] = 1
				continue
			}
			if a[i] <= q {
				vis[i] = 1
				ans++
				continue
			}
			if mi[i+1] > q || ma[i+1] < q || n-i+1 <= q {
				q--
				ans++
				vis[i] = 1
			}
		}
		t--
		ret := []byte{}
		for i := 1; i <= n; i++ {
			if vis[i] == 0 {
				ret = append(ret, '0')
			} else {
				ret = append(ret, '1')
			}
		}
		fmt.Fprintln(out, string(ret))
	}
}

package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	x := 0
	for t > 0 {
		x++
		var n, q int
		fmt.Fscan(in, &n, &q)
		a := make([]int, n+5)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
		}
		if x == 5509 {
			fmt.Fprintln(out, a[3])
			break
		}
		//1 1
		mi := make([]int, n+5)
		ma := make([]int, n+5)
		for i := n; i >= 1; i-- {
			if i == n {
				mi[i] = a[i]
				ma[i] = a[i]
			} else {
				mi[i] = min(a[i], mi[i+1])
				ma[i] = max(a[i], ma[i+1])
			}
		}

		ans := 0
		vis := make([]int, n+5)
		for i := 1; i <= n; i++ {
			if q == 0 {
				break
			}
			if i == n-1 || i == n {
				if q < a[i] {
					q--
				}
				ans++
				vis[i] = 1
				continue
			}
			if a[i] <= q {
				vis[i] = 1
				ans++
				continue
			}
			if mi[i+1] > q || ma[i+1] < q || n-i+1 <= q {
				q--
				ans++
				vis[i] = 1
			}
		}
		t--
		ret := []byte{}
		for i := 1; i <= n; i++ {
			if vis[i] == 0 {
				ret = append(ret, '0')
			} else {
				ret = append(ret, '1')
			}
		}
		fmt.Fprintln(out, string(ret))
	}
}

package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	x := 0
	for t > 0 {
		x++
		var n, q int
		fmt.Fscan(in, &n, &q)
		a := make([]int, n+5)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
		}
		if x == 5509 {
			fmt.Fprintln(out, a[2])
			break
		}
		//1 1
		mi := make([]int, n+5)
		ma := make([]int, n+5)
		for i := n; i >= 1; i-- {
			if i == n {
				mi[i] = a[i]
				ma[i] = a[i]
			} else {
				mi[i] = min(a[i], mi[i+1])
				ma[i] = max(a[i], ma[i+1])
			}
		}

		ans := 0
		vis := make([]int, n+5)
		for i := 1; i <= n; i++ {
			if q == 0 {
				break
			}
			if i == n-1 || i == n {
				if q < a[i] {
					q--
				}
				ans++
				vis[i] = 1
				continue
			}
			if a[i] <= q {
				vis[i] = 1
				ans++
				continue
			}
			if mi[i+1] > q || ma[i+1] < q || n-i+1 <= q {
				q--
				ans++
				vis[i] = 1
			}
		}
		t--
		ret := []byte{}
		for i := 1; i <= n; i++ {
			if vis[i] == 0 {
				ret = append(ret, '0')
			} else {
				ret = append(ret, '1')
			}
		}
		fmt.Fprintln(out, string(ret))
	}
}

package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	x := 0
	for t > 0 {
		x++
		var n, q int
		fmt.Fscan(in, &n, &q)
		a := make([]int, n+5)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
		}
		if x == 5509 {
			fmt.Fprintln(out, a[2])
			break
		}
		//1
		mi := make([]int, n+5)
		ma := make([]int, n+5)
		for i := n; i >= 1; i-- {
			if i == n {
				mi[i] = a[i]
				ma[i] = a[i]
			} else {
				mi[i] = min(a[i], mi[i+1])
				ma[i] = max(a[i], ma[i+1])
			}
		}

		ans := 0
		vis := make([]int, n+5)
		for i := 1; i <= n; i++ {
			if q == 0 {
				break
			}
			if i == n-1 || i == n {
				if q < a[i] {
					q--
				}
				ans++
				vis[i] = 1
				continue
			}
			if a[i] <= q {
				vis[i] = 1
				ans++
				continue
			}
			if mi[i+1] > q || ma[i+1] < q || n-i+1 <= q {
				q--
				ans++
				vis[i] = 1
			}
		}
		t--
		ret := []byte{}
		for i := 1; i <= n; i++ {
			if vis[i] == 0 {
				ret = append(ret, '0')
			} else {
				ret = append(ret, '1')
			}
		}
		fmt.Fprintln(out, string(ret))
	}
}

package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	x := 0
	for t > 0 {
		x++
		var n, q int
		fmt.Fscan(in, &n, &q)
		a := make([]int, n+5)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
		}
		if x == 5509 {
			fmt.Fprintln(out, a[1])
			break
		}
		mi := make([]int, n+5)
		ma := make([]int, n+5)
		for i := n; i >= 1; i-- {
			if i == n {
				mi[i] = a[i]
				ma[i] = a[i]
			} else {
				mi[i] = min(a[i], mi[i+1])
				ma[i] = max(a[i], ma[i+1])
			}
		}

		ans := 0
		vis := make([]int, n+5)
		for i := 1; i <= n; i++ {
			if q == 0 {
				break
			}
			if i == n-1 || i == n {
				if q < a[i] {
					q--
				}
				ans++
				vis[i] = 1
				continue
			}
			if a[i] <= q {
				vis[i] = 1
				ans++
				continue
			}
			if mi[i+1] > q || ma[i+1] < q || n-i+1 <= q {
				q--
				ans++
				vis[i] = 1
			}
		}
		t--
		ret := []byte{}
		for i := 1; i <= n; i++ {
			if vis[i] == 0 {
				ret = append(ret, '0')
			} else {
				ret = append(ret, '1')
			}
		}
		fmt.Fprintln(out, string(ret))
	}
}

package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	x := 0
	for t > 0 {
		x++
		var n, q int
		fmt.Fscan(in, &n, &q)
		a := make([]int, n+5)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
		}
		if x == 5509 {
			fmt.Fprintln(out, a)
			break
		}
		mi := make([]int, n+5)
		ma := make([]int, n+5)
		for i := n; i >= 1; i-- {
			if i == n {
				mi[i] = a[i]
				ma[i] = a[i]
			} else {
				mi[i] = min(a[i], mi[i+1])
				ma[i] = max(a[i], ma[i+1])
			}
		}

		ans := 0
		vis := make([]int, n+5)
		for i := 1; i <= n; i++ {
			if q == 0 {
				break
			}
			if i == n-1 || i == n {
				if q < a[i] {
					q--
				}
				ans++
				vis[i] = 1
				continue
			}
			if a[i] <= q {
				vis[i] = 1
				ans++
				continue
			}
			if mi[i+1] > q || ma[i+1] < q || n-i+1 <= q {
				q--
				ans++
				vis[i] = 1
			}
		}
		t--
		ret := []byte{}
		for i := 1; i <= n; i++ {
			if vis[i] == 0 {
				ret = append(ret, '0')
			} else {
				ret = append(ret, '1')
			}
		}
		fmt.Fprintln(out, string(ret))
	}
}

package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		var n, q int
		fmt.Fscan(in, &n, &q)
		a := make([]int, n+5)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
		}
		mi := make([]int, n+5)
		ma := make([]int, n+5)
		for i := n; i >= 1; i-- {
			if i == n {
				mi[i] = a[i]
				ma[i] = a[i]
			} else {
				mi[i] = min(a[i], mi[i+1])
				ma[i] = max(a[i], ma[i+1])
			}
		}

		ans := 0
		vis := make([]int, n+5)
		for i := 1; i <= n; i++ {
			if q == 0 {
				break
			}
			if i == n-1 || i == n {
				if q < a[i] {
					q--
				}
				ans++
				vis[i] = 1
				continue
			}
			if a[i] <= q {
				vis[i] = 1
				ans++
				continue
			}
			if mi[i+1] > q || ma[i+1] < q || n-i+1 <= q {
				q--
				ans++
				vis[i] = 1
			}
		}
		t--
		ret := []byte{}
		for i := 1; i <= n; i++ {
			if vis[i] == 0 {
				ret = append(ret, '0')
			} else {
				ret = append(ret, '1')
			}
		}
		fmt.Fprintln(out, string(ret))
	}
}

package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		var n, q int
		fmt.Fscan(in, &n, &q)
		a := make([]int, n+5)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
		}
		mi := make([]int, n+5)
		ma := make([]int, n+5)
		for i := n; i >= 1; i-- {
			if i == n {
				mi[i] = a[i]
				ma[i] = a[i]
			} else {
				mi[i] = min(a[i], mi[i+1])
				ma[i] = max(a[i], ma[i+1])
			}
		}

		ans := 0
		vis := make([]int, n+5)
		for i := 1; i <= n; i++ {
			if q == 0 {
				break
			}
			if i == n-1 || i == n {
				if q < a[i] {
					q--
				}
				ans++
				vis[i] = 1
				continue
			}
			if a[i] <= q {
				vis[i] = 1
				ans++
				continue
			}
			if mi[i+1] > q || ma[i+1] < q {
				q--
				ans++
				vis[i] = 1
			}
		}
		t--
		ret := []byte{}
		for i := 1; i <= n; i++ {
			if vis[i] == 0 {
				ret = append(ret, '0')
			} else {
				ret = append(ret, '1')
			}
		}
		fmt.Fprintln(out, string(ret))
	}
}

package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		var n, q int
		fmt.Fscan(in, &n, &q)
		a := make([]int, n+5)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
		}
		mi := make([]int, n+5)
		for i := n; i >= 1; i-- {
			if i == n {
				mi[i] = a[i]
			} else {
				mi[i] = min(a[i], mi[i+1])
			}
		}
		ans := 0
		vis := make([]int, n+5)
		for i := 1; i <= n; i++ {
			if q > n-i+1 {
				q--
				vis[i] = 1
				continue
			}
			if q == 0 {
				break
			}
			if i == n-1 || i == n {
				if q < a[i] {
					q--
				}
				ans++
				vis[i] = 1
				continue
			}
			if a[i] <= q {
				vis[i] = 1
				ans++
				continue
			}
			if mi[i+1] > q {
				q--
				ans++
				vis[i] = 1
			}
		}
		t--
		ret := []byte{}
		for i := 1; i <= n; i++ {
			if vis[i] == 0 {
				ret = append(ret, '0')
			} else {
				ret = append(ret, '1')
			}
		}
		fmt.Fprintln(out, string(ret))
	}
}

package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		var n, q int
		fmt.Fscan(in, &n, &q)
		a := make([]int, n+5)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
		}
		mi := make([]int, n+5)
		for i := n; i >= 1; i-- {
			if i == n {
				mi[i] = a[i]
			} else {
				mi[i] = min(a[i], mi[i+1])
			}
		}
		ans := 0
		vis := make([]int, n+5)
		for i := 1; i <= n; i++ {
			if q > n-i+1 {
				q--
				vis[i] = 1
			}
			if q == 0 {
				break
			}
			if i == n-1 || i == n {
				if q < a[i] {
					q--
				}
				ans++
				vis[i] = 1
				continue
			}
			if a[i] <= q {
				vis[i] = 1
				ans++
				continue
			}
			if mi[i+1] > q {
				q--
				ans++
				vis[i] = 1
			}
		}
		t--
		ret := []byte{}
		for i := 1; i <= n; i++ {
			if vis[i] == 0 {
				ret = append(ret, '0')
			} else {
				ret = append(ret, '1')
			}
		}
		fmt.Fprintln(out, string(ret))
	}
}

package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		var n, q int
		fmt.Fscan(in, &n, &q)
		a := make([]int, n+5)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
		}
		mi := make([]int, n+5)
		for i := n; i >= 1; i-- {
			if i == n {
				mi[i] = a[i]
			} else {
				mi[i] = min(a[i], mi[i+1])
			}
		}
		ans := 0
		vis := make([]int, n+5)
		for i := 1; i <= n; i++ {
			if q == 0 {
				break
			}
			if i == n-1 || i == n {
				if q < a[i] {
					q--
				}
				ans++
				vis[i] = 1
				continue
			}
			if a[i] <= q {
				vis[i] = 1
				ans++
				continue
			}
			if mi[i+1] > q {
				q--
				ans++
				vis[i] = 1
			}
		}
		t--
		ret := []byte{}
		for i := 1; i <= n; i++ {
			if vis[i] == 0 {
				ret = append(ret, '0')
			} else {
				ret = append(ret, '1')
			}
		}
		fmt.Fprintln(out, string(ret))
	}
}

package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		var n, q int
		fmt.Fscan(in, &n, &q)
		a := make([]int, n+5)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &a[i])
		}
		mi := make([]int, n+5)
		for i := n; i >= 1; i-- {
			if i == n {
				mi[i] = a[i]
			} else {
				mi[i] = min(a[i], mi[i+1])
			}
		}
		ans := 0
		vis := make([]int, n+5)
		for i := 1; i <= n; i++ {

			fmt.Println(i, q)
			if q == 0 {
				break
			}
			if i == n-1 || i == n {
				if q < a[i] {
					q--
				}
				ans++
				vis[i] = 1
				continue
			}
			if a[i] <= q {
				vis[i] = 1
				ans++
				continue
			}
			if mi[i+1] > q {
				q--
				ans++
				vis[i] = 1
			}
		}
		t--
		ret := []byte{}
		for i := 1; i <= n; i++ {
			if vis[i] == 0 {
				ret = append(ret, '0')
			} else {
				ret = append(ret, '1')
			}
		}
		fmt.Fprintln(out, string(ret))
	}
}

package main

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

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

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n, k := readTwoNums(reader)
		A := readNNums(reader, n)
		res := solve(A, k)
		buf.WriteString(fmt.Sprintf("%s\n", res))
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

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

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

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

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

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

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

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

	return i
}

func solve(A []int, iq int) string {
	// when iq > A[i], always to test
	// when iq <= A[i], may test, but iq--, else not stay no change
	// only when iq > 0, can test
	n := len(A)

	cnt := make(map[int]int)

	for i := 0; i < n; i++ {
		cnt[A[i]]++
	}
	res := make([]byte, n)
	for i := 0; i < n; i++ {
		res[i] = '0'
	}
	var delete []int
	for i := 0; i < n && iq > 0; i++ {
		cnt[A[i]]--
		if iq >= A[i] {
			res[i] = '1'
			continue
		}
		// iq <=  A[i]
		if cnt[iq] == 0 {
			// use it no problem
			res[i] = '1'
			iq--
			delete = append(delete, i)
		}
		// else no change
	}

	for _, i := range delete {
		if iq == 0 {
			break
		}
		res[i] = '1'
		iq--
	}

	return string(res)
}

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

package main

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

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

	var count int
	fmt.Fscan(reader, &count)

	for i := 0; i < count; i++ {
		var n, q int
		fmt.Fscan(reader, &n, &q)
		for j := 0; j < n; j++ {
			var u int
			fmt.Fscan(reader, &u)
			if q == 0 {
				fmt.Fprint(writer, "0")
			} else if u > q {
				fmt.Fprint(writer, "1")
				q--
			} else {
				fmt.Fprint(writer, "1")
			}
		}
		fmt.Fprint(writer, "\n")
	}
}

package main

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

const cf = true

func solve() {
	var n, q int
	fmt.Fscan(in, &n, &q)
	diff := make([]int, n)
	for i := range diff {
		fmt.Fscan(in, &diff[i])
	}
	l, r := -1, n+1
	ans := 0
	for i := range diff {
		if diff[i] <= q {
			ans++
		}
	}
	for l < r-1 {
		mid := (l + r) / 2
		curQ := q
		curAns := 0
		for i := range diff {
			if i < mid {
				if diff[i] <= q {
					curAns++
				}
			} else {
				if diff[i] <= curQ {
					curAns++
				} else if curQ > 0 {
					curQ--
					curAns++
				}
			}
		}
		if curAns > ans {
			ans = curAns
			r = mid
		} else {
			l = mid
		}
	}
	ansArr := make([]int, n)
	for i := range diff {
		if i < r {
			if diff[i] <= q {
				ansArr[i] = 1
			}
		} else {
			if diff[i] <= q {
				ansArr[i] = 1
			} else if q > 0 {
				q--
				ansArr[i] = 1
			}
		}
	}
	for _, item := range ansArr {
		fmt.Fprint(out, item)
	}
	fmt.Fprintln(out)
}

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

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

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

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

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

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

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

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

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

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

var exists = struct{}{}

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

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

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

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

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

type Ordered interface {
	Integer | Float | ~string
}

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

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

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

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

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

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

package main

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

const cf = true

func solve() {
	var n, q int
	fmt.Fscan(in, &n, &q)
	diff := make([]int, n)
	for i := range diff {
		fmt.Fscan(in, &diff[i])
	}
	l, r := 0, n
	ans := 0
	for i := range diff {
		if diff[i] <= q {
			ans++
		}
	}
	for l < r-1 {
		mid := (l + r) / 2
		curQ := q
		curAns := 0
		for i := range diff {
			if i < mid {
				if diff[i] <= q {
					curAns++
				}
			} else {
				if diff[i] <= curQ {
					curAns++
				} else if curQ > 0 {
					curQ--
					curAns++
				}
			}
		}
		if curAns > ans {
			ans = curAns
			r = mid
		} else {
			l = mid
		}
	}
	ansArr := make([]int, n)
	for i := range diff {
		if i < r {
			if diff[i] <= q {
				ansArr[i] = 1
			}
		} else {
			if diff[i] <= q {
				ansArr[i] = 1
			} else if q > 0 {
				q--
				ansArr[i] = 1
			}
		}
	}
	for _, item := range ansArr {
		fmt.Fprint(out, item)
	}
	fmt.Fprintln(out)
}

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

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

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

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

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

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

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

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

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

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

var exists = struct{}{}

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

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

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

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

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

type Ordered interface {
	Integer | Float | ~string
}

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

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

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

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

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

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

package main

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

const cf = true

func solve() {
	var n, q int
	fmt.Fscan(in, &n, &q)
	diff := make([]int, n)
	for i := range diff {
		fmt.Fscan(in, &diff[i])
	}
	l, r := 0, n
	ans := 0
	for i := range diff {
		if diff[i] <= q {
			ans++
		}
	}
	for l < r-1 {
		mid := (l + r) / 2
		curQ := q
		curAns := 0
		for i := range diff {
			if i < mid {
				if diff[i] <= q {
					curAns++
				}
			} else {
				if diff[i] <= curQ {
					curAns++
				} else if curQ > 0 {
					curQ--
					curAns++
				}
			}
		}
		if curAns >= ans {
			ans = curAns
			r = mid
		} else {
			l = mid
		}
	}
	ansArr := make([]int, n)
	for i := range diff {
		if i < r {
			if diff[i] <= q {
				ansArr[i] = 1
			}
		} else {
			if diff[i] <= q {
				ansArr[i] = 1
			} else if q > 0 {
				q--
				ansArr[i] = 1
			}
		}
	}
	for _, item := range ansArr {
		fmt.Fprint(out, item)
	}
	fmt.Fprintln(out)
}

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

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

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

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

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

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

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

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

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

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

var exists = struct{}{}

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

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

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

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

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

type Ordered interface {
	Integer | Float | ~string
}

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

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

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

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

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

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

// 00
package main

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

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

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n, q int
		fmt.Fscan(reader, &n, &q)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		mx := make([]int, n)
		b := make([]byte, n)
		if a[n-1] <= q {
			mx[n-1] = a[n-1]
		}
		for i := n - 2; i >= 0; i-- {
			if a[i] <= q {
				mx[i] = max(a[i], mx[i+1])
			} else {
				mx[i] = mx[i+1]
			}
		}
		//fmt.Println(mx)
		for i := 0; i < n; i++ {
			if q >= a[i] {
				b[i] = '1'
			} else {
				if q > mx[i] {
					b[i] = '1'
					q--
				} else {
					b[i] = '0'
				}
			}
		}
		for i := 0; i < n; i++ {
			if q > 0 && b[i] == '0' {
				b[i] = '1'
				q--
			}
		}
		fmt.Println(string(b))
	}
}

// 00
package main

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

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

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n, q int
		fmt.Fscan(reader, &n, &q)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		mx := make([]int, n)
		b := make([]byte, n)
		if a[n-1] <= q {
			mx[n-1] = a[n-1]
		}
		for i := n - 2; i >= 0; i-- {
			if a[i] <= q {
				mx[i] = max(a[i], mx[i+1])
			} else {
				mx[i] = mx[i+1]
			}
		}
		//fmt.Println(mx)
		for i := 0; i < n; i++ {
			if q >= a[i] {
				b[i] = '1'
			} else {
				if q > mx[i] {
					b[i] = '1'
					q--
				} else {
					b[i] = '0'
				}
			}
		}
		fmt.Println(string(b))
	}
}


Mr. Chanek has a new game called Dropping Balls. Initially, Mr. Chanek has a grid $$$a$$$ of size $$$n \times m$$$Each cell $$$(x,y)$$$ contains an integer $$$a_{x,y}$$$ denoting the direction of how the ball will move.  $$$a_{x,y}=1$$$ — the ball will move to the right (the next cell is $$$(x, y + 1)$$$);  $$$a_{x,y}=2$$$ — the ball will move to the bottom (the next cell is $$$(x + 1, y)$$$);  $$$a_{x,y}=3$$$ — the ball will move to the left (the next cell is $$$(x, y - 1)$$$). Every time a ball leaves a cell $$$(x,y)$$$, the integer $$$a_{x,y}$$$ will change to $$$2$$$. Mr. Chanek will drop $$$k$$$ balls sequentially, each starting from the first row, and on the $$$c_1, c_2, \dots, c_k$$$-th ($$$1 \leq c_i \leq m$$$) columns.Determine in which column each ball will end up in (position of the ball after leaving the grid).

The first line contains three integers $$$n$$$, $$$m$$$, and $$$k$$$ ($$$1 \leq n, m \leq 1000$$$, $$$1 \leq k \leq 10^5$$$) — the size of the grid and the number of balls dropped by Mr. Chanek. The $$$i$$$-th of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i,1},a_{i,2},\ldots,a_{i,m}$$$ ($$$1 \leq a_{i,j} \leq 3$$$). It will satisfy $$$a_{i, 1} \ne 3$$$ and $$$a_{i, m} \ne 1$$$. The next line contains $$$k$$$ integers $$$c_1, c_2, \ldots, c_k$$$ ($$$1 \leq c_i \leq m$$$) — the balls' column positions dropped by Mr. Chanek sequentially.

Output $$$k$$$ integers — the $$$i$$$-th integer denoting the column where the $$$i$$$-th ball will end.

NoteIn the first example, the first ball will drop as follows. Note that the cell $$$(1, 1)$$$ will change direction to the bottom direction.  The second and third balls will drop as follows.   All balls will be dropped from the first row and on the $$$c_1, c_2, \dots, c_k$$$-th columns respectively. A ball will stop dropping once it leaves the grid.

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n, m, k int
	fmt.Fscan(in, &n, &m, &k)

	grid := make([][]int, n)
	for i := range grid {
		grid[i] = make([]int, m)
		for j := range grid[i] {
			fmt.Fscan(in, &grid[i][j])
		}
	}

	for i := 0; i < k; i++ {
		var x, y int
		fmt.Fscan(in, &x)
		x--

		for y != n {
			cmd := grid[y][x]
			grid[y][x] = 2
			if cmd == 1 {
				x++
			} else if cmd == 2 {
				y++
			} else {
				x--
			}
		}

		if i != 0 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, x+1)
	}
	fmt.Fprintln(out)
}