While Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab challenged Mahmoud with another problem.Given two strings a and b, find the length of their longest uncommon subsequence, which is the longest string that is a subsequence of one of them and not a subsequence of the other.A subsequence of some string is a sequence of characters that appears in the same order in the string, The appearances don't have to be consecutive, for example, strings "ac", "bc", "abc" and "a" are subsequences of string "abc" while strings "abbc" and "acb" are not. The empty string is a subsequence of any string. Any string is a subsequence of itself.

The first line contains string a, and the second line — string b. Both of these strings are non-empty and consist of lowercase letters of English alphabet. The length of each string is not bigger than 105 characters.

If there's no uncommon subsequence, print "-1". Otherwise print the length of the longest uncommon subsequence of a and b.

NoteIn the first example: you can choose "defgh" from string b as it is the longest subsequence of string b that doesn't appear as a subsequence of string a.

package main

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

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

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

func init() {
	if f, err := os.Open("in.goC"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var a, b string
	for I(&a, &b) == nil {
		solve(a, b)
	}
}

func solve(a, b string) {
	if a == b {
		O("-1\n")
	} else {
		O(max(len(a), len(b)), "\n")
	}
}

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

package main

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

func main() {
	ab := [2]string{}

	reader := bufio.NewReader(os.Stdin)
	re := regexp.MustCompile(`\r?\n`)
	for i := 0; i < 2; i++ {
		if s, err := reader.ReadString('\n'); err != nil {
			if err == io.EOF {
				break
			} else {
				return
			}
		} else {
			ab[i] = re.ReplaceAllString(s, "")
		}
	}

	if len(ab[0]) > len(ab[1]) {
		fmt.Println(len(ab[0]))
	} else if len(ab[0]) < len(ab[1]) {
		fmt.Println(len(ab[1]))
	} else {
		if ab[0] == ab[1] {
			fmt.Println(-1)
		} else {
			fmt.Println(len(ab[0]))
		}
	}
}

package main

import (
	"fmt"
	"math"
)

func main() {

	var a, b string
	fmt.Scanf("%s\n%s", &a, &b)

	if a == b {
		fmt.Println(-1)
	} else {
		fmt.Printf("%d\n", int(math.Max(float64(len(a)), float64(len(b)))))
	}
}

package main

import "fmt"

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

func main() {
	var a, b string
	fmt.Scan(&a)
	fmt.Scan(&b)
	if a == b {
		fmt.Println(-1)
		return
	}
	fmt.Println(max(len(a), len(b)))
}

/*
few testcases

	abcd
	defgh

*/

package main
import (
	"fmt"
)

func max(x, y int) int {
    if x > y {
        return x
    }
    return y
}
func main()  {
	var x, y string
	fmt.Scan(&x)
	fmt.Scan(&y)

	if x == y {
		fmt.Println("-1")
	}else{
		fmt.Println(max(len(x), len(y)))
	}
}

package main

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

func solve() {
	a := readString()
	b := readString()
	if len(a) > len(b) {
		a, b = b, a
	}
	if len(a) != len(b) {
		fmt.Println(len(b))
		return
	}
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			fmt.Println(len(b))
			return
		}
	}
	fmt.Println(-1)
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF766A(in io.Reader, out io.Writer) {
	var s, t string
	if Fscan(bufio.NewReader(in), &s, &t); s == t {
		Fprint(out, -1)
	} else if len(s) > len(t) {
		Fprint(out, len(s))
	} else {
		Fprint(out, len(t))
	}
}

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

package main

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

func readString(reader *bufio.Reader) string {
	var buf []byte
	for {
		str, prefix, err := reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, str...)
		if !prefix {
			return string(buf)
		}
	}
}

func main() {
	input := bufio.NewReader(os.Stdin)
	a, b := readString(input), readString(input)
	if a == b {
		fmt.Println("-1")
	} else {
		ans := len(a)
		if len(b) > ans {
			ans = len(b)
		}
		fmt.Println(ans)
	}
}

package main

import "fmt"

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

func main() {
    var s1, s2 string
    fmt.Scan(&s1)
    fmt.Scan(&s2)
    if s1 == s2 {
        fmt.Print(-1)
    } else {
        fmt.Print(max(len(s1), len(s2)))
    }
}

package main

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

func main() {
	var firstString, secondString string
	var firstLen, secondLen int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &firstString)
	fmt.Fscan(reader, &secondString)
	firstLen = len(firstString)
	secondLen = len(secondString)
	if firstLen > secondLen {
		fmt.Println(firstLen)
	} else if firstLen < secondLen {
		fmt.Println(secondLen)
	} else {
		for index := 0; index < firstLen; index++ {
			if firstString[index] != secondString[index] {
				fmt.Println(firstLen)
				return
			}
		}
		fmt.Println(-1)
	}

}

package main

import (
    "fmt"
)

func main() {
    var a, b string
    fmt.Scanf("%s\n%s", &a, &b)
    if len(a) == len(b) && a == b {
        fmt.Println(-1)
    } else {
        longer := len(a)
        if len(b) > longer {
            longer = len(b)
        }
        fmt.Println(longer)
    }
}

package main

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

func Solve(io *FastIO) {
	A := io.NextLine()
	B := io.NextLine()

	if A == B {
		io.Println(-1)
	} else {
		io.Println(Max(len(A), len(B)))
	}
}

func Max(args ...int) int {
	max := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] > max {
			max = args[i]
		}
	}
	return max
}

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

func IsLineBreakChar(c byte) bool {
	switch c {
		case 0, '\n', '\r':
			return true
		default:
			return false
	}
}

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Solve(&io)
	io.FlushOutput()
}

package main

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

func main() {
	sc := NewScanner()

	A := sc.NextLine()
	B := sc.NextLine()

	if A == B {
		fmt.Println(-1)
	} else {
		fmt.Println(max(len(A),len(B)))
	}

}

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) 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 (
	"bufio"
	"fmt"
	"os"
)

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

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

func init() {
	if f, err := os.Open("in.goC"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var a, b string
	for I(&a, &b) == nil {
		solve(a, b)
	}
}

func solve(a, b string) {
	h := make(map[uint64]int)
	for i := 0; i < len(a); i++ {
		for j := i; j < len(a); j++ {
			h[hash(a[i:j])] = j - i + 1
		}
	}
	ans := 0
	for i := 0; i < len(b); i++ {
		for j := i; j < len(b); j++ {
			if _, exists := h[hash(b[i:j])]; !exists {
				ans = max(ans, j-i+1)
			}
		}
	}
	if ans == 0 {
		ans--
	}
	O(ans, "\n")
}

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

func hash(s string) uint64 {
	h := A
	for i := 0; i < len(s); i++ {
		h ^= pow(i+5) * uint64(s[i]+113)
	}
	return h
}

var A uint64 = 11111111111111111011
var pp [2000020]uint64

func pow(a int) uint64 {
	if a == 1 {
		return uint64(1117)
	} else if a == 0 {
		return 1
	} else if pp[a] == 0 {
		pp[a] = (uint64(1117) * pow(a-1)) % A
	}
	return pp[a]
}

package main

import (
	"fmt"
	"strings"
)

func main() {

	var a, b string
	fmt.Scanf("%s\n%s", &a, &b)

	if strings.Contains(a, b) {
		fmt.Println(-1)
	} else {
		fmt.Println(len(b))
	}
}

package main

import (
	"fmt"
	"math"
	"strings"
)

func main() {

	var a, b string
	fmt.Scanf("%s\n%s", &a, &b)

	if strings.Contains(a, b) {
		fmt.Println(-1)
	} else {
		fmt.Printf("%d\n", int(math.Max(float64(len(a)), float64(len(b)))))
	}
}

package main

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

func solve() {
	a := readString()
	b := readString()
	if len(a) > len(b) {
		a, b = b, a
	}
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			fmt.Println(len(b))
			return
		}
	}
	fmt.Println(-1)
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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

package main

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

func solve() {
	a := readString()
	b := readString()
	if len(a) > len(b) {
		a, b = b, a
	}
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			fmt.Println(b)
			return
		}
	}
	fmt.Println(-1)
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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

package main

import "fmt"

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

func main() {
    var s1, s2 string
    fmt.Scan(&s1)
    fmt.Scan(&s2)
    if s1 == s2 {
        fmt.Print(-1)
    } else {
        fmt.Print(min(len(s1), len(s2)))
    }
}

package main

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

func main() {
	var firstString, secondString string
	var prevChar, firstSubSeq, secondSubSeq int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &firstString)
	fmt.Fscan(reader, &secondString)
	prevChar = int(firstString[0])
	firstSubSeq = 1
	for index := 1; index < len(firstString); index++ {
		if prevChar < int(firstString[index]) {
			firstSubSeq++
		} else {
			firstSubSeq = 0
		}
	}
	secondSubSeq = 1
	for index := 1; index < len(secondString); index++ {
		if prevChar < int(secondString[index]) {
			secondSubSeq++
		} else {
			secondSubSeq = 0
		}
	}
	if firstSubSeq > secondSubSeq {
		fmt.Println(firstSubSeq)
	} else if firstSubSeq < secondSubSeq {
		fmt.Println(secondSubSeq)
	} else {
		fmt.Println(-1)
	}
}

package main

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

func main() {
	sc := NewScanner()

	A := sc.NextLine()
	B := sc.NextLine()
	mpA := map[byte]bool{}
	mpB := map[byte]bool{}

	commonCount := 0
	for _, v := range A {
		mpA[byte(v)] = true
	}
	for _, v := range B {
		mpB[byte(v)] = true
	}

	for k, _ := range mpA {
		if _, ok := mpB[byte(k)]; ok {
			commonCount++
		}
	}

	v := max(len(mpA), len(mpB)) - commonCount
	if v > 0 {
		fmt.Println(v)
	} else {
		fmt.Println(-1)
	}

}
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) 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 (
	"strconv"
	"bufio"
	"os"
	"fmt"
)

func main() {
	sc := NewScanner()

	A := sc.NextLine()
	B := sc.NextLine()
	mpA := map[byte]bool{}
	mpB := map[byte]bool{}

	for _, v := range A {
		mpA[byte(v)] = true
	}
	for _, v := range B {
		mpB[byte(v)] = true
	}

	if len(mpA) == 1 && len(mpB) == 1 {
		v := min(len(A), len(B))
		if v == 1 {
			fmt.Println(-1)
			return
		}
		fmt.Println(v - 1)
		return
	}
	C := A
	D := B
	if len(A) < len(B) {
		C = B
		D = A
	}
	j := 0

	for i := 0; i < len(C); i++ {
		if C[i] == D[j] {
			j++
		}
	}
	if j == len(D) {
		fmt.Println(len(C) - 1)
	} else {
		fmt.Println(len(C))
	}

}
func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}
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) 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
		}
	}
}


Each month Blake gets the report containing main economic indicators of the company "Blake Technologies". There are n commodities produced by the company. For each of them there is exactly one integer in the final report, that denotes corresponding revenue. Before the report gets to Blake, it passes through the hands of m managers. Each of them may reorder the elements in some order. Namely, the i-th manager either sorts first ri numbers in non-descending or non-ascending order and then passes the report to the manager i + 1, or directly to Blake (if this manager has number i = m).Employees of the "Blake Technologies" are preparing the report right now. You know the initial sequence ai of length n and the description of each manager, that is value ri and his favourite order. You are asked to speed up the process and determine how the final report will look like.

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of commodities in the report and the number of managers, respectively. The second line contains n integers ai (|ai| ≤ 109) — the initial report before it gets to the first manager. Then follow m lines with the descriptions of the operations managers are going to perform. The i-th of these lines contains two integers ti and ri (, 1 ≤ ri ≤ n), meaning that the i-th manager sorts the first ri numbers either in the non-descending (if ti = 1) or non-ascending (if ti = 2) order.

Print n integers — the final report, which will be passed to Blake by manager number m.

NoteIn the first sample, the initial report looked like: 1 2 3. After the first manager the first two numbers were transposed: 2 1 3. The report got to Blake in this form.In the second sample the original report was like this: 1 2 4 3. After the first manager the report changed to: 4 2 1 3. After the second manager the report changed to: 2 4 1 3. This report was handed over to Blake.

package main

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

var MAX_NM int = 200100

func main() {
	scanner.Split(bufio.ScanWords)
	var N, M int
	N = NextInt()
	M = NextInt()

	var A []int = make([]int, MAX_NM)
	var B []int = make([]int, MAX_NM)

	T := make([]int, MAX_NM)
	R := make([]int, MAX_NM)
	for i := 0; i < N; i++ {
		A[i] = NextInt()
		B[i] = A[i]
	}
	var ma int

	ma = 0
	for i := 0; i < M; i++ {
		var t, r int
		t = NextInt()
		r = NextInt()
		if r > ma {
			ma = r
		}
		T[r] = i + 1
		R[r] = t
	}
	C := A[:ma]
	sort.Ints(C)
	for i := 0; i < ma; i++ {
		A[i] = C[i]
	}
	var head, tail int
	head = 0
	tail = ma - 1
	var t int = 0
	var j int = 0
	for i := N - 1; i >= 0; i-- {
		if T[i+1] > t {
			j = R[i+1]
			t = T[i+1]
		}
		if t > 0 {
			if j == 2 {
				B[i] = A[head]
				head++
			} else {
				B[i] = A[tail]
				tail--
			}
		}
	}
	for i := 0; i < N; i++ {
		fmt.Print(B[i], " ")
	}

}

//---------------------------------template--------------------------------

var scanner = bufio.NewScanner(os.Stdin)

var writer = bufio.NewWriter(os.Stdout)

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

func NextInt() int {
	val, err := strconv.Atoi(NextToken())
	if err != nil {
		panic(err.Error())
	}
	return val
}


In the pet store on sale there are:  $$$a$$$ packs of dog food;  $$$b$$$ packs of cat food;  $$$c$$$ packs of universal food (such food is suitable for both dogs and cats). Polycarp has $$$x$$$ dogs and $$$y$$$ cats. Is it possible that he will be able to buy food for all his animals in the store? Each of his dogs and each of his cats should receive one pack of suitable food for it.

The first line of input contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ lines are given, each containing a description of one test case. Each description consists of five integers $$$a, b, c, x$$$ and $$$y$$$ ($$$0 \le a,b,c,x,y \le 10^8$$$).

For each test case in a separate line, output:   YES, if suitable food can be bought for each of $$$x$$$ dogs and for each of $$$y$$$ cats;  NO else.  You can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as a positive response).

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a, b, c, x, y int
		fmt.Scan(&a)
		fmt.Scan(&b)
		fmt.Scan(&c)
		fmt.Scan(&x)
		fmt.Scan(&y)

		if x >= a {
			x -= a
			if c < x {
				fmt.Println("NO")
				continue
			} else {
				c -= x
			}
		}

		if y >= b {
			y -= b
			if c < y {
				fmt.Println("NO")
			} else {
				fmt.Println("YES")
			}
		} else {
			fmt.Println("YES")
		}
	}
}

package main

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

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

func (in *CF1675A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1675A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1675A
Date: 9/05/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1675/A
Problem: CF1675A
**/
func (in *CF1675A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		a, b, c, x, y := in.NextInt(), in.NextInt(), in.NextInt(), in.NextInt(), in.NextInt()

		if a >= x {
			a -= x
			a = 0
			x = 0
		} else {
			x-= a
			a = 0
			if x <= c {
				c -= x
				x = 0
			}
		}

		if b >= y {
			a -= y
			b = 0
			y = 0
		} else {
			y-= b
			b = 0
			if y <= c {
				c -= y
				y = 0
			}

		}

		if x == 0 && y == 0{
			fmt.Println("YES")
		}else {
			fmt.Println("NO")
		}

	}

}

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

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

package main

import (
	"fmt"
)

func main() {
	var ts int
	fmt.Scanln(&ts)

	for i := 0; i < ts; i++ {
		var a, b, c, x, y int
		fmt.Scanf("%d %d %d %d %d\n", &a, &b, &c, &x, &y)

		ma := x - a
		if ma < 0 {
			ma = 0
		}
		mb := y - b
		if mb < 0 {
			mb = 0
		}

		if c >= ma+mb {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
}

package main

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

//goland:noinspection GoUnusedFunction
func min(a int, nums ...int) int {
	min := a

	for _, num := range nums {
		if num < min {
			min = num
		}
	}
	return min
}

//goland:noinspection GoUnusedFunction
func max(a int, nums ...int) int {
	max := a

	for _, num := range nums {
		if num > max {
			max = num
		}
	}
	return max
}

//goland:noinspection GoUnusedFunction
func FprintlnArr(w io.Writer, arr []int) {
	for _, val := range arr {
		fmt.Fprint(w, val, " ")
	}
	fmt.Fprintln(w)
}

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

	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		var a, b, c, x, y int
		fmt.Fscan(in, &a, &b, &c, &x, &y)

		if max(x-a, 0)+max(y-b, 0) <= c {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		scanner.Scan()
		sl := strings.Split(scanner.Text(), " ")
		a, _ := strconv.Atoi(sl[0])
		b, _ := strconv.Atoi(sl[1])
		c, _ := strconv.Atoi(sl[2])
		x, _ := strconv.Atoi(sl[3])
		y, _ := strconv.Atoi(sl[4])
		xa := 0
		if x > a {
			xa = x - a
		}
		yb := 0
		if y > b {
			yb = y - b
		}
		if a >= x && b >= y {
			fmt.Println("YES")
		} else if xa+yb <= c {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)

	for i:=0;i<t;i++{ // take inputs
		list:= make([]int,5)
		for j:=0;j<5;j++{
			fmt.Fscan(in,&list[j])
		}
		if list[3] <= list[0] && list[4] <= list[1] { // check if already surplus
			fmt.Fprintln(out,"YES")
		} else {
			if (list[3]-list[0]) < 0 { // check if deficit
				list[2]-= 0
			} else {
				list[2]-= (list[3]-list[0]) // deduct from universal
			}
			if list[2] >= 0 { // check if deficit
				if list[4]-list[1] > list[2] { // if cat food exceeds reserve
					fmt.Fprintln(out,"NO")
				} else {
					fmt.Fprintln(out,"YES")
				}
			} else {
				fmt.Fprintln(out,"NO")
			}
		}
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)
var tc = 1
var DEBUG = os.Getenv("DEBUG") != ""

func solve() {
	var a, b, c, x, y int
	scan(&a, &b, &c, &x, &y)
	x -= a
	y -= b
	x = max(x, 0)
	y = max(y, 0)
	if x == 0 && y == 0 {
		printf("YES\n")
		return
	}
	printf("%s\n", ys(x+y <= c))
}

func main() {
	var T int
	scan(&T)
	for ; T > 0; T-- {
		solve()
		tc++
	}
}

func ys(b bool) string      { return map[bool]string{true: "YES", false: "NO"}[b] }
func scan(a ...interface{}) { fmt.Fscan(in, a...) }
func printf(format string, a ...interface{}) {
	if DEBUG {
		format = fmt.Sprintf("Test #%d: %s", tc, format)
	}
	fmt.Printf(format, a...)
}

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

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

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

package main

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

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

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

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		var a, b, c, x, y int
		fmt.Fscan(in, &a, &b, &c, &x, &y)
		x -= min(x, a)
		y -= min(y, b)
		if c >= x+y {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}
func solve() {
	var a, b, c, x, y int
	scan(&a, &b, &c, &x, &y)
	if a+b+c >= x+y && a+c >= x && b+c >= y {
		printf("YES\n")
	} else {
		printf("NO\n")
	}
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int     { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }
func min(a,b int) int { if a > b { return b }; return a }
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	T := gi()
	for tt:=1;tt<=T;tt++ {
		a,b,c,x,y := gi(),gi(),gi(),gi(),gi()
		a = min(a,x); b = min(b,y)
		ans := "NO"; if a+b+c >= x+y { ans = "YES" }
		fmt.Fprintln(wrtr,ans)
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for n > 0 {
		n--
		arr := make([]int, 5)
		for i := 0; i < 5; i++ {
			fmt.Scan(&arr[i])
		}
		if arr[0]+arr[1]+arr[2] < arr[3]+arr[4] {
			fmt.Println("NO")
		} else if arr[0]+arr[2] < arr[3] || arr[1]+arr[2] < arr[4] {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}
}

package main

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

var wr = bufio.NewWriter(os.Stdout)
var rd = bufio.NewScanner(os.Stdin)

func nextInt() int {
	rd.Scan()
	if n, err := strconv.Atoi(rd.Text()); err == nil {
		return n
	}
	return 0
}
func Max(a,b int)int{
	if a>b {
		return a
	}else{
		return b
	}
}
func main() {
	defer wr.Flush()
	rd.Buffer(make([]byte, 0), 1000000009)
	rd.Split(bufio.ScanWords)
	T := nextInt()
	for Case := 0; Case < T; Case++ {
		solve()
	}
}
func solve() {
	a, b, c, x, y := nextInt(), nextInt(), nextInt(), nextInt(), nextInt()
	if Max(x-a,0)+Max(y-b,0) <= c {
		fmt.Fprint(wr, "YES\n")
	} else {
		fmt.Fprint(wr, "NO\n")
	}
}

package main

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

const (
	MOD2 = 998244353
	MOD1 = 1000000007
)

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	defer wr.Flush()
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	t := nextInt()
	for t > 0 {
		solve()
		t--
	}
}

func solve() {
	a := nextInt()
	b := nextInt()
	c := nextInt()
	x := nextInt()
	y := nextInt()

	x -= a
	y -= b
	if x > 0 {
		c -= x
	}
	if c < 0 {
		println("NO")
		return
	}

	if y > 0 {
		c -= y
	}

	if c < 0 {
		println("NO")
	} else {
		println("YES")
	}
}

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

func print(a ...interface{}) {
	fmt.Fprint(wr, a...)
}

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

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

func nextFloat() float64 {
	i, e := strconv.ParseFloat(next(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

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

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

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

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

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 a, b, c, x, y int
		fmt.Fscan(in, &a, &b, &c, &x, &y)

		x = max(0, x-a)
		y = max(0, y-b)

		if x+y <= c {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

func main() {
	var (
		t int
	)

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

	for t > 0 {
		t--

		text, _ := reader.ReadString('\n')
		ninps := strings.Fields(text)
		a, _ := strconv.Atoi(ninps[0])
		b, _ := strconv.Atoi(ninps[1])
		c, _ := strconv.Atoi(ninps[2])
                x, _ := strconv.Atoi(ninps[3])
		y, _ := strconv.Atoi(ninps[4])

		if a+c >= x {
		        if a < x && (x-a) <= c {
		        	c -= (x - a)
			}
			if b + c >= y {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	r, w := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var n int
	Fscan(r, &n)
	t := 0
	var a, b, c, x, y int
	for t < n{
		t++
		Fscan(r, &a, &b, &c, &x, &y)
		a -= x
		b -= y
		if a < 0{
			c += a
		}
		if b < 0{
			c += b
		}
		if c >= 0{
			Fprintln(w, "YES")
		}else{
			Fprintln(w, "NO")
		}
	}

}

package main

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

func main_div3_787_A() {
	_in, _out := os.Stdin, os.Stdout
	in, out := bufio.NewReader(_in), bufio.NewWriter(_out)
	defer out.Flush()
	var cas int = 1
	Fscan(in, &cas)
	var sol func()
	// Coding...
	sol = func() {
		var a, b, c, x, y int
		Fscan(in, &a, &b, &c, &x, &y)
		if a > x {
			a = x

		}
		if b > y {
			b = y
		}
		if a+b+c >= x+y {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
	for i := 0; i < cas; i++ {
		sol()
	}
}

func main() {
	main_div3_787_A()
}

package main

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

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

func slove() {
	defer w.Flush()
	var a, b, c, x, y int
	fmt.Fscan(r, &a, &b, &c)
	fmt.Fscan(r, &x, &y)
	x -= a
	y -= b
	if max(x, 0) + max(y, 0) > c {
		fmt.Fprintln(w, "No")
	} else {
		fmt.Fprintln(w, "Yes")
	}
}

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

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

package main

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

type Int int64

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

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

	var t int
	Fscan(in, &t)

	for tt := 0; tt < t; tt++ {
		var a, b, c, x, y Int
		Fscan(in, &a, &b, &c, &x, &y)

		x = Max(0, x-a)
		y = Max(0, y-b)

		if x+y <= c {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}

}

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

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

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

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

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

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

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

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

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

func doNothing(m Int) Int {
	return m
}

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

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

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

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

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

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

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

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

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

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

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

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

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

package main

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

/*

 */

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var a, b, c, x, y int
	scanf("%d %d %d %d %d\n", &a, &b, &c, &x, &y)

	reqDog := x - a
	if reqDog < 0 {
		reqDog = 0
	}

	reqCat := y - b
	if reqCat < 0 {
		reqCat = 0
	}

	if c >= reqDog+reqCat {
		fmt.Fprintln(writer, "YES")
	} else {
		fmt.Fprintln(writer, "NO")
	}
}

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

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

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

const maxUint = ^uint(0)

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

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

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

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

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

//goland:noinspection GoUnusedFunction
func divCeil(num, div int64) int64 {
	quot := num / div
	if num%div > 0 {
		quot++
	} else if num%div < 0 {
		quot--
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	return nums[minIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func minIdx(nums ...int) int {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return minNumIdx
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	return nums[maxIdx(nums...)]
}

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

	return maxNumIdx
}

//goland:noinspection GoUnusedFunction
func sum(nums ...int) (sum int) {
	for _, num := range nums {
		sum += num
	}
	return
}

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

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

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

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

	return true
}

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

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

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

	num = abs(num)

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

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

//goland:noinspection GoUnusedFunction
func factorize(num int64) []int64 {
	factors := make([]int64, 0)

	for ftr := int64(2); ftr*ftr <= num; ftr++ {
		for num%ftr == 0 {
			num /= ftr
			factors = append(factors, ftr)
		}
	}

	if num > 1 {
		factors = append(factors, num)
	}

	return factors
}

package main

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

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

	for ii := 0; ii < t; ii++ {
		var a, b, c, x, y int
		fmt.Fscan(in, &a, &b, &c, &x, &y)
		if a+c < x {
			fmt.Fprintln(out, "NO")
			continue
		}
		if a < x {
			c -= x - a
		}
		if b+c < y {
			fmt.Fprintln(out, "NO")
		} else {
			fmt.Fprintln(out, "YES")
		}
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a, b, c, x, y int
		fmt.Scan(&a)
		fmt.Scan(&b)
		fmt.Scan(&c)
		fmt.Scan(&x)
		fmt.Scan(&y)

		if x >= a {
			x -= a
			if c < x {
				fmt.Println("NO")
				continue
			} else {
				c -= x
			}
		}

		if y >= b {
			y -= b
			if c < y {
				fmt.Println("NO")
			} else {
				fmt.Println("YES")
			}
		}
		fmt.Println("YES")
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a, b, c, x, y int
		fmt.Scan(&a)
		fmt.Scan(&b)
		fmt.Scan(&c)
		fmt.Scan(&x)
		fmt.Scan(&y)

		if x >= a {
			x -= a
			if c < x {
				fmt.Println("NO")
				continue
			} else {
				c -= x
			}
		}

		if y >= b {
			y -= b
			if c < y {
				fmt.Println("NO")
			} else {
				fmt.Println("YES")
			}
		}
	}
}

package main

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

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

func (in *CF1675A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1675A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1675A
Date: 9/05/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1675/A
Problem: CF1675A
**/
func (in *CF1675A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		a, b, c, x, y := in.NextInt(), in.NextInt(), in.NextInt(), in.NextInt(), in.NextInt()

		if a >= x {
			a -= x
			a = 0
		} else {
			x-= a
			a = 0
			if x <= c {
				c -= x
				x = 0
			}
		}

		if b >= y {
			a -= y
			b = 0
		} else {
			y-= b
			b = 0
			if y <= c {
				c -= y
				y = 0
			}

		}

		if x == 0 && y == 0{
			fmt.Println("YES")
		}else {
			fmt.Println("NO")
		}

	}

}

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

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

package main

import (
	"fmt"
)

func main() {
	var ts int
	fmt.Scan(&ts)

	for i := 0; i < ts; i++ {
		var a, b, c, x, y int
		fmt.Scanf("%d %d %d %d %d\n", &a, &b, &c, &x, &y)

		ma := x - a
		if ma < 0 {
			ma = 0
		}
		mb := y - b
		if mb < 0 {
			mb = 0
		}

		if c >= ma+mb {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
}

package main

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

//goland:noinspection GoUnusedFunction
func min(a int, nums ...int) int {
	min := a

	for _, num := range nums {
		if num < min {
			min = num
		}
	}
	return min
}

//goland:noinspection GoUnusedFunction
func max(a int, nums ...int) int {
	max := a

	for _, num := range nums {
		if num > max {
			max = num
		}
	}
	return max
}

//goland:noinspection GoUnusedFunction
func FprintlnArr(w io.Writer, arr []int) {
	for _, val := range arr {
		fmt.Fprint(w, val, " ")
	}
	fmt.Fprintln(w)
}

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

	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		var a, b, c, x, y int
		fmt.Fscan(in, &a, &b, &c, &x, &y)

		if int(math.Abs(float64(x-a)))+int(math.Abs(float64(y-b))) <= c {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}


Ashish has a binary string $$$s$$$ of length $$$n$$$ that he wants to sort in non-decreasing order.He can perform the following operation:   Choose a subsequence of any length such that its elements are in non-increasing order. Formally, choose any $$$k$$$ such that $$$1 \leq k \leq n$$$ and any sequence of $$$k$$$ indices $$$1 \le i_1 \lt i_2 \lt \ldots \lt i_k \le n$$$ such that $$$s_{i_1} \ge s_{i_2} \ge \ldots \ge s_{i_k}$$$.  Reverse this subsequence in-place. Formally, swap $$$s_{i_1}$$$ with $$$s_{i_k}$$$, swap $$$s_{i_2}$$$ with $$$s_{i_{k-1}}$$$, $$$\ldots$$$ and swap $$$s_{i_{\lfloor k/2 \rfloor}}$$$ with $$$s_{i_{\lceil k/2 \rceil + 1}}$$$ (Here $$$\lfloor x \rfloor$$$ denotes the largest integer not exceeding $$$x$$$, and $$$\lceil x \rceil$$$ denotes the smallest integer not less than $$$x$$$) Find the minimum number of operations required to sort the string in non-decreasing order. It can be proven that it is always possible to sort the given binary string in at most $$$n$$$ operations.

The first line contains a single integer $$$t$$$ $$$(1 \le t \le 1000)$$$  — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ $$$(1 \le n \le 1000)$$$  — the length of the binary string $$$s$$$. The second line of each test case contains a binary string $$$s$$$ of length $$$n$$$ containing only $$$0$$$s and $$$1$$$s. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$1000$$$.

For each test case output the following:   The minimum number of operations $$$m$$$ in the first line ($$$0 \le m \le n$$$).  Each of the following $$$m$$$ lines should be of the form: $$$k$$$ $$$i_1$$$ $$$i_2$$$ ... $$$i_{k}$$$, where $$$k$$$ is the length and $$$i_1 \lt i_2 \lt ... \lt i_{k}$$$ are the indices of the chosen subsequence. For them the conditions from the statement must hold.

NoteIn the first test case, the binary string is already sorted in non-decreasing order.In the second test case, we can perform the following operation:   $$$k = 4:$$$ choose the indices $$$\{1, 3, 4, 5\}$$$$$$\underline{1}$$$ $$$0$$$ $$$\underline{1}$$$ $$$\underline{0}$$$ $$$\underline{0}$$$ $$$\rightarrow $$$ $$$\underline{0}$$$ $$$0$$$ $$$\underline{0}$$$ $$$\underline{1}$$$ $$$\underline{1}$$$ In the third test case, we can perform the following operation:  $$$k = 3:$$$ choose the indices $$$\{3, 5, 6\}$$$$$$0$$$ $$$0$$$ $$$\underline{1}$$$ $$$0$$$ $$$\underline{0}$$$ $$$\underline{0}$$$ $$$\rightarrow $$$ $$$0$$$ $$$0$$$ $$$\underline{0}$$$ $$$0$$$ $$$\underline{0}$$$ $$$\underline{1}$$$

// 00
package main

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

func write(f *bufio.Writer, a ...interface{}) {
	f.Write([]byte(fmt.Sprint(a...)))
}

type Number interface {
	int64 | float64 | int
}

func min[K Number](a K, b K) K {
	if a < b {
		return a
	}
	return b
}
func max[K Number](a K, b K) K {
	if a > b {
		return a
	}
	return b
}
func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n int
		var s string
		fmt.Fscan(reader, &n, &s)
		b := []byte(s)
		zeros := 0
		ones := 0
		for i := 0; i < n; i++ {
			if b[i] == '0' {
				zeros++
			} else {
				ones++
			}
		}
		bs := []byte(s)
		for i := 0; i < n; i++ {
			if zeros > 0 {
				bs[i] = '0'
				zeros--
			} else {
				bs[i] = '1'
			}
		}

		k := make([]int, 0)
		for i := 0; i < n; i++ {
			if b[i] != bs[i] {
				k = append(k, i+1)
			}
		}
		if len(k) > 0 {
			write(f, 1, "\n")
			write(f, len(k))
			for i := 0; i < len(k); i++ {
				write(f, " ", k[i])
			}
			write(f, "\n")
		} else {
			write(f, 0, "\n")
		}

	}
}

package main

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

func main() {
	var t int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in,&t)
	out := os.Stdout
	for u:=1;u<=t;u++{
		var n int
		fmt.Fscan(in,&n)
		var s []byte
		fmt.Fscan(in,&s)
		check := false
		r1 := false
		for i:=0;i<len(s);i++{
			if r1&&s[i]=='0'{
				check = true
				break
			}
			if s[i]=='1'{
				r1 =true
			}
		}
		ans := 0
		ops := [][]int{}
		for check {
			ans ++
			vis := [1005]int{}
			sub := []int{}
			for i:=0;i<len(s);i++{
				if s[i]=='1'{
					for j:=len(s)-1;j>=i+1;j--{
						if s[j]=='0'&&vis[j]==0{
							vis[j]=1
							sub = append(sub,i,j)
							break
						}
					}
				}
			}
			sort.Ints(sub)
			for i:=0;i<len(sub)/2;i++{
				s[sub[i]],s[sub[len(sub)-i-1]] = s[sub[len(sub)-i-1]],s[sub[i]]
			}
			ops = append(ops,sub)
			r1 = false
			check = false
			for i:=0;i<len(s);i++{
				if r1&&s[i]=='0'{
					check = true
					break
				}
				if s[i]=='1'{
					r1 =true
				}
			}
		}
		fmt.Fprintln(out,ans)
		for i:=0;i<len(ops);i++{
			fmt.Fprintf(out,"%d ", len(ops[i]))
			for j:=0;j<len(ops[i]);j++{
				fmt.Fprintf(out,"%d ", ops[i][j]+1)
			}
			fmt.Fprintln(out)
		}
	}
}

package main

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

func solve(n int, s string) {
	ans := ([]int)(nil)
	i, j := 0, n-1
	for i < j {
		for i < j && s[i] == '0' {
			i++
		}
		for i < j && s[j] == '1' {
			j--
		}
		if i < j {
			ans = append(ans, i+1, j+1)
			i++
			j--
		}
	}
	sort.Slice(ans, func(i, j int) bool { return ans[i] < ans[j] })

	if len(ans) == 0 {
		printf("0\n")
		return
	}
	printf("1\n%v ", len(ans))
	for _, i := range ans {
		printf("%v ", i)
	}
	printf("\n")
}

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		var (
			n int
			s string
		)
		scan(&n, &s)
		solve(n, s)
	}
}

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

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

package main

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

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

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

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

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

		var c0 int
		for _, ch := range s {
			if ch == '0' {
				c0++
			}
		}

		arr := []int{}

		for i := 0; i < n; i++ {
			if c0 > 0 {
				if s[i] != '0' {
					arr = append(arr, i+1)
				}
				c0--
			} else {
				if s[i] != '1' {
					arr = append(arr, i+1)
				}
			}
		}

		if len(arr) == 0 {
			fmt.Fprintln(out, 0)
		} else {
			fmt.Fprintln(out, 1)
			fmt.Fprintf(out, "%d ", len(arr))
			for _, v := range arr {
				fmt.Fprintf(out, "%d ", v)
			}
			fmt.Fprintln(out)
		}
	}
}

package main

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

/*
4
1
0
1
1
2
10
2
01
---
0
0
2 1 2
0
======
1
2
10
---
2 1 2
*/

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

	bld := strings.Builder{}

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

	for ; t > 0; t-- {
		var n int
		var s string
		scanf("%d\n%s\n", &n, &s)

		zeroCnt := 0
		for _, r := range s {
			if r == '0' {
				zeroCnt++
			}
		}

		oneIdxs := make([]int, 0)
		zeroIdxs := make([]int, 0)

		for i, j := 0, zeroCnt; i < zeroCnt && j < len(s); {
			if s[i] == '0' {
				i++
				continue
			}
			if s[j] == '1' {
				j++
				continue
			}

			oneIdxs = append(oneIdxs, i)
			zeroIdxs = append(zeroIdxs, j)

			i++
			j++
		}

		if len(oneIdxs) != 0 {
			fmt.Fprintln(&bld, 1)
			fmt.Fprintf(&bld, "%d ", 2*len(oneIdxs))

			for _, idx := range oneIdxs {
				fmt.Fprintf(&bld, "%d ", idx+1)
			}
			for _, idx := range zeroIdxs {
				fmt.Fprintf(&bld, "%d ", idx+1)
			}
			fmt.Fprintln(&bld)
		} else {
			fmt.Fprintln(&bld, 0)
		}
	}

	printf("%s", bld.String())
}

const maxUint = ^uint(0)

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

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

//goland:noinspection GoUnusedType
type pair struct {
	x int64
	y int64
}

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

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

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

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

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

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

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

	return true
}

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

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

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

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

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

package main

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

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

	var tc int
	fmt.Fscan(in, &tc)
	for ; tc > 0; tc-- {
		var n int
		var s string
		fmt.Fscan(in, &n, &s)
		zeros := 0
		for _, ch := range s {
			if ch == '0' {
				zeros++
			}
		}
		r := []int{}
		for i, ch := range s {
			expected := '0'
			if i >= zeros {
				expected = '1'
			}
			if expected != ch {
				r = append(r, i+1)
			}
		}
		if len(r) == 0 {
			out.WriteString("0\n")
			continue
		}
		out.WriteString("1\n")
		fmt.Fprintf(out, "%d", len(r))
		for _, i := range r {
			fmt.Fprintf(out, " %d", i)
		}
		out.WriteByte('\n')
	}
}

// 00
package main

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

func write(f *bufio.Writer, a ...interface{}) {
	f.Write([]byte(fmt.Sprint(a...)))
}

type Number interface {
	int64 | float64 | int
}

func min[K Number](a K, b K) K {
	if a < b {
		return a
	}
	return b
}
func max[K Number](a K, b K) K {
	if a > b {
		return a
	}
	return b
}
func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n int
		var s string
		fmt.Fscan(reader, &n, &s)
		if t == 42 {
			fmt.Println(n, s)
		}
		b := []byte(s)
		zeros := 0
		ones := 0
		for i := 0; i < n; i++ {
			if b[i] == '0' {
				zeros++
			} else {
				ones++
			}
		}
		bs := []byte(s)
		for i := 0; i < n; i++ {
			if zeros > 0 {
				bs[i] = '0'
				zeros--
			} else {
				bs[i] = '1'
			}
		}

		k := make([]int, 0)
		for i := 0; i < n; i++ {
			if b[i] != bs[i] {
				k = append(k, i+1)
			}
		}
		if len(k) > 0 {
			write(f, 1, "\n")
			write(f, len(k))
			for i := 0; i < len(k); i++ {
				write(f, " ", k[i])
			}
			write(f, "\n")
		} else {
			write(f, 0, "\n")
		}

	}
}

// 00
package main

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

func write(f *bufio.Writer, a ...interface{}) {
	f.Write([]byte(fmt.Sprint(a...)))
}

type Number interface {
	int64 | float64 | int
}

func min[K Number](a K, b K) K {
	if a < b {
		return a
	}
	return b
}
func max[K Number](a K, b K) K {
	if a > b {
		return a
	}
	return b
}
func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n int
		var s string
		fmt.Fscan(reader, &n, &s)
		if t == 42 {
			fmt.Println(n, s)
		}
		b := []byte(s)
		kks := make([][]int, 0)
		for true {
			found_one := false
			found_zero := false
			kk := make([]int, 0)
			start := n - 1
			for start >= 0 {
				if found_zero && b[start] == '1' {
					kk = append(kk, start)
					found_one = true
				} else if !found_one && b[start] == '0' {
					kk = append(kk, start)
					found_zero = true
				}
				start--
			}
			if found_one {
				kks = append(kks, kk)
				k := len(kk)
				for i := 0; i < k/2; i++ {
					b[kk[i]], b[kk[k-1-i]] = b[kk[k-1-i]], b[kk[i]]
				}
			} else {
				break
			}
		}
		write(f, len(kks), "\n")
		for i := 0; i < len(kks); i++ {
			write(f, len(kks[i]))
			for j := len(kks[i]) - 1; j >= 0; j-- {
				write(f, " ", kks[i][j]+1)
			}
			write(f, "\n")
		}

	}
}

// 00
package main

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

func write(f *bufio.Writer, a ...interface{}) {
	f.Write([]byte(fmt.Sprint(a...)))
}

type Number interface {
	int64 | float64 | int
}

func min[K Number](a K, b K) K {
	if a < b {
		return a
	}
	return b
}
func max[K Number](a K, b K) K {
	if a > b {
		return a
	}
	return b
}
func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n int
		var s string
		fmt.Fscan(reader, &n, &s)
		b := []byte(s)
		kks := make([][]int, 0)
		for true {
			found_one := false
			found_zero := false
			kk := make([]int, 0)
			start := n - 1
			for start >= 0 {
				if found_zero && b[start] == '1' {
					kk = append(kk, start)
					found_one = true
				} else if !found_one && b[start] == '0' {
					kk = append(kk, start)
					found_zero = true
				}
				start--
			}
			if found_one {
				kks = append(kks, kk)
				k := len(kk)
				for i := 0; i < k/2; i++ {
					b[kk[i]], b[kk[k-1-i]] = b[kk[k-1-i]], b[kk[i]]
				}
			} else {
				break
			}
		}
		write(f, len(kks), "\n")
		for i := 0; i < len(kks); i++ {
			write(f, len(kks[i]))
			for j := len(kks[i]) - 1; j >= 0; j-- {
				write(f, " ", kks[i][j]+1)
			}
			write(f, "\n")
		}

	}
}

package main

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

func main() {
	var t int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in,&t)
	out := os.Stdout
	for u:=1;u<=t;u++{
		var n int
		fmt.Fscan(in,&n)
		var s []byte
		fmt.Fscan(in,&s)
		check := false
		r1 := false
		for i:=0;i<len(s);i++{
			if r1&&s[i]=='0'{
				check = true
				break
			}
			if s[i]=='1'{
				r1 =true
			}
		}
		ans := 0
		ops := [][]int{}
		for check {
			ans++
			b0 := -1
			for i:=len(s)-1;i>=0;i--{
				if s[i]!='1'{
					b0 = i
					break
				}
			}
			subs := []int{}
			b1 := -1
			for i:=b0;i>=0;i--{
				if s[i]=='1'{
					b1 = i
					break
				}
				subs = append([]int{i},subs...)
			}
			cnt :=  len(subs)
			temp := []int{}
			for i:=0;i<=b1;i++{
				if s[i]=='1'{
					cnt--
					temp = append(temp,i)
					if cnt==0{
						break
					}
				}
			}
			subs = append(temp,subs...)
			for i:=0;i<len(subs)/2;i++{
				s[subs[i]],s[subs[len(subs)-i-1]] = s[subs[len(subs)-i-1]],s[subs[i]]
			}
			ops = append(ops,subs)
			check = false
			r1 = false
			for i:=0;i<len(s);i++{
				if r1&&s[i]=='0'{
					check = true
					break
				}
				if s[i]=='1'{
					r1 =true
				}
			}
		}
		fmt.Fprintln(out,ans)
		for i:=0;i<len(ops);i++{
			fmt.Fprintf(out,"%d ", len(ops[i]))
			for j:=0;j<len(ops[i]);j++{
				fmt.Fprintf(out,"%d ", ops[i][j]+1)
			}
			fmt.Fprintln(out)
		}
	}
}

package main

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

func main() {
	var t int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in,&t)
	out := os.Stdout
	for u:=1;u<=t;u++{
		var n int
		fmt.Fscan(in,&n)
		var s []byte
		fmt.Fscan(in,&s)
		check := false
		r1 := false
		for i:=0;i<len(s);i++{
			if r1&&s[i]=='0'{
				check = true
				break
			}
			if s[i]=='1'{
				r1 =true
			}
		}
		ans := 0
		ops := [][]int{}
		for check {
			ans++
			b0 := -1
			for i:=len(s)-1;i>=0;i--{
				if s[i]!='1'{
					b0 = i
					break
				}
			}
			subs := []int{}
			b1 := -1
			for i:=b0;i>=0;i--{
				if s[i]=='1'{
					b1 = i
					break
				}
				subs = append([]int{i},subs...)
			}
			cnt :=  len(subs)
			for i:=b1;i>=0;i--{
				if s[i]=='1'{
					cnt--
					subs = append([]int{i},subs...)
					if cnt==0{
						break
					}
				}
			}
			for i:=0;i<len(subs)/2;i++{
				s[subs[i]],s[subs[len(subs)-i-1]] = s[subs[len(subs)-i-1]],s[subs[i]]
			}
			ops = append(ops,subs)
			check = false
			r1 = false
			for i:=0;i<len(s);i++{
				if r1&&s[i]=='0'{
					check = true
					break
				}
				if s[i]=='1'{
					r1 =true
				}
			}
		}
		fmt.Fprintln(out,ans)
		for i:=0;i<len(ops);i++{
			fmt.Fprintf(out,"%d ", len(ops[i]))
			for j:=0;j<len(ops[i]);j++{
				fmt.Fprintf(out,"%d ", ops[i][j]+1)
			}
			fmt.Fprintln(out)
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

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

func solve(n int, s string) {
	ans := ([]int)(nil)
	i, j := 0, n-1
	for i < j {
		for i < j && s[i] == '0' {
			i++
		}
		for i < j && s[j] == '1' {
			j--
		}
		if i < j {
			ans = append(ans, i+1, j+1)
			i++
			j--
		}
	}
	sort.Slice(ans, func(i, j int) bool { return ans[i] < ans[j] })

	if len(ans) == 0 {
		fmt.Println(0)
		return
	}
	fmt.Printf("1\n%d ", len(ans))
	for _, i := range ans {
		fmt.Printf("%d ", i)
	}
	fmt.Printf("\n")
}


A string $$$s$$$ of length $$$n$$$, consisting of lowercase letters of the English alphabet, is given.You must choose some number $$$k$$$ between $$$0$$$ and $$$n$$$. Then, you select $$$k$$$ characters of $$$s$$$ and permute them however you want. In this process, the positions of the other $$$n-k$$$ characters remain unchanged. You have to perform this operation exactly once.For example, if $$$s=\texttt{"andrea"}$$$, you can choose the $$$k=4$$$ characters $$$\texttt{"a_d_ea"}$$$ and permute them into $$$\texttt{"d_e_aa"}$$$ so that after the operation the string becomes $$$\texttt{"dneraa"}$$$.Determine the minimum $$$k$$$ so that it is possible to sort $$$s$$$ alphabetically (that is, after the operation its characters appear in alphabetical order).

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 40$$$) — the length of the string. The second line of each test case contains the string $$$s$$$. It is guaranteed that $$$s$$$ contains only lowercase letters of the English alphabet.

For each test case, output the minimum $$$k$$$ that allows you to obtain a string sorted alphabetically, through the operation described above.

NoteIn the first test case, we can choose the $$$k=2$$$ characters $$$\texttt{"_ol"}$$$ and rearrange them as $$$\texttt{"_lo"}$$$ (so the resulting string is $$$\texttt{"llo"}$$$). It is not possible to sort the string choosing strictly less than $$$2$$$ characters.In the second test case, one possible way to sort $$$s$$$ is to consider the $$$k=6$$$ characters $$$\texttt{"_o__force_"}$$$ and rearrange them as $$$\texttt{"_c__efoor_"}$$$ (so the resulting string is $$$\texttt{"ccdeefoors"}$$$). One can show that it is not possible to sort the string choosing strictly less than $$$6$$$ characters.In the third test case, string $$$s$$$ is already sorted (so we can choose $$$k=0$$$ characters).In the fourth test case, we can choose all $$$k=4$$$ characters $$$\texttt{"dcba"}$$$ and reverse the whole string (so the resulting string is $$$\texttt{"abcd"}$$$).

package main

import (
    "fmt"
    "sort"
)

func main() {
    var t int
    //fmt.Scanf("%d", &t)
    fmt.Scan(&t)
    for i:=0 ; i<t; i+=1{
        var n int
        //fmt.Scanf("%d", &n)
        fmt.Scan(&n)
        var s string
        //fmt.Scanf("%s", &s)
        fmt.Scan(&s)
        //slce := []string{}
        var slce []string
        for j:=0; j<len(s); j+=1{
            slce = append(slce, string(s[j]) )
        }
        sort.Strings(slce)
        ans := 0
        for j:=0; j<len(s); j+=1{
            if string(s[j]) != slce[j]{
                ans += 1
            }
        }
        fmt.Println(ans)
    }
}

package main
import(
    "fmt"
    "bufio"
    "os"
    "strings"
    "sort"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		var word string
		fmt.Fscan(in,&word)
		list:= strings.Split(word,"")
		sort.Strings(list)
		counter:=0
		for j:=0;j<n;j++{
			if list[j] != string(word[j]) {
				counter++
			}
		}
		fmt.Fprintln(out,counter)
	}
}

package main

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

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

func (in *CF1552A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1552A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1552A
Date: 25/11/21
User: epradere
URL: https://codeforces.com/problemset/problem/1552/A
Problem: CF1552A
**/
func (in *CF1552A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		arr := make([]int, n)
		ord := make([]int, n)
		str := in.NextString()
		for i := 0; i < n; i++ {
			arr[i] = int(str[i])
			ord[i] = int(str[i])
		}

		sort.Ints(ord)

		ans := 0
		for i := 0; i < n; i++ {
			if arr[i] != ord[i] {
				ans++
			}
		}

		fmt.Println(ans)
	}
}

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

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

package main

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

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

func stringToRuneSlice(s string) []rune {
	var x []rune
	for _, c := range s {
		x = append(x, rune(c))
	}
	return x
}

func solve(n int, s string) int {
	p := stringToRuneSlice(s)
	q := stringToRuneSlice(s)
	sort.Slice(q, func(i, j int) bool {
		return q[i] < q[j]
	})
	r := 0
	for i := range q {
		if p[i] != q[i] {
			r++
		}
	}
	return r
}

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

package main

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

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

func main() {
	defer writer.Flush()

	var (
		t, n int
		s    string
	)
	fmt.Fscanf(reader, "%d\n", &t)

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

		arr := strings.Split(s, "")
		sort.Strings(arr)

		ans := 0
		for i := 0; i < len(arr); i++ {
			if arr[i] != string([]rune(s)[i]) {
				ans++
			}
		}
		fmt.Fprintf(writer, "%d\n", ans)

	}
}

package main

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

func main() {
	r := bufio.NewReaderSize(os.Stdin, 1024 * 1024)

	var T int

	fmt.Fscanf(r, "%d\n", &T)

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

		x := []byte(s)
		sort.Slice(x, func(i, j int) bool {
			return x[i] < x[j]
		})

		res := 0
		for i := 0; i < n; i++ {
			if x[i] != s[i] {
				res++
			}
		}
		fmt.Println(res)
	}
}

package main

import (
	"fmt"
	"sort"
)

type btaray []byte
func (this btaray) Len() int {
	return len(this)
}
func (this btaray) Less(i, j int) bool {
	return this[i] < this[j]
}
func (this btaray) Swap(i, j int) {
	this[i], this[j] = this[j], this[i]
}

func main()  {
	var t int
	fmt.Scan(&t)
	for ; t > 0;t-- {
		var n int
		fmt.Scan(&n)
		var s string
		fmt.Scan(&s)
		t := btaray{}
		for _,i:=range s{
			j := byte(i)
			t = append(t,j)
		}
		//t := s
		sort.Sort(t)
		ans := 0
		for i,j:=range s{
			if t[i]!=byte(j){
				ans ++
			}
		}
		fmt.Println(ans)
	}
}

package main

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

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

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

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

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

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

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

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

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

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

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

		}
		return initial
	}
}

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

		}
		return m
	}
}

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

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

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

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

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

	return
}

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

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

	return num
}

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

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

var t int

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

	for o := 0; o < t; o++ {
		var n int
		fmt.Fscan(input, &n)

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

		var ans int
		ARR := make([]int, 0)
		B := make([]int, 0)
		for i := 0; i < n; i++ {
			q := int(STRING[i])
			ARR = append(ARR, q)
			B = append(B, q)
		}
		sort.Ints(B)
		for i := 0; i < n; i++ {
			if B[i] != ARR[i] {
				ans++
			}
		}
		fmt.Println(ans)

	}

}

package main

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

var (
	t      int
	input  io.Reader = bufio.NewReader(os.Stdin)
	output           = bufio.NewWriter(os.Stdout)
)

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

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

	sBytes := make([]byte, n)
	sBytes = []byte(s)
	sSorted := make([]byte, 0)
	sSorted = append(sSorted, sBytes...)

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

	ans := 0
	for i := 0; i < n; i++ {
		if sBytes[i] != sSorted[i] {
			ans += 1
		}
	}

	fmt.Fprintln(output, ans)
}

func main() {
	t = 1
	fmt.Fscan(input, &t)

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

	defer output.Flush()
}

package main

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

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

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

}

func solve() {
	var n int
	fmt.Fscan(in, &n)
	var givenString string
	fmt.Fscan(in, &givenString)
	var temp runeSort
	temp = []rune(givenString)
	sort.Sort(temp)
	var ans int
	for i := 0; i < len(temp); i++ {
		if string(temp[i]) != string(givenString[i]) {
			ans++
		}
	}
	fmt.Println(ans)
}

func printArray(arr []int) {
	for i := 1; i < len(arr); i++ {
		fmt.Print(arr[i], " ")
	}
	fmt.Println()
}

type runeSort []rune

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

package main

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

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

	var s, tmp string
	var n int
	var k int

	var tmp2 []string

	for i := 0; i < t; i++ {
		fmt.Scan(&n)
		fmt.Scan(&s)

		tmp2 = strings.Split(s, "")
		sort.Strings(tmp2)
		tmp = strings.Join(tmp2, "")

		k = 0
		for j := 0; j < n; j++ {
			if s[j] != tmp[j] {
				k++
			}
		}
		fmt.Println(k)
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var l int
		var s string
		fmt.Scan(&l, &s)
		a := []byte(s)
		b := make([]byte, len(a))
		copy(b, a)
		sort.SliceStable(a, func(i, j int) bool {
			return a[i] < a[j]
		})
		res := 0
		for i := range a {
			if a[i] != b[i] {
				res++
			}
		}
		fmt.Println(res)
	}
}

package main

import (
	"fmt"
	"sort"
)

func dd(a string) {
	arr := []byte(a)
	sort.Slice(arr, func(a, b int) bool {
		return arr[a] < arr[b]
	})
	res := 0
	for i := 0; i < len(a); i++ {
		if arr[i] != a[i] {
			res++
		}
	}
	fmt.Println(res)
}

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a int
		var s string
		fmt.Scan(&a, &s)
		dd(s)
	}
}

package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

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

func solve() {
	var (
		n int
		s string
	)
	fmt.Fscan(read, &n, &s)
	fmt.Fprintln(write, getMax(s, n))

}

func getMax(s string, n int) int {

	var k int = 0
	b := []byte(s)
	sort.Slice(b, func(i, j int) bool {
		return b[i] < b[j]
	})
	for i := 0; i < len(s); i++ {
		if b[i] != s[i] {
			k++
		}
	}
	return k
}

package main

import (
	"fmt"
	"sort"
)

type byteSlice []byte

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

func getMinimumK(s string, n int) (k int) {
	bytes := make(byteSlice, 0)
	str := []byte(s)
	bytes = append(bytes, str...)
	sort.Sort(bytes)
	for i := 0; i < len(s); i++ {
		if bytes[i] != str[i] {
			k++
		}
	}
	return
}

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var (
			n int
			s string
		)
		fmt.Scan(&n, &s)
		fmt.Println(getMinimumK(s, n))
	}
}

package main

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

var (
	read = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func solve() {
	n := 0
	var word string
	fmt.Fscan(read, &n)
	fmt.Fscan(read, &word)
	nword := SortStringByCharacter(word)
	sum := 0
	for i := 0; i < len(nword); i++ {
		if nword[i] != word[i] {
			sum += 1
		}
	}
	fmt.Fprintln(write, sum)
}

func main() {
	defer write.Flush()
	t :=  0
	fmt.Fscan(read, &t)
	for i := 0; i < t; i++ {
		solve()
	}
}

type ByRune []rune

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

func StringToRuneSlice(s string) []rune {
      var r []rune
      for _, runeValue := range s {
              r = append(r, runeValue)
      }
      return r
}

func SortStringByCharacter(s string) string {
      var r ByRune = StringToRuneSlice(s)
      sort.Sort(r)
      return string(r)
}

package main

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

type Scanner struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) *Scanner {
	scanner := bufio.NewScanner(reader)
	scanner.Split(bufio.ScanWords)
	return &Scanner{scanner}
}

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

func (s *Scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *Scanner) Int64() int64 {
	s.Scan()
	n, _ := strconv.ParseInt(s.Text(), 10, 64)
	return n
}

func (s *Scanner) Words(count int) []string {
	words := make([]string, count)
	for i := range words {
		words[i] = s.Word()
	}
	return words
}

func (s *Scanner) Ints(count int) []int {
	ints := make([]int, count)
	for i := range ints {
		ints[i] = s.Int()
	}
	return ints
}

func (s *Scanner) Int64s(count int) []int64 {
	int64s := make([]int64, count)
	for i := range int64s {
		int64s[i] = s.Int64()
	}
	return int64s
}

func solve(s string) int {
	ss := []byte(s)
	sort.Slice(ss, func(i, j int) bool { return ss[i] < ss[j] })

	res := 0
	for i, ch := range []byte(s) {
		if ss[i] != ch {
			res += 1
		}
	}
	return res
}

func main() {
	stdin := NewWordScanner(os.Stdin)
	tests := stdin.Int()

	for i := 0; i < tests; i += 1 {
		stdin.Int()
		s := stdin.Word()
		fmt.Println(solve(s))
	}
}

package main

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

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

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

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

func _int() int {
	s := _string()
	i := 0
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int(r - '0')
	}
	return i
}

func _int64() int64 {
	s := _string()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func _string() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := _int(); t > 0; t-- {
		n := _int()
		s := _string()
		printf("%d\n", sol(n, s))
	}
}

func sol(n int, s string) int {
	b := []byte(s)
	sort.Slice(b, func(il, ir int) bool {
		return b[il] < b[ir]
	})
	k := 0
	for i := range b {
		if b[i] != s[i] {
			k++
		}
	}
	return k
}

package main

import (
    "fmt"
    "sort"
)

func main() {
    var t int
    fmt.Scanf("%d", &t)
    for i:=0 ; i<t; i+=1{
        var n int
        fmt.Scanf("%d", &n)
        var s string
        fmt.Scanf("%s", &s)
        //slce := []string{}
        var slce []string
        for j:=0; j<len(s); j+=1{
            slce = append(slce, string(s[j]) )
        }
        sort.Strings(slce)
        ans := 0
        for j:=0; j<len(s); j+=1{
            if string(s[j]) != slce[j]{
                ans += 1
            }
        }
        fmt.Println(ans)
    }
}

package main

import (
    "fmt"
    "sort"
)

func main() {
    var t int
    fmt.Scanf("%d", &t)
    for i:=0 ; i<t; i+=1{
        var n int
        fmt.Scanf("%d", &n)
        var s string
        fmt.Scanf("%s", &s)
        slce := []string{}
        for j:=0; j<len(s); j+=1{
            slce = append(slce, string(s[j]) )
        }
        sort.Strings(slce)
        ans := 0
        for j:=0; j<len(s); j+=1{
            if string(s[j]) != slce[j]{
                ans += 1
            }
        }
        fmt.Println(ans)
    }
}

package main

import (
    "fmt"
    "sort"
)

func main() {
    t := 0
    fmt.Scanf("%d", &t)
    for i:=0 ; i<t; i+=1{
        n:= 0
        fmt.Scanf("%d", &n)
        s:= ""
        fmt.Scanf("%s", &s)
        slce := []string{}
        for j:=0; j<len(s); j+=1{
            slce = append(slce, string(s[j]) )
        }
        sort.Strings(slce)
        ans := 0
        for j:=0; j<len(s); j+=1{
            if string(s[j]) != slce[j]{
                ans += 1
            }
        }
        fmt.Println(ans)
    }
}


Now Serval is a junior high school student in Japari Middle School, and he is still thrilled on math as before. As a talented boy in mathematics, he likes to play with numbers. This time, he wants to play with numbers on a rooted tree.A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. A parent of a node $$$v$$$ is the last different from $$$v$$$ vertex on the path from the root to the vertex $$$v$$$. Children of vertex $$$v$$$ are all nodes for which $$$v$$$ is the parent. A vertex is a leaf if it has no children.The rooted tree Serval owns has $$$n$$$ nodes, node $$$1$$$ is the root. Serval will write some numbers into all nodes of the tree. However, there are some restrictions. Each of the nodes except leaves has an operation $$$\max$$$ or $$$\min$$$ written in it, indicating that the number in this node should be equal to the maximum or minimum of all the numbers in its sons, respectively. Assume that there are $$$k$$$ leaves in the tree. Serval wants to put integers $$$1, 2, \ldots, k$$$ to the $$$k$$$ leaves (each number should be used exactly once). He loves large numbers, so he wants to maximize the number in the root. As his best friend, can you help him?

The first line contains an integer $$$n$$$ ($$$2 \leq n \leq 3\cdot 10^5$$$), the size of the tree. The second line contains $$$n$$$ integers, the $$$i$$$-th of them represents the operation in the node $$$i$$$. $$$0$$$ represents $$$\min$$$ and $$$1$$$ represents $$$\max$$$. If the node is a leaf, there is still a number of $$$0$$$ or $$$1$$$, but you can ignore it. The third line contains $$$n-1$$$ integers $$$f_2, f_3, \ldots, f_n$$$ ($$$1 \leq f_i \leq i-1$$$), where $$$f_i$$$ represents the parent of the node $$$i$$$.

Output one integer — the maximum possible number in the root of the tree.

NotePictures below explain the examples. The numbers written in the middle of the nodes are their indices, and the numbers written on the top are the numbers written in the nodes.In the first example, no matter how you arrange the numbers, the answer is $$$1$$$.  In the second example, no matter how you arrange the numbers, the answer is $$$4$$$.  In the third example, one of the best solution to achieve $$$4$$$ is to arrange $$$4$$$ and $$$5$$$ to nodes $$$4$$$ and $$$5$$$.  In the fourth example, the best solution is to arrange $$$5$$$ to node $$$5$$$.

package main

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

func addD(u, v int, edges [][]int) {
	if len(edges[u]) == 0 {
		edges[u] = make([]int, 0)
	}
	edges[u] = append(edges[u], v)
}
func dfsD(root, pre int, edges [][]int, dp, mat []int) int {
//	fmt.Printf("root=%d\n", root)

	sun := 0
	dpsum := 0
	maxsum := 0
	for _, next := range edges[root] {
		if pre == next {
			continue
		}
		sun += dfsD(next, root, edges, dp, mat)
		dpsum += dp[next]
		if maxsum == 0|| maxsum > dp[next] {
			maxsum = dp[next]
		}
	}
	if sun == 0 {
		dp[root] = 1
		return 1
	}
	if mat[root] == 0 {
		dp[root] = dpsum
	} else {
		dp[root] = maxsum
	}
//	fmt.Printf("root=%d dp=%d\n", root, dp[root])
	return sun
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var n, pre int
	fmt.Fscanf(buf, "%d\n", &n)
	mat := make([]int, n+1)
	edges := make([][]int, n+1)
	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%d", &mat[i+1])
	}
	fmt.Fscanf(buf, "\n")
	for i := 2; i <= n; i++ {
		fmt.Fscanf(buf, "%d", &pre)
		addD(i, pre, edges)
		addD(pre, i, edges)
	}
	fmt.Fscanf(buf, "\n")
	dp := make([]int, n+1)
	sum:=dfsD(1, -1, edges, dp, mat)
//	fmt.Printf("%v\n",dp)
	fmt.Printf("%d\n", sum - dp[1]+1)

}

package main

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

const INF int = 1000000007
var son [][]int
var limit, f []int
var leaf = 0

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 dfs(x int) {
	if len(son[x]) == 0 {
		leaf++
		f[x] = -1
		return
	}
	max, sum := -INF, 0
	for _, y := range son[x] {
		dfs(y)
		if f[y] > max {
			max = f[y]
		}
		sum += f[y]
	}
	if limit[x] == 0 {  // min
		f[x] = sum
	} else {  // max
		f[x] = max
	}
}

func main() {
	defer writer.Flush()

	var n, x int
	scanf("%d\n", &n)
	// printf("%d\n", n)
	for i := 0; i < n; i++ {
		scanf("%d", &x)
		// printf("%d ", x)
		limit = append(limit, x)
		f = append(f, 0)
		son = append(son, []int{})
	}
	scanf("\n");
	// printf("\n");
	for i := 1; i < n; i++ {
		scanf("%d", &x)
		// printf("%d %d\n", x, i + 1)
		son[x - 1] = append(son[x - 1], i)
	}
	dfs(0)
	printf("%d\n", leaf + f[0] + 1)
	// for i := 0; i < n; i++ {
	// 	printf("%d %d %d\n", i, f[i], len(son[i]))
	// }
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1153D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	var n, v, leafCnt int
	Fscan(in, &n)
	tp := make([]int8, n)
	for i := range tp {
		Fscan(in, &tp[i])
	}
	g := make([][]int, n)
	for w := 1; w < n; w++ {
		Fscan(in, &v)
		g[v-1] = append(g[v-1], w)
	}

	var f func(int) int
	f = func(v int) (cnt int) {
		if g[v] == nil {
			leafCnt++
			tp[v] = 1
			return 1
		}
		if tp[v] == 0 {
			for _, w := range g[v] {
				cnt += f(w)
			}
		} else {
			cnt = 1e9
			for _, w := range g[v] {
				if c := f(w); c < cnt {
					cnt = c
				}
			}
		}
		return
	}
	Fprint(_w, leafCnt+1-f(0))
}

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

package main

import "fmt"

const N int = 300010
const INF int = 1000000007
var son [N][]int
var limit, f, leaf [N]int

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

func dfs(x int) int {
    if son[x] == nil {
        leaf[x] = 1
        f[x] = 0
        return f[x]
    }
    max1, max2 := -INF, -INF
    for _, y := range son[x] {
        tmp := dfs(y)
        leaf[x] += leaf[y]
        max1 = Max(max1, tmp)
        max2 = Max(max2, leaf[y] + tmp)
    }
    if limit[x] == 0 {  // min
        f[x] = max2 - leaf[x]
    } else {  // max
        f[x] = max1
    }
    return f[x]  // negative
}

func main() {
    var n int
    fmt.Scan(&n)
    for i := 1; i <= n; i++ {
        fmt.Scan(&limit[i])
    }
    for i := 2; i <= n; i++ {
        var father int
        fmt.Scan(&father)
        son[father] = append(son[father], i)
    }
    ans := dfs(1)
    fmt.Println(leaf[1] + ans)
}

package main

import "fmt"

const N int = 300010
const INF int = 1000000007
var son [N][]int
var limit, f, leaf [N]int

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

func dfs(x int) int {
    if son[x] == nil {
        leaf[x] = 1
        f[x] = 0
        return f[x]
    }
    max1, max2 := -INF, -INF
    for _, y := range son[x] {
        tmp := dfs(y)
        leaf[x] += leaf[y]
        max1 = Max(max1, tmp)
        max2 = Max(max2, leaf[y] + tmp)
    }
    if limit[x] == 0 {  // min
        f[x] = max2 - leaf[x]
    } else {  // max
        f[x] = max1
    }
    return f[x]  // negative
}

func main() {
    var n int
    fmt.Scanf("%d", &n)
    for i := 1; i <= n; i++ {
        fmt.Scanf("%d", &limit[i])
    }
    for i := 2; i <= n; i++ {
        var father int
        fmt.Scanf("%d", &father)
        son[father] = append(son[father], i)
    }
    ans := dfs(1)
    fmt.Println(leaf[1] + ans)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1153D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	var n, v, leafCnt int
	Fscan(in, &n)
	tp := make([]int8, n)
	for i := range tp {
		Fscan(in, &tp[i])
	}
	g := make([][]int, n)
	for w := 1; w < n; w++ {
		Fscan(in, &v)
		g[v-1] = append(g[v-1], w)
	}

	var f func(int) int
	f = func(v int) (cnt int) {
		if g[v] == nil {
			leafCnt++
			tp[v] = 1
			return 1
		}
		if tp[v] == 0 {
			for _, w := range g[v] {
				if c := f(w); tp[w] == 0 {
					cnt += c
				} else {
					cnt++
				}
			}
		} else {
			cnt = 1e9
			hasMax := false
			for _, w := range g[v] {
				if c := f(w); c < cnt {
					cnt = c
				}
				if tp[w] != 0 {
					hasMax = true
				}
			}
			if hasMax {
				cnt = 1
			}
		}
		return
	}
	Fprint(_w, leafCnt+1-f(0))
}

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


There are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It is possible to get from one city to another only by bus. But all buses and roads are very old, so the Minister of Transport decided to build a new bus route. The Minister doesn't want to spend large amounts of money — he wants to choose two cities in such a way that the distance between them is minimal possible. The distance between two cities is equal to the absolute value of the difference between their coordinates.It is possible that there are multiple pairs of cities with minimal possible distance, so the Minister wants to know the quantity of such pairs. Your task is to write a program that will calculate the minimal possible distance between two pairs of cities and the quantity of pairs which have this distance.

The first line contains one integer number n (2 ≤ n ≤ 2·105). The second line contains n integer numbers a1, a2, ..., an ( - 109 ≤ ai ≤ 109). All numbers ai are pairwise distinct.

Print two integer numbers — the minimal distance and the quantity of pairs with this distance.

NoteIn the first example the distance between the first city and the fourth city is |4 - 6| = 2, and it is the only pair with this distance.

package main

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

func solve() {
	n := readInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = readInt()
	}
	sort.Ints(a)
	min := math.MaxInt32
	cnt := 0
	for i := 1; i < n; i++ {
		d := a[i] - a[i-1]
		if d < min {
			min = d
			cnt = 1
		} else if d == min {
			cnt++
		}
	}
	fmt.Println(min, cnt)
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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

package main

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

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

func main() {
	var arrI []int
	var arrS []string
	var tmp, min, count int
	min = 2000000000
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	line, _ := reader.ReadString('\n')
	line, _ = reader.ReadString('\n')
	arrS = strings.Split(strings.TrimSpace(line), " ")
	for j := range arrS {
		tmp, _ = strconv.Atoi(arrS[j])
		arrI = append(arrI, tmp)
	}
	sort.Ints(arrI)
	for i := 0; i < len(arrI)-1; i++ {
		if abs(arrI[i]-arrI[i+1]) < min {
			min = abs(arrI[i] - arrI[i+1])
			count = 1
		} else if abs(arrI[i]-arrI[i+1]) == min {
			count++
		}
	}
	writer.WriteString(strconv.Itoa(min) + " " + strconv.Itoa(count))
	writer.Flush()
}