// https://codeforces.com/problemset/problem/276/A
package main

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

func getTwoNum(text string) (int64, int64) {
	inputs := strings.Split(text, " ")
	input1, _ := strconv.ParseInt(inputs[0], 10, 32)
	input2, _ := strconv.ParseInt(inputs[1], 10, 32)
	return input1, input2
}

func calculateJoy(fi, ti, k int64) (joy int64) {
	if ti > k {
		joy = fi - (ti - k)
	} else {
		joy = fi
	}
	return
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	numRest, time := getTwoNum(scanner.Text())
	fun := int64(math.MinInt64)
	var i int64
	for i = 0; i < numRest; i++ {
		scanner.Scan()
		fi, ti := getTwoNum(scanner.Text())
		j := calculateJoy(fi, ti, time)
		if j > fun {
			fun = j
		}
	}
	fmt.Printf("%d", fun)
}

package main

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

func getLine(s *bufio.Scanner) (int,int) {
    s.Scan()
    ab := strings.Fields(s.Text())
    a, _ := strconv.Atoi(ab[0])
    b, _ := strconv.Atoi(ab[1])
    return a,b
}

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    n, k := getLine(scanner)
    max := math.MinInt32
    for i:=0 ; i<n ; i++ {
        a,b := getLine(scanner)
        c := 0
        if (b > k) {
            c = a -(b-k)
        } else {
            c = a
        }
        if c > max {max = c}
    }
    fmt.Println(max)
}

package main
import (
    "fmt"
)
func main() {
    var n,k,f,t,mj,j int
    fmt.Scan(&n,&k,&f,&t)
    if t>k {
        mj=f-(t-k)
    }else {
        mj=f
    }
    for i:=1; i<n; i++ {
        fmt.Scan(&f,&t)
        if t>k {
            j=f-(t-k)
        }else {
            j=f
        }
        if j>mj{
            mj = j
        }
    }
    fmt.Println(mj)
}

package main

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

const INF  = 1000000001

type Pair struct {
	first, second int
}

func sort(arr []int) []int {
	if len(arr) < 2 {
		return arr
	}
	left := 0
	right := len(arr) - 1
	pivot := rand.Int() % len(arr)

	arr[pivot], arr[right] = arr[right], arr[pivot]

	for i := 0; i < len(arr); i++ {
		if arr[i] < arr[right] {
			arr[i], arr[left] = arr[left], arr[i]
			left++
		}
	}

	arr[left], arr[right] = arr[right], arr[left]

	sort(arr[:left])
	sort(arr[left+1:])
	return arr
}

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

func solution(reader io.Reader, writer io.Writer) {
	var n, k, r int
	r = -INF
	fmt.Fscanf(reader, "%d %d\n", &n, &k)
	for i := 0; i < n; i++ {
		var f, t int
		fmt.Fscanf(reader, "%d %d\n", &f, &t)
		if t > k {
			r = max(r, f - (t - k))
		} else {
			r = max(r, f)
		}
	}
	fmt.Println(r)
}

func main() {

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

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

	solution(reader, writer)
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

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

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

func main() {
	defer w.Flush()
	var n int
	for I(&n, " ") == nil {
		solve(n)
	}
}

func solve(n int) {
	var k, t, f int64
	I(&k, "\n")
	max := int64(-1e10)
	for i := 0; i < n; i++ {
		I(&f, " ")
		I(&t, "\n")
		if t > k {
			o := f - (t - k)
			if max < o {
				max = o
			}
		} else {
			if max < f {
				max = f
			}
		}
	}
	O(max, "\n")
}

package main

import "fmt"

func main() {
  var n, k int
  fmt.Scan(&n, &k)
  var res int
  res = -1e9
  for i := 0; i < n; i++ {
    var f, t int
    fmt.Scan(&f, &t)
    if t <= k {
      if res < f {
        res = f;
      }
    } else {
      if res < f - t + k {
        res = f - t + k
      }
    }
  }
  fmt.Println(res)
}

package main

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

func main() {
    defer s.Flush()

	n, k := s.Next(), s.Next()
	m := math.MinInt32
	for ; n > 0; n-- {
		f, t := s.Next(), s.Next()
		if t > k {
			t -= k
			m = max(m, f - t)
		} else {
			m = max(m, f)
		}
	}
	s.Println(m)
}

func max(a... int) int {
	result := math.MinInt32
	for _, e := range a {
		if result < e {
			result = e
		}
	}
	return result
}

var (
	s *InOut
)

func init() {
	s = NewInOut(os.Stdin, os.Stdout)
}

type InOut struct {
	*bufio.Reader
	*bufio.Writer
}

func NewInOut(r io.Reader, w io.Writer) *InOut {
	return &InOut{bufio.NewReader(r), bufio.NewWriter(w)}
}

// Get Next Integer
func (s *InOut) Next() (r int) {
	b, _ := s.ReadByte()
	p := 1
	for (b < '0' || '9' < b) && b != '-' {
		b, _ = s.ReadByte()
	}
	if b == '-' {
		p = -1
		b, _ = s.ReadByte()
	}
	for '0' <= b && b <= '9' {
		r = 10*r + int(b-'0')
		b, _ = s.ReadByte()
	}
	return r * p
}

func (s *InOut) NextInt64() (r int64) {
	b, _ := s.ReadByte()
	p := int64(1)
	for (b < '0' || '9' < b) && b != '-' {
		b, _ = s.ReadByte()
	}
	if b == '-' {
		p = -1
		b, _ = s.ReadByte()
	}
	for '0' <= b && b <= '9' {
		r = 10*r + int64(b-'0')
		b, _ = s.ReadByte()
	}
	return r * p
}

// Get Next Line String
func (s *InOut) NextLine() (r string) {
    b, _ := s.ReadByte()
    for b == '\r' || b == '\n' {
        b, _ = s.ReadByte()
    }
    buf := make([]byte, 0)
    for ; b != '\r' && b != '\n'; b, _ = s.ReadByte() {
        buf = append(buf, b)
    }
    return string(buf)
}

// Get Next String using delimiter whitespace
func (s *InOut) NextStr() (r string) {
    return string(s.NextBytes())
}

// Get Next String using delimiter whitespace
func (s *InOut) NextBytes() (r []byte) {
	b, _ := s.ReadByte()
	for b == '\n' || b == ' ' {
		b, _ = s.ReadByte()
	}
	buf := make([]byte, 0)
	for ; b != '\n' && b != ' '; b, _ = s.ReadByte() {
		buf = append(buf, b)
	}
	return buf
}

// Print Strings using the suitable way to change type
func (s *InOut) Print(os ...interface{}) {
	for _, o := range os {
		switch o.(type) {
		case byte:
			s.WriteByte(o.(byte))
		case string:
			s.WriteString(o.(string))
		case int:
			s.WriteString(strconv.Itoa(o.(int)))
		case int64:
			s.WriteString(strconv.FormatInt(o.(int64), 10))
		default:
			s.WriteString(fmt.Sprint(o))
		}
	}
}

// Print Strings using the suitable way to change type with new line
func (s *InOut) Println(os ...interface{}) {
	for _, o := range os {
		s.Print(o)
	}
	s.Print("\n")
}

// Print immediately with new line (for debug)
func (s *InOut) PrintlnNow(o interface{}) {
	fmt.Println(o)
}

package main

import "fmt"

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

func main() {
    var n,k,f,t int
    fmt.Scan(&n,&k)
    ans := -1000000000
    for i := 0; i < n; i++ {
        fmt.Scan(&f,&t)
        if t > k {
            ans = max(ans,f-(t-k))
        } else {
            ans = max(ans,f)
        }
    }
    fmt.Println(ans)
}

package main

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

func main() {
    defer s.Flush()

	n, k := s.Next(), s.Next()
	m := math.MinInt32
	for ; n > 0; n-- {
		f, t := s.Next(), s.Next()
		if t > k {
			t -= k
		}
		m = max(m, f - t)
	}
	s.Println(m)
}

func max(a... int) int {
	result := math.MinInt32
	for _, e := range a {
		if result < e {
			result = e
		}
	}
	return result
}

var (
	s *InOut
)

func init() {
	s = NewInOut(os.Stdin, os.Stdout)
}

type InOut struct {
	*bufio.Reader
	*bufio.Writer
}

func NewInOut(r io.Reader, w io.Writer) *InOut {
	return &InOut{bufio.NewReader(r), bufio.NewWriter(w)}
}

// Get Next Integer
func (s *InOut) Next() (r int) {
	b, _ := s.ReadByte()
	p := 1
	for (b < '0' || '9' < b) && b != '-' {
		b, _ = s.ReadByte()
	}
	if b == '-' {
		p = -1
		b, _ = s.ReadByte()
	}
	for '0' <= b && b <= '9' {
		r = 10*r + int(b-'0')
		b, _ = s.ReadByte()
	}
	return r * p
}

func (s *InOut) NextInt64() (r int64) {
	b, _ := s.ReadByte()
	p := int64(1)
	for (b < '0' || '9' < b) && b != '-' {
		b, _ = s.ReadByte()
	}
	if b == '-' {
		p = -1
		b, _ = s.ReadByte()
	}
	for '0' <= b && b <= '9' {
		r = 10*r + int64(b-'0')
		b, _ = s.ReadByte()
	}
	return r * p
}

// Get Next Line String
func (s *InOut) NextLine() (r string) {
    b, _ := s.ReadByte()
    for b == '\r' || b == '\n' {
        b, _ = s.ReadByte()
    }
    buf := make([]byte, 0)
    for ; b != '\r' && b != '\n'; b, _ = s.ReadByte() {
        buf = append(buf, b)
    }
    return string(buf)
}

// Get Next String using delimiter whitespace
func (s *InOut) NextStr() (r string) {
    return string(s.NextBytes())
}

// Get Next String using delimiter whitespace
func (s *InOut) NextBytes() (r []byte) {
	b, _ := s.ReadByte()
	for b == '\n' || b == ' ' {
		b, _ = s.ReadByte()
	}
	buf := make([]byte, 0)
	for ; b != '\n' && b != ' '; b, _ = s.ReadByte() {
		buf = append(buf, b)
	}
	return buf
}

// Print Strings using the suitable way to change type
func (s *InOut) Print(os ...interface{}) {
	for _, o := range os {
		switch o.(type) {
		case byte:
			s.WriteByte(o.(byte))
		case string:
			s.WriteString(o.(string))
		case int:
			s.WriteString(strconv.Itoa(o.(int)))
		case int64:
			s.WriteString(strconv.FormatInt(o.(int64), 10))
		default:
			s.WriteString(fmt.Sprint(o))
		}
	}
}

// Print Strings using the suitable way to change type with new line
func (s *InOut) Println(os ...interface{}) {
	for _, o := range os {
		s.Print(o)
	}
	s.Print("\n")
}

// Print immediately with new line (for debug)
func (s *InOut) PrintlnNow(o interface{}) {
	fmt.Println(o)
}

package main
import (
	"fmt"
)
func main() {
	var n,k,f,t,mj,j int
	fmt.Scan(&n,&k,&f,&t)
	if t>k {
		mj=f-t-k
	}else {
		mj=f
	}
	for i:=1; i<n; i++ {
		fmt.Scan(&f,&t)
		if t>k {
			mj=f-t-k
		}else {
			mj=f
		}
		if j>mj{
			mj = j
		}
	}
	fmt.Println(mj)
}

package main

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

func getLine(s *bufio.Scanner) (int,int) {
    s.Scan()
    ab := strings.Fields(s.Text())
    a, _ := strconv.Atoi(ab[0])
    b, _ := strconv.Atoi(ab[1])
    return a,b
}

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    n, k := getLine(scanner)
    max := 0
    for i:=0 ; i<n ; i++ {
        a,b := getLine(scanner)
        c := 0
        if (b > k) {
            c = a - (b-k)
        } else {
            c = a
        }
        if c > max {max = c}
    }
    fmt.Println(max)
}

package main

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

const INF  = 1000000001

type Pair struct {
	first, second int
}

func sort(arr []int) []int {
	if len(arr) < 2 {
		return arr
	}
	left := 0
	right := len(arr) - 1
	pivot := rand.Int() % len(arr)

	arr[pivot], arr[right] = arr[right], arr[pivot]

	for i := 0; i < len(arr); i++ {
		if arr[i] < arr[right] {
			arr[i], arr[left] = arr[left], arr[i]
			left++
		}
	}

	arr[left], arr[right] = arr[right], arr[left]

	sort(arr[:left])
	sort(arr[left+1:])
	return arr
}

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

func solution(reader io.Reader, writer io.Writer) {
	var n, k, r int
	fmt.Fscanf(reader, "%d %d\n", &n, &k)
	for i := 0; i < n; i++ {
		var f, t int
		fmt.Fscanf(reader, "%d %d\n", &f, &t)
		if t > k {
			r = max(r, f - (t - k))
		} else {
			r = max(r, f)
		}
	}
	fmt.Println(r)
}

func main() {

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

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

	solution(reader, writer)
}


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscanf(in, "%d\n", &t)
	for k := 0; k < t; k++ {
		var n int
		groupsCount := 0
		isSorted := true
		fmt.Fscanf(in, "%d\n", &n)
		prev := 0
		for i := 0; i < n; i++ {
			var a int
			if i+1 == n {
				fmt.Fscanf(in, "%d\n", &a)
			} else {
				fmt.Fscanf(in, "%d", &a)
			}
			if prev > a {
				isSorted = false
			}
			prev = a
		}
		for i := 0; i < n; i++ {
			var b int
			if i+1 == n {
				fmt.Fscanf(in, "%d\n", &b)
			} else {
				fmt.Fscanf(in, "%d", &b)
			}
			groupsCount += b
		}
		if isSorted || (!isSorted && groupsCount != n && groupsCount != 0) {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

// https://codeforces.com/contest/x/problem/A
package main

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

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

func main() {
	var T int

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

func solver() string {
	var n int
	fmt.Fscan(input, &n)
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &a[i])
	}
	sum := 0
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &b[i])
		sum += b[i]
	}
	if sum == 0 || sum == n {
		m0 := 0
		m1 := 0
		for i := 0; i < n; i++ {
			if b[i] == 0 {
				if a[i] < m0 {return "NO"}
				m0 = a[i]
			}
			if b[i] == 1 {
				if a[i] < m1 {return "NO"}
				m1 = a[i]
			}
		}
	}

	return "YES"
}

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

package main

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

type item struct {
	value int
	ty int
}

//44828 79565 8501
// 0     1    1

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	buff := make([]byte, 2 * 1024 * 1024)

	scanner.Buffer(buff, 1024 * 1024)

	scanner.Scan()

	t := scanner.Text()

	testCases, err := strconv.Atoi(t)

	if err != nil {
		panic(err)
	}

	for j := 0; j < int(testCases); j ++ {
		scanner.Scan()

		N := scanner.Text()

		n, _  := strconv.Atoi(N)

		var items []item

		scanner.Scan()

		vs := scanner.Text()

		vsp := strings.Fields(vs)

		scanner.Scan()

		ts := scanner.Text()

		tsp := strings.Fields(ts)

		for k := 0 ; k < n; k ++ {
			v, _  := strconv.Atoi(vsp[k])
			t, _  := strconv.Atoi(tsp[k])

			items = append(items, item{value: v, ty: t})

		}

		ans := solve2(items)

		fmt.Println(ans)
	}
}

func solve2(items []item) string {

	var min item
	for i := 0; i < len(items); i++ {
		min = items[i]

		var minIndex int
		for j := i; j < len(items); j ++ {
			if items[j].value < min.value {
				min = items[j]
				minIndex = j
			}
		}
		if min.value != items[i].value {
			if min.ty == items[i].ty {

				var k int
				for k = 0; k < len(items); k ++ {
					if k != i && k != minIndex {
						if items[k].ty != items[minIndex].ty {
							temp := items[k]
							items[k] = items[i]
							items[i] = temp

							temp = items[i]
							items[i] = min
							items[minIndex] = temp

							break
						}
					}
				}

				if k == len(items) {
					return "NO"
				}

			} else {
				temp := items[i]
				items[i] = min
				items[minIndex] = temp
			}
		}
	}

	return "YES"
}

package main

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

func main() {
	t := nextInt()
	for i := 0; i < t; i++ {
		n := nextInt()
		as := nextInts(n)
		bs := nextInts(n)
		if solve(as, bs) {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

func solve(as, bs []int) bool {
	if sort.IntsAreSorted(as) {
		return true
	}
	found0 := false
	found1 := false
	for i := 0; i < len(bs); i++ {
		if bs[i] == 0 {
			found0 = true
		}
		if bs[i] == 1 {
			found1 = true
		}
		if found0 && found1 {
			return true
		}
	}
	return false
}

var sc = bufio.NewScanner(os.Stdin)

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

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

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

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

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

package main

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

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

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

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

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

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

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

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

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

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

var (
	t int

	n    int
	A, B []int
)

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

		solve()
	}
}

func solve() {
	ok := true
	for i := 1; i < n; i++ {
		if A[i-1] > A[i] {
			ok = false
			break
		}
	}

	if ok {
		fmt.Println("Yes")
		return
	}

	memo := make(map[int]bool)
	for _, b := range B {
		memo[b] = true
	}

	if len(memo) == 2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

package main

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

var nTest, n int
var a [555]int
var b [555]int

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	fmt.Fscanf(in, "%d\n", &nTest)

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

		// fmt.Println(n)
		for i := 0; i < n-1; i++ {
			fmt.Fscanf(in, "%d ", &a[i])
		}
		fmt.Fscanf(in, "%d\n", &a[n-1])

		for i := 0; i < n-1; i++ {
			fmt.Fscanf(in, "%d ", &b[i])
		}
		fmt.Fscanf(in, "%d\n", &b[n-1])

		// for i := 0; i < n; i++ {
		// 	fmt.Println(a[i])
		// }
		nonDecrease := true
		oneType := true

		for i := 0; i < n-1; i++ {
			if a[i] > a[i+1] {
				nonDecrease = false
			}

			if b[i] != b[i+1] {
				oneType = false
			}

		}

		if oneType && !nonDecrease {
			fmt.Fprintf(out, "No\n")
		} else {
			fmt.Fprintf(out, "Yes\n")
		}
	}
	out.Flush()
}

package main

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

var nTest, n int
var a [555]int
var b [555]int

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	fmt.Fscan(in, &nTest)

	for i := 0; i < nTest; i++ {
		fmt.Fscan(in, &n)

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

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

		nonDecrease := true
		oneType := true

		for i := 0; i < n-1; i++ {
			if a[i] > a[i+1] {
				nonDecrease = false
			}

			if b[i] != b[i+1] {
				oneType = false
			}

		}

		if oneType && !nonDecrease {
			fmt.Fprintln(out, "No")
		} else {
			fmt.Fprintln(out, "Yes")
		}
	}
	out.Flush()
}

package main

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

var nTest, n int
var a [555]int
var b [555]int

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	fmt.Fscanf(in, "%d\n", &nTest)

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

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

		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d", &b[i])
		}
		fmt.Fscanf(in, "\n")

		nonDecrease := true
		oneType := true

		for i := 0; i < n-1; i++ {
			if a[i] > a[i+1] {
				nonDecrease = false
			}

			if b[i] != b[i+1] {
				oneType = false
			}

		}

		if oneType && !nonDecrease {
			fmt.Fprintf(out, "No\n")
		} else {
			fmt.Fprintf(out, "Yes\n")
		}
	}
	out.Flush()
}

package main

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

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

	var t, n, v int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		has := [2]bool{}
		for ; n > 0; n-- {
			Fscan(in, &v)
			has[v] = true
		}
		if sort.IntsAreSorted(a) || has[0] && has[1] {
			Fprintln(out, "Yes")
		} else {
			Fprintln(out, "No")
		}
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	var t, n, v int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		has := [2]bool{}
		for ; n > 0; n-- {
			Fscan(in, &v)
			has[v] = true
		}
		if sort.IntsAreSorted(a) || has[0] && has[1] {
			Println("Yes")
		} else {
			Println("No")
		}
	}
}

package main

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

func min(a, b int) int {
	return int(math.Min(float64(a), float64(b)))
}

func max(a, b int) int {
	return int(math.Max(float64(a), float64(b)))
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t, now int64
	fmt.Fscanf(in, "%d\n", &t)
	for now < t {
		now++
		var n int
		fmt.Fscanf(in, "%v\n", &n)
		a := make([]int, n, n)
		b := make([]int, n, n)
		for i := 0;i < n;i++ {
			fmt.Fscan(in, &a[i])
		}
		fmt.Fscanf(in, "\n")
		for i := 0;i < n;i++ {
			fmt.Fscan(in, &b[i])
		}
		fmt.Fscanf(in, "\n")
		na := make([]int, 0, n)
		nb := make([]int, 0, n)
		for i := 0; i < n;i++ {
			if b[i] == 1 {
				nb = append(nb, a[i])
			} else {
				na = append(na, a[i])
			}
		}
		sort.Ints(b)
		pizda := false
		if b[0] == b[n - 1] {
			pizda = true
		}

		if pizda && (sort.IntsAreSorted(na) == false || sort.IntsAreSorted(nb) == false) {
			fmt.Fprintln(out, "No")
		} else {
			fmt.Fprintln(out, "Yes")
		}
	}
	return
}

package main
import (
        "fmt"
        "os"
        "bufio"
)
func worker(in *bufio.Reader) {
    var n, x, y int
    fmt.Fscan(in, &n)
    ans := true
    fmt.Fscan(in, &x)
    for i := 1; i < n; i++ {
        fmt.Fscan(in, &y)
        if x > y {
            ans = false
        }
        x = y
    }
    x, y = 0, 0
    for i := 0; i < n; i++ {
        var tmp int
        fmt.Fscan(in, &tmp)
        if tmp == 0 {
            x++
        } else {
            y++
        }
    }
    if x * y > 0 || ans {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }
}
func main(){
    var t int
    in := bufio.NewReader(os.Stdin)
    fmt.Fscan(in, &t)
    for ; t > 0; t-- {
        worker(in)
    }
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	scan := func(x ...interface{}) (n int, err error) {
		return fmt.Fscan(in, x...)
	}
	println := func(x ...interface{}) (n int, err error) {
		return fmt.Fprintln(out, x...)
	}

	var t int
	for scan(&t); t > 0; t-- {
		var n int
		scan(&n)
		var a int
		var aPrev int = -1
		isSorted := true
		for i := 0; i < n; i++ {
			scan(&a)
			if a < aPrev {
				isSorted = false
			}
			aPrev = a
		}
		var b int
		hasType0 := false
		hasType1 := false
		for i := 0; i < n; i++ {
			scan(&b)
			if b == 0 {
				hasType0 = true
			} else {
				hasType1 = true
			}
		}
		if (hasType0 && hasType1) || isSorted {
			println("Yes")
		} else {
			println("No")
		}
	}
}

package main

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

func main() {
	var t int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		increasing, zeros, ones := true, false, false
		var n int

		fmt.Fscan(in, &n)
		prev := -1
		for i := 0; i < n; i++ {
			var curr int
			fmt.Fscan(in, &curr)
			increasing = increasing && (prev <= curr)
			prev = curr
		}
		for i := 0; i < n; i++ {
			var curr int
			fmt.Fscan(in, &curr)
			if curr == 1 {
				ones = true
			} else {
				zeros = true
			}
		}
		if increasing || (ones && zeros) {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

package main

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

func main() {
	var t int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	var res string
	for i := 0; i < t; i++ {
		increasing, zeros, ones := true, false, false
		var n int

		fmt.Fscan(in, &n)
		prev := -1
		for i := 0; i < n; i++ {
			var curr int
			fmt.Fscan(in, &curr)
			increasing = increasing && (prev <= curr)
			prev = curr
		}
		for i := 0; i < n; i++ {
			var curr int
			fmt.Fscan(in, &curr)
			if curr == 1 {
				ones = true
			} else {
				zeros = true
			}
		}
		if increasing || (ones && zeros) {
			res += "Yes\n"
		} else {
			res += "No\n"
		}
	}
	fmt.Printf("%v", res)
}

package main

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

func main() {
	var t int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	var res string
	for i := 0; i < t; i++ {
		increasing, zeros, ones := true, false, false
		var n int

		fmt.Fscan(in, &n)
		prev := -1
		for i := 0; i < n; i++ {
			var curr int
			fmt.Fscan(in, &curr)
			increasing = increasing && (prev <= curr)
			prev = curr
		}
		for i := 0; i < n; i++ {
			var curr int
			fmt.Fscan(in, &curr)
			if curr == 1 {
				ones = true
			} else {
				zeros = true
			}
		}
		if increasing || (ones && zeros) {
			fmt.Println("Yes")
			res += "Yes\n"
		} else {
			fmt.Println("No")
			res += "No\n"
		}
	}
	//fmt.Printf("%v", res)
}

package main

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

func solve(s1 []string, s2 []string) string {
	a := []int{}
	b := []int{}
	for i := range s1 {
		v, _ := strconv.Atoi(s1[i])
		if s2[i] == "1" {
			b = append(b, v)
		} else {
			a = append(a, v)
		}
	}
	if len(a) > 0 && len(b) > 0 {
		return "Yes"
	}
	if len(a) == 0 {
		a = b
	}
	last := 0
	for i := range a {
		if a[i] < last {
			return "No"
		}
		last = a[i]
	}
	return "Yes"

}

func output(i int, ans string) {
	fmt.Printf("%s\n", ans)
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 1000000), 1000000)
	var numTests int
	scanner.Scan()
	fmt.Sscan(scanner.Text(), &numTests)
	for i := 1; i <= numTests; i++ {
		scanner.Scan()
		scanner.Scan()
		s1 := strings.Split(scanner.Text(), " ")
		scanner.Scan()
		s2 := strings.Split(scanner.Text(), " ")
		output(i, solve(s1, s2))
	}
}

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

package main

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

func Solve(n int, a []int, b []int) string {
	s := 0
	for _, elem := range b {
		s += elem
	}
	if s != 0 && s < n {
		return "Yes"
	}
	for i := 1; i < n; i++ {
		if a[i] < a[i-1] {
			return "No"
		}
	}
	return "Yes"
}

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

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

package main

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

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

type writerImpl struct {
	*bufio.Writer
}

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

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

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

type WordScanner interface {
	Int64() int64
	UInt64() uint64
	String() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

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

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

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

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

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

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

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

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

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
	defer writer.Flush()
	t := reader.Int64()
	for ; t > 0; t-- {
		n := reader.Int64()
		a := make([]int64, n)
		for i := range a {
			a[i] = reader.Int64()
		}
		b := make([]int64, n)
		for i := range b {
			b[i] = reader.Int64()
		}
		writer.Printf("%s\n", sol(a, b))
	}
}

func sol(a, b []int64) string {
	type0 := []int64{}
	type1 := []int64{}
	for i := range a {
		if b[i] == 0 {
			type0 = append(type0, a[i])
		} else {
			type1 = append(type1, a[i])
		}
	}
	if len(type0) > 0 && len(type1) > 0 {
		return "Yes"
	}
	if len(type1) == 0 {
		return isSorted(type0)
	}
	if len(type0) == 0 {
		return isSorted(type1)
	}
	return "Yes"
}

func isSorted(a []int64) string {
	for i := 1; i < len(a); i++ {
		if a[i] < a[i-1] {
			return "No"
		}
	}
	return "Yes"
}

package main

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

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

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		A := readNNums(reader, n)
		B := readNNums(reader, n)
		res := solve(n, A, B)

		if res {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, A []int, B []int) bool {
	cnt := make([]int, 2)

	for i := 0; i < n; i++ {
		cnt[B[i]]++
	}

	if cnt[0] > 0 && cnt[1] > 0 {
		return true
	}
	for i := 1; i < n; i++ {
		if A[i] < A[i-1] {
			return false
		}
	}
	return true
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		n := 0
		fmt.Fscanf(in, "%d\n", &n)
		a := make([]int, n)
		b := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d", &a[i])
		}
		fmt.Fscanf(in, "\n")
		haveOne := false
		haveZero := false
		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d", &b[i])
			if b[i] == 1 {
				haveOne = true
			} else {
				haveZero = true
			}
		}
		fmt.Fscanf(in, "\n")
		//fmt.Println(a, b)
		if haveOne && haveZero {
			fmt.Fprintf(out, "Yes\n")
		} else {
			ok := true
			for i := 1; i < n; i++ {
				if a[i] < a[i-1] {
					ok = false
					break
				}
			}
			if ok {
				fmt.Fprintf(out, "Yes\n")
			} else {
				fmt.Fprintf(out, "No\n")
			}
		}

	}
	return
}

package main

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

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

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		A := readNNums(reader, n)
		B := readNNums(reader, n)
		res := solve(n, A, B)

		if res {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, A []int, B []int) bool {
	cnt := make([]int, 2)

	for i := 0; i < n; i++ {
		cnt[B[i]]++
	}

	if B[0] > 0 && B[1] > 0 {
		return true
	}
	for i := 1; i < n; i++ {
		if A[i] < A[i-1] {
			return false
		}
	}
	return true
}

// https://codeforces.com/contest/x/problem/A
package main

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

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

func main() {
	var T int

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

func solver() string {
	var n int
	fmt.Fscan(input, &n)
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &a[i])
	}
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &b[i])
	}

	m0 := 0
	m1 := 0
	for i := 0; i < n; i++ {
		if b[i] == 0 {
			if a[i] < m0 {return "NO"}
			m0 = a[i]
		}
		if b[i] == 1 {
			if a[i] < m1 {return "NO"}
			m1 = a[i]
		}
	}

	return "YES"
}

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

package main

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

type item struct {
	value int
	ty int
}

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	buff := make([]byte, 2 * 1024 * 1024)

	scanner.Buffer(buff, 1024 * 1024)

	scanner.Scan()

	t := scanner.Text()

	testCases, err := strconv.Atoi(t)

	if err != nil {
		panic(err)
	}

	for j := 0; j < int(testCases); j ++ {
		scanner.Scan()

		N := scanner.Text()

		n, _  := strconv.Atoi(N)

		var items []item

		scanner.Scan()

		vs := scanner.Text()

		vsp := strings.Fields(vs)

		scanner.Scan()

		ts := scanner.Text()

		tsp := strings.Fields(ts)

		for k := 0 ; k < n; k ++ {
			v, _  := strconv.Atoi(vsp[k])
			t, _  := strconv.Atoi(tsp[k])

			items = append(items, item{value: v, ty: t})

		}

		ans := solve2(items)

		fmt.Println(ans)
	}
}

func solve2(items []item) string {

	for i:=1 ; i < len(items); i++ {
		for j := i ; j > 0; j-- {
			if items[j].value < items[j - 1].value {
				if items[j].ty == items[j - 1].ty {
					return "NO"
				}
				temp := items[j - 1]
				items[j - 1] = items[j]
				items[j] = temp
			}
		}
	}

	return "YES"
}

package main

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

type item struct {
	value int
	ty int
}

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	buff := make([]byte, 2 * 1024 * 1024)

	scanner.Buffer(buff, 1024 * 1024)

	scanner.Scan()

	t := scanner.Text()

	testCases, err := strconv.Atoi(t)

	if err != nil {
		panic(err)
	}

	for j := 0; j < int(testCases); j ++ {
		scanner.Scan()

		N := scanner.Text()

		n, _  := strconv.Atoi(N)

		var items []item

		scanner.Scan()

		vs := scanner.Text()

		vsp := strings.Fields(vs)

		scanner.Scan()

		ts := scanner.Text()

		tsp := strings.Fields(ts)

		for k := 0 ; k < n; k ++ {
			v, _  := strconv.Atoi(vsp[k])
			t, _  := strconv.Atoi(tsp[k])

			items = append(items, item{value: v, ty: t})

		}

		ans := solve2(items)

		fmt.Println(ans)
	}
}

func solve2(items []item) string {

	var min item
	for i := 0; i < len(items); i++ {
		min = items[i]

		var minIndex int
		for j := i; j < len(items); j ++ {
			if items[j].value < min.value {
				min = items[j]
				minIndex = j
			}
		}
		if min.value != items[i].value {
			if min.ty == items[i].ty {
				return "NO"
			}
			temp := items[i]
			items[i] = min
			items[minIndex] = temp
		}
	}

	return "YES"
}

package main

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

type item struct {
	value int
	ty int
}

//44828 79565 8501
// 0     1    1

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	buff := make([]byte, 2 * 1024 * 1024)

	scanner.Buffer(buff, 1024 * 1024)

	scanner.Scan()

	t := scanner.Text()

	testCases, err := strconv.Atoi(t)

	if err != nil {
		panic(err)
	}

	for j := 0; j < int(testCases); j ++ {
		scanner.Scan()

		N := scanner.Text()

		n, _  := strconv.Atoi(N)

		var items []item

		scanner.Scan()

		vs := scanner.Text()

		vsp := strings.Fields(vs)

		scanner.Scan()

		ts := scanner.Text()

		tsp := strings.Fields(ts)

		for k := 0 ; k < n; k ++ {
			v, _  := strconv.Atoi(vsp[k])
			t, _  := strconv.Atoi(tsp[k])

			items = append(items, item{value: v, ty: t})

		}

		ans := solve2(items)

		fmt.Println(ans)
	}
}

func solve2(items []item) string {

	var min item
	for i := 0; i < len(items); i++ {
		min = items[i]

		var minIndex int
		for j := i; j < len(items); j ++ {
			if items[j].value < min.value {
				min = items[j]
				minIndex = j
			}
		}
		if min.value != items[i].value {
			if min.ty == items[i].ty {

				var k int
				for k = 0; k < len(items); k ++ {
					if k != i && k != minIndex {
						if items[k].ty != items[minIndex].ty {
							temp := items[k]
							items[k] = items[i]
							items[i] = temp

							temp = items[i]
							items[i] = min
							items[minIndex] = temp
						}
					}
				}

				if k == len(items) {
					return "NO"
				}

			} else {
				temp := items[i]
				items[i] = min
				items[minIndex] = temp
			}
		}
	}

	return "YES"
}

package main

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

func min(a, b int) int {
	return int(math.Min(float64(a), float64(b)))
}

func max(a, b int) int {
	return int(math.Max(float64(a), float64(b)))
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t, now int64
	fmt.Fscanf(in, "%d\n", &t)
	for now < t {
		now++
		var n int
		fmt.Fscanf(in, "%v\n", &n)
		a := make([]int, n, n)
		b := make([]int, n, n)
		for i := 0;i < n;i++ {
			fmt.Fscan(in, &a[i])
		}
		fmt.Fscanf(in, "\n")
		for i := 0;i < n;i++ {
			fmt.Fscan(in, &b[i])
		}
		fmt.Fscanf(in, "\n")
		na := make([]int, 0, n)
		nb := make([]int, 0, n)
		for i := 0; i < n;i++ {
			if b[i] == 1 {
				nb = append(nb, a[i])
			} else {
				na = append(na, a[i])
			}
		}
		if sort.IntsAreSorted(na) && sort.IntsAreSorted(nb) {
			fmt.Fprintln(out, "Yes")
		} else {
			fmt.Fprintln(out, "No")
		}
	}
	return
}

package main

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

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

type writerImpl struct {
	*bufio.Writer
}

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

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

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

type WordScanner interface {
	Int64() int64
	UInt64() uint64
	String() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

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

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

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

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

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

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

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

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

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
	defer writer.Flush()
	t := reader.Int64()
	for ; t > 0; t-- {
		n := reader.Int64()
		a := make([]int64, n)
		for i := range a {
			a[i] = reader.Int64()
		}
		b := make([]int64, n)
		for i := range b {
			b[i] = reader.Int64()
		}
		writer.Printf("%s\n", sol(a, b))
	}
}

func sol(a, b []int64) string {
	type0 := []int64{}
	type1 := []int64{}
	for i := range b {
		if b[i] == 0 {
			type0 = append(type0, a[i])
		} else {
			type1 = append(type1, a[i])
		}
	}
	for i := 1; i < len(type0); i++ {
		if type0[i] < type0[i-1] {
			return "No"
		}
	}
	for i := 1; i < len(type1); i++ {
		if type1[i] < type1[i-1] {
			return "No"
		}
	}
	return "Yes"
}

package main

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

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

type writerImpl struct {
	*bufio.Writer
}

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

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

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

type WordScanner interface {
	Int64() int64
	UInt64() uint64
	String() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

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

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

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

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

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

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

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

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

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
	defer writer.Flush()
	t := reader.Int64()
	for ; t > 0; t-- {
		n := reader.Int64()
		a := make([]int64, n)
		for i := range a {
			a[i] = reader.Int64()
		}
		b := make([]int64, n)
		for i := range b {
			b[i] = reader.Int64()
		}
		writer.Printf("%s\n", sol(a, b))
	}
}

func sol(a, b []int64) string {
	type0 := []int64{}
	type1 := []int64{}
	for i := range b {
		if b[i] == 0 {
			type0 = append(type0, a[i])
		} else {
			type1 = append(type1, a[i])
		}
	}
	maxSwap := min(int64(len(type0)), int64(len(type1)))
	c0 := int64(0)
	for i := 1; i < len(type0); i++ {
		if type0[i] < type0[i-1] {
			c0++
		}
		if c0 > maxSwap {
			return "No"
		}
	}
	c1 := int64(0)
	for i := 1; i < len(type1); i++ {
		if type1[i] < type1[i-1] {
			c1++
		}
		if c1 > maxSwap {
			return "No"
		}
	}
	return "Yes"
}

package main

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

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

type writerImpl struct {
	*bufio.Writer
}

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

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

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

type WordScanner interface {
	Int64() int64
	UInt64() uint64
	String() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

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

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

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

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

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

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

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

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

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
	defer writer.Flush()
	t := reader.Int64()
	for ; t > 0; t-- {
		n := reader.Int64()
		a := make([]int64, n)
		for i := range a {
			a[i] = reader.Int64()
		}
		b := make([]int64, n)
		for i := range b {
			b[i] = reader.Int64()
		}
		writer.Printf("%s\n", sol(a, b))
	}
}

func sol(a, b []int64) string {
	type0 := []int64{}
	type1 := []int64{}
	for i := range b {
		if b[i] == 0 {
			type0 = append(type0, a[i])
		} else {
			type1 = append(type1, a[i])
		}
	}
	c0 := int64(0)
	for i := 1; i < len(type0); i++ {
		if type0[i] < type0[i-1] {
			c0++
		}
	}
	c1 := int64(0)
	for i := 1; i < len(type1); i++ {
		if type1[i] < type1[i-1] {
			c1++
		}
	}
	if c0 == 0 && c1 == 0 {
		return "Yes"
	}
	if c0 == 0 || c1 == 0 {
		return "No"
	}
	return "Yes"
}


package main

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

func ofdisk(_r io.Reader, _w io.Writer) {
	input := bufio.NewReader(_r)
	output := bufio.NewWriter(_w)
	defer output.Flush()

	var a, b, c int
	var x int64

	for fmt.Fscan(input, &a); a > 0; a-- {

		fmt.Fscan(input, &b, &c)
		s := make([]int64, b+1)
		p := []int{0}
		for i := 1; i <= b; i++ {
			fmt.Fscan(input, &x)
			s[i] = s[i-1] + x
			if s[i] > s[p[len(p)-1]] {
				p = append(p, i)
			}
		}
		for ; c > 0; c-- {
			fmt.Fscan(input, &x)
			if x <= s[p[len(p)-1]] {
				i := sort.Search(len(p), func(i int) bool { return s[p[i]] >= x })
				fmt.Fprint(output, p[i]-1, " ")
			} else if s[b] < 1 {
				fmt.Fprint(output, "-1 ")
			} else {
				loop := (x-s[p[len(p)-1]]-1)/s[b] + 1
				x -= loop * s[b]
				i := sort.Search(len(p), func(i int) bool { return s[p[i]] >= x })
				fmt.Fprint(output, loop*int64(b)+int64(p[i]-1), " ")
			}
		}
		fmt.Fprintln(output)
	}
}

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

package main

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

var (
    inn = bufio.NewScanner(os.Stdin)
    out = bufio.NewWriter(os.Stdout)
)

func main() {
    defer out.Flush()
    inn.Buffer([]byte{}, 10000000)
    inn.Split(bufio.ScanWords)
    //prep
    for tt:=rd(); tt>0 ;tt-- {
        n, m:=rd(), rd()
        a:=make([]int64, n)
        for i :=range a {
            a[i]=rdll()
        }
        ps:=make([]int64, n)
        ps[0]=a[0];
        for i:=1; i<n; i++ {
            ps[i]=ps[i-1]+a[i]
        }
        var mx int64
        for _, x := range ps {
            mx=maxll(mx, x)
        }
        type pair struct {
            first int64
            second int
        }
        inc:=make([]pair, 0)
        for i:=0; i<n; i++ {
            if len(inc)==0 || ps[i]>inc[len(inc)-1].first {
                inc=append(inc, pair{ps[i], i})
            }
        }

        for ; m>0; m-- {
            x:=rdll()
            if ps[n-1]<=0 && x>mx {
                Printf("-1 ")
            } else {
                if x<=mx {
                    Printf("%d ", inc[sort.Search(len(inc), func(i int) bool { return inc[i].first>=x })].second)
                } else {
                    back:=ps[n-1];
                    rev:=(x-mx+back-1)/back
                    x-=rev*back
                    Printf("%d ", int64(inc[sort.Search(len(inc), func(i int) bool { return inc[i].first>=x })].second)+int64(n)*rev)
                }
            }
        }
        Println()
    }
}

//-------------------template------------------
func gcd(a, b int) int {
    for b != 0 {
        a, b = b, a%b
    }
    return a
}
func max(a ...int) int {
    mx := a[0]
    for _, x := range a {
        if x > mx {
            mx = x
        }
    }
    return mx
}
func maxll(a ...int64) int64 {
    mx := a[0]
    for _, x := range a {
        if x > mx {
            mx = x
        }
    }
    return mx
}
func min(a ...int) int {
    mn := a[0]
    for _, x := range a {
        if x < mn {
            mn = x
        }
    }
    return mn
}
func minll(a ...int64) int64 {
    mn := a[0]
    for _, x := range a {
        if x < mn {
            mn = x
        }
    }
    return mn
}
func rd() (x int) {
    inn.Scan()
    x, _ = strconv.Atoi(string(inn.Bytes()))
    return x
}
func rdll() (x int64) {
    inn.Scan()
    x, _ = strconv.ParseInt(string(inn.Bytes()), 10, 64)
    return x
}
func rdch() (x byte) {
    inn.Scan()
    return inn.Bytes()[0]
}
func rds() string {
    inn.Scan()
    return string(inn.Bytes())
}

package main

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

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

	var T, n, q int
	var x int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &q)
		s := make([]int64, n+1)
		p := []int{0}
		for i := 1; i <= n; i++ {
			Fscan(in, &x)
			s[i] = s[i-1] + x
			if s[i] > s[p[len(p)-1]] {
				p = append(p, i)
			}
		}
		for ; q > 0; q-- {
			Fscan(in, &x)
			if x <= s[p[len(p)-1]] {
				i := sort.Search(len(p), func(i int) bool { return s[p[i]] >= x })
				Fprint(out, p[i]-1, " ")
			} else if s[n] < 1 {
				Fprint(out, "-1 ")
			} else {
				loop := (x-s[p[len(p)-1]]-1)/s[n] + 1
				x -= loop * s[n]
				i := sort.Search(len(p), func(i int) bool { return s[p[i]] >= x })
				Fprint(out, loop*int64(n)+int64(p[i]-1), " ")
			}
		}
		Fprintln(out)
	}
}
func main() { CF1490G(os.Stdin, os.Stdout) }

package main

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

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

	var T, n, q int
	var x int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &q)
		s := make([]int64, n+1)
		p := []int{0}
		for i := 1; i <= n; i++ {
			Fscan(in, &x)
			s[i] = s[i-1] + x
			if s[i] > s[p[len(p)-1]] {
				p = append(p, i)
			}
		}
		for ; q > 0; q-- {
			Fscan(in, &x)
			if x <= s[n] {
				i := sort.Search(len(p), func(i int) bool { return s[p[i]] >= x })
				Fprint(out, p[i]-1, " ")
			} else if s[n] < 1 {
				Fprint(out, "-1 ")
			} else {
				loop := (x-s[p[len(p)-1]]-1)/s[n] + 1
				x -= loop * s[n]
				i := sort.Search(len(p), func(i int) bool { return s[p[i]] >= x })
				Fprint(out, loop*int64(n)+int64(p[i]-1), " ")
			}
		}
		Fprintln(out)
	}
}

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

package main

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

func ofd(r io.Reader, w io.Writer) {
	input := bufio.NewReader(r)
	output := bufio.NewWriter(w)
	defer output.Flush()

	var a, b, c int
	var x int64

	for fmt.Fscan(input, &a); a > 0; a-- {

		fmt.Fscan(input, &b, &c)
		s := make([]int64, b+1)
		p := []int{0}
		for i := 1; i <= b; i++ {
			fmt.Fscan(input, &x)
			s[i] = s[i-1] + x
			if s[i] > s[p[len(p)-1]] {
				p = append(p, i)
			}
		}
		for ; c > 0; c-- {
			fmt.Fscan(input, &x)
			if x <= s[p[len(p)-1]] {
				i := sort.Search(len(p), func(i int) bool { return s[p[i]] >= x })
				fmt.Fprint(output, p[i]-1, " ")
			} else if s[b] < 1 {
				fmt.Fprint(output, "-1 ")
			} else {
				loop := (x-s[p[len(p)-1]]-1)/s[b] + 1
				x -= loop * s[b]
				i := sort.Search(len(p), func(i int) bool { return s[p[i]] >= x })
				fmt.Fprint(output, loop*int64(b)+int64(p[i]-1), " ")
			}
		}

		fmt.Println("")

		fmt.Fprintln(output)
	}
}

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


package main

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

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var n,k int64
		fmt.Scanf("%d %d\n", &n, &k)
		first, t := getFirst(k)
		second := k - t
		s := strings.Builder{}
		// fmt.Println(first, second)
		for i:=int64(0);i<n;i++ {
			if i== n - first || i == n - second {
				s.WriteByte('b')
			} else {
				s.WriteByte('a')
			}
		}
		fmt.Println(s.String())
	}
}

func getFirst(n int64) (int64, int64){
	k, i := int64(0), int64(0)
	for ;;i++ {
		k = i * (i+1) / 2
		if k >= n {
			return i+1, (i-1)*i / 2
		}
	}
}

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

package main

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

var reader io.Reader
var scanner *bufio.Scanner

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	T := NextInt()

	f := make([][3]int64, 100001)
	f[0][0] = 1
	for i := 1; i <= 100000; i++ {
		for j := 0; j <= 2; j++ {
			f[i][j] = f[i-1][j]
			if j > 0 {
				f[i][j] += f[i-1][j-1]
			}
		}
	}

	s := make([]byte, 100010)

	for t := 0; t < T; t++ {
		n := NextInt()
		k := NextInt64() - 1

		bs := 2
		for i := n; i >= 1; i-- {
			if k < f[i-1][bs] {
				s[n-i] = 'a'
				continue
			} else {
				s[n-i] = 'b'
				k -= f[i-1][bs]
				bs--
			}
		}
		fmt.Fprintln(out, string(s[:n]))
	}

}

package main

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

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

	in := func() int64 {
		sc.Scan()
		i, _ := strconv.ParseInt(sc.Text(), 10, 64)
		return i
	}

	for t := in(); t > 0; t-- {
		n, k := in(), in()

		var s, n1 int64 = 0, n-1

		for s+(n - n1) < k {
			s += (n-n1)
			n1--
		}

		var r int64 = k - s
		r = n1 + (n - n1 - r + 1)

		// fmt.Println(n1, r)

		var i int64
		for i = 1; i <= n; i++ {
			if i == r || i == n1 {
				fmt.Print("b")
			} else {
				fmt.Print("a")
			}
		}

		fmt.Println()
	}
}

package main

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

func main() {
	for t := ScanInt64(); t > 0; t-- {
		n, k := ScanInt(), ScanInt()
		outputString := []rune(strings.Repeat("a", n))
		for i := n - 2; i >= 0; i--{
			if k <= n - 1 - i{
				outputString[i] = 'b'
				outputString[n - k] = 'b'
				break
			}
			k -= n - 1 - i
		}
		P(string(outputString))
	}

	close(O)
	oWg.Wait()
}

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

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

func init() {
	P = fmt.Println

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

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

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

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

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

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

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

/*
URL:
https://codeforces.com/problemset/problem/1328/B
*/

package main

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

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

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

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

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

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

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

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

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

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

var (
	t    int
	n, k int64
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		n, k = ReadInt64_2()

		solve()
	}
}

func solve() {
	A := make([]rune, n)

	i := BinarySearch(0, 200000, func(mid int64) bool {
		return mid*(mid+1)/2 < k
	})
	cnt := k - i*(i+1)/2
	l, r := n-1-(i+1), n-1-(cnt-1)

	for j := int64(0); j < n; j++ {
		A[j] = 'a'
	}
	A[l], A[r] = 'b', 'b'

	fmt.Println(string(A))
}

func BinarySearch(initOK, initNG int64, isOK func(mid int64) bool) (ok int64) {
	ng := initNG
	ok = initOK
	for int(math.Abs(float64(ok-ng))) > 1 {
		mid := (ok + ng) / 2
		if isOK(mid) {
			ok = mid
		} else {
			ng = mid
		}
	}

	return ok
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

package main

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

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

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

func main() {
	defer writer.Flush()

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

	var a [100001]int64

	a[0] = 1
	var cntr int64 = 2

	for i := 1;i<100001;i++ {
		a[i] = a[i-1] + cntr
		cntr++
	}

	for t>0 {
		t--
		var n,k int64
		scanf("%d %d\n", &n, &k)

		i := sort.Search(len(a), func(i int) bool { return k <= a[i] })

		if(i==0) {
			str := ""
			for i:=int64(0);i<n-2;i++ {
				str += "a"
			}
			str += "bb"
			printf("%v\n", str)
			continue
		}

		i--

		k -= a[i]

		start := n-int64(i)-int64(3)

		end := n-k

		str := ""

		for i:=int64(0);i<n;i++ {
			if i==start || i==end {
				str+="b"
			} else {
				str += "a"
			}
		}

		printf("%v\n", str)
	}
}

package main

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

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

	var t, n, k int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &k)
		ans := bytes.Repeat([]byte{'a'}, n)
		i := 1
		for ; k > i; i++ {
			k -= i
		}
		ans[n-1-i] = 'b'
		ans[n-k] = 'b'
		Fprintf(out, "%s\n", ans)
	}
}

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

package main

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

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

	var nt, n, k int
	fmt.Fscanf(reader, "%d\n", &nt)
	for kk:=0; kk < nt; kk++ {
		fmt.Fscanf(reader, "%d %d\n", &n, &k)
		for i := n - 1; i >= 1; i-- {
			var rm = n - i
			if k <= rm {
				var p1 = i
				var p2 = n - k + 1
				for j := 1; j <= n; j++ {
					if j == p1 || j == p2 {
						fmt.Fprintf(writer, "b")
					} else {
						fmt.Fprintf(writer, "a")
					}
				}
				fmt.Fprintf(writer, "\n")
				break
			}
			k -= rm
		}

	}
}

package main

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

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

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

package main

import (
	"fmt"
	"bytes"
)

func gen_str(n, a, b int) string{
	var buffer bytes.Buffer

	for i := 0; i < a; i++ {
		buffer.WriteString("a")
	}
	buffer.WriteString("b")

	for i := 0; i < b; i++ {
		buffer.WriteString("a")
	}
	buffer.WriteString("b")

	for i := 0; i < (n - a - b - 2); i++ {
		buffer.WriteString("a")
	}

	return buffer.String()
}

func main() {
    var t, n, k, idx int

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

        s := 0
        for j := 1; j < n && s < k; j++ {
			s += j
			idx = j
		}

		s -= idx
		for j := 0; ;j++ {
			s++
			if s == k {
				a := n - idx - 1
				b := idx - j - 1
				fmt.Println(gen_str(n, a, b))
				break
			}
		}
    }
}

package main

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

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

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

var sc = newScanner()

func main() {
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	for t := scanInt(); t > 0; t-- {
		n, k := scanInt(), scanInt()
		ans := bytes.Repeat([]byte{'a'}, n)
		x, s := 0, 0
		for s < k {
			x++
			s += x
		}
		l, r := x, x-(s-k)-1
		ans[n-l-1] = 'b'
		ans[n-r-1] = 'b'
		// i := 1
		// for ; k > i; i++ {
		// 	k -= i
		// }
		// ans[n-1-i] = 'b'
		// ans[n-k] = 'b'
		fmt.Fprintf(w, "%s\n", ans)
	}
}

package main

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

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

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

var sc = newScanner()

func main() {
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	for t := scanInt(); t > 0; t-- {
		n, k := scanInt(), scanInt()
		ans := bytes.Repeat([]byte{'a'}, n)
		// x, s := 0, 0
		// for s < k {
		// 	x++
		// 	s = x * (x + 1) / 2
		// }
		// l, r := x, x-(s-k)-1
		// ans[n-l-1] = 'b'
		// ans[n-r-1] = 'b'
		i := 1
		for ; k > i; i++ {
			k -= i
		}
		ans[n-1-i] = 'b'
		ans[n-k] = 'b'
		fmt.Fprintf(w, "%s\n", ans)
	}
}

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

package main

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

func Solve(n, k int64) string {
	right := n * (n - 1) / 2
	x := int64(0)
	y := int64(0)
	for i := int64(1); i <= n-1; i++ {
		left := right - (n - i) + 1
		if left <= k && k <= right {
			y = n - (k - left)
			x = i
			break
		}
		right = left - 1
	}
	s := make([]string, n)
	for i := int64(0); i < n; i++ {
		if i == x-1 || i == y-1 {
			s[i] = "b"
		} else {
			s[i] = "a"
		}
	}
	return strings.Join(s, "")
}

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

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

package main

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

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

type wordScannerImpl struct {
	*bufio.Scanner
}

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

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

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

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

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

type writerImpl struct {
	*bufio.Writer
}

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

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

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

var (
	reader = NewWordScanner(os.Stdin)
	writer = NewWriter(os.Stdout)
)

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n := reader.NextInt64()
		k := reader.NextInt64()
		writer.Printf("%s\n", sol(n, k))
	}
}

func sol(n, k int64) string {
	bytes := make([]byte, n)
	first, second := getPos(n, k)
	for i := range bytes {
		if int64(i) == first || int64(i) == second {
			bytes[i] = 'b'
		} else {
			bytes[i] = 'a'
		}
	}
	return string(bytes)
}

func getPos(n, k int64) (int64, int64) {
	curr := int64(2)
	for (curr*(curr-1))/2 < k {
		curr += 1
	}
	diff := (curr*(curr-1))/2 - k
	return n - curr, n - curr + diff + 1
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var n, k, b1, b2, i uint64
	var result []byte
	scanner.Scan()
	for scanner.Scan() {
		fmt.Sscanf(scanner.Text(), "%d %d", &n, &k)
		b1 = n - 1
		b2 = n - 1
		for i = 1; i < k; i++ {
			if b1 != b2 {
				if b2-b1 < k-i {
					// skip loop runs..
					i = i + b2 - b1 - 1
					b2 = b1
					continue
				}
				b2--
			} else {
				b1--
				b2 = n - 1
			}
		}
		b1--
		// bytes.Repeat needs an int: n is max 100000, int is minimum int32, int32 storeds 2147483647 => uint64 to int is ok
		result = bytes.Repeat([]byte("a"), int(n)+1)
		result[b1] = 'b'
		result[b2] = 'b'
		result[n] = '\n'
		os.Stdout.Write(result)
	}
}

package main

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

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

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

func main() {
	defer writer.Flush()

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

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

func exec() {
	var n, k uint64
	scanf("%d %d\n", &n, &k)

	unoPositionFirst := uint64(0)
	unoPositionSecond := uint64(1)

	numb := n * (n - 1) / 2
	sec := n - 1
	for {
		if k < numb {
			numb -= sec
			sec--
			unoPositionFirst++
			unoPositionSecond++
			continue
		}
		break
	}

	if numb != k {
		unoPositionSecond = n - (k - numb)
		unoPositionFirst--
	}

	result := bytes.Repeat([]byte{'a'}, int(n))
	result[unoPositionFirst] = 'b'
	result[unoPositionSecond] = 'b'

	if k == 1 {
		result = append(bytes.Repeat([]byte{'a'}, int(n-2)), 'b', 'b')
	}

	printf("%s\n", result)
}

package main

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

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

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

func main() {
	defer writer.Flush()

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

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

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

	if n == 1 {
		printf("%s\n", strings.Repeat("a", n-2)+"bb")
		return
	}

	unoPositionFirst := 0
	unoPositionSecond := 1

	numb := n * (n - 1) / 2
	sec := n - 1
	for {
		if k < numb {
			numb -= sec
			sec--
			unoPositionFirst++
			unoPositionSecond++
			continue
		}
		break
	}

	if numb != k {
		unoPositionSecond = n - (k - numb)
		unoPositionFirst--
	}

	result := []byte(strings.Repeat("a", n))
	result[unoPositionFirst] = 'b'
	result[unoPositionSecond] = 'b'
	printf("%s\n", result)
}

package main

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

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

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

func main() {
	defer writer.Flush()

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

	var a [100001]int

	a[0] = 1
	var cntr int = 2

	for i := 1;i<100001;i++ {
		a[i] = a[i-1] + cntr
		cntr++
	}

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

		i := sort.Search(len(a), func(i int) bool { return k <= a[i] })

		if(i==0) {
			str := ""
			for i:=0;i<n-2;i++ {
				str += "a"
			}
			str += "bb"
			printf("%v\n", str)
			continue
		}

		i--

		k -= a[i]

		start := n-i-3
		end := n-k

		str := ""

		for i:=0;i<n;i++ {
			if i==start || i==end {
				str+="b"
			} else {
				str += "a"
			}
		}

		printf("%v\n", str)
	}
}

package main

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

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

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

var sc = newScanner()

func main() {
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	t := scanInt()
	for i := 0; i < t; i++ {
		n, k := scanInt(), scanInt()
		r := -1
		for j := n - 1; j >= 0; j-- {
			c := "a"
			if r >= 0 {
				if j == r {
					c = "b"
				}
			} else {
				v := j * (j + 1) / 2
				if k <= v && k > v-j {
					r = j - 1 - (v - k)
					c = "b"
				}
			}
			fmt.Fprint(w, c)
		}
		fmt.Fprintln(w)
	}
}

package main

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

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

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

var sc = newScanner()

func main() {
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	t := scanInt()
	for i := 0; i < t; i++ {
		n, k := scanInt(), scanInt()
		r := -1
		for j := n - 1; j >= 0; j-- {
			c := "a"
			if r == -1 {
				v := j*(j-1)/2 + 1
				if k >= v {
					r = k - v
					c = "b"
				}
			} else if j == r {
				c = "b"
			}
			fmt.Fprint(w, c)
		}
		fmt.Fprintln(w)
	}
}

package main

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

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

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

var sc = newScanner()

func main() {
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	t := scanInt()
	for i := 0; i < t; i++ {
		n, k := scanInt(), scanInt()
		r := -1
		for j := n - 1; j >= 0; j-- {
			c := "a"
			if r >= 0 && j == r {
				c = "b"
			} else {
				v := j * (j + 1) / 2
				if k <= v && k > v-j {
					r = j - 1 - (v - k)
					c = "b"
				}
			}
			fmt.Fprint(w, c)
		}
		fmt.Fprintln(w)
	}
}

package main

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

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

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

var sc = newScanner()

func main() {
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	t := scanInt()
	for i := 0; i < t; i++ {
		n, k := scanInt(), scanInt()
		r := -1
		for j := n - 1; j >= 0; j-- {
			c := "a"
			if r == -1 {
				v := j*(j-1)/2 + 1
				if k >= v {
					r = k - v
					c = "b"
				}
			} else if j == r {
				c = "b"
			}
			fmt.Println(n, k, j, r)
			fmt.Fprint(w, c)
		}
		fmt.Fprintln(w)
	}
}

package main

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

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

type wordScannerImpl struct {
	*bufio.Scanner
}

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

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

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

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

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

type writerImpl struct {
	*bufio.Writer
}

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

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

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

var (
	reader = NewWordScanner(os.Stdin)
	writer = NewWriter(os.Stdout)
)

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n := reader.NextInt64()
		k := reader.NextInt64()
		writer.Printf("%s\n", sol(n, k))
	}
}

func sol(n, k int64) string {
	bytes := make([]byte, n)
	first, second := getPos(n, k)
	writer.Printf("first=%d, second=%d\n", first, second)
	for i := range bytes {
		if int64(i) == first || int64(i) == second {
			bytes[i] = 'b'
		} else {
			bytes[i] = 'a'
		}
	}
	return string(bytes)
}

func getPos(n, k int64) (int64, int64) {
	curr := int64(2)
	for (curr*(curr-1))/2 < k {
		curr += 1
	}
	diff := (curr*(curr-1))/2 - k
	return n - curr, n - curr + diff + 1
}

package main

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

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

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

func main() {
	defer writer.Flush()

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

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

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

	unoPositionFirst := 0
	unoPositionSecond := 1

	numb := n * (n - 1) / 2
	sec := n - 1
	for {
		if k < numb {
			numb -= sec
			sec--
			unoPositionFirst++
			unoPositionSecond++
			continue
		}
		break
	}

	if numb != k {
		unoPositionSecond = n - (k - numb)
		unoPositionFirst--
	}

	result := bytes.Repeat([]byte{'a'}, n)
	result[unoPositionFirst] = 'b'
	result[unoPositionSecond] = 'b'

	if _, err := writer.Write(result); err != nil {
		fmt.Println(err.Error())
		panic(err)
	}
	if _, err := writer.Write([]byte{'\n'}); err != nil {
		fmt.Println(err.Error())
		panic(err)
	}
}

package main

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

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

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

func main() {
	defer writer.Flush()

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

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

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

	if n == 1 {
		printf("%s\n", strings.Repeat("a", n-2)+"bb")
		return
	}

	unoPositionFirst := 0
	unoPositionSecond := 1

	numb := n * (n - 1) / 2
	sec := n - 1
	for {
		if k < numb {
			numb -= sec
			sec--
			unoPositionFirst++
			unoPositionSecond++
			continue
		}
		break
	}

	if numb != k {
		unoPositionSecond = n - (k - numb)
		unoPositionFirst--
	}

	result := []byte(strings.Repeat("a", n))
	result[unoPositionFirst] = 'b'
	result[unoPositionSecond] = 'b'
	printf("%s\n", string(result))
}

package main

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

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

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

func main() {
	defer writer.Flush()

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

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

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

	unoPositionFirst := 0
	unoPositionSecond := 1

	numb := n * (n - 1) / 2
	sec := n - 1
	for {
		if k < numb {
			numb -= sec
			sec--
			unoPositionFirst++
			unoPositionSecond++
			continue
		}
		break
	}

	if numb != k {
		unoPositionSecond = n - (k - numb)
		unoPositionFirst--
	}

	result := []byte(strings.Repeat("a", n))
	result[unoPositionFirst] = 'b'
	result[unoPositionSecond] = 'b'
	printf("%s\n", string(result))
}

/*
001100 12
011000 24
001000 8
010000 16

1 aaaabb 3
2 aaabab 5
3 aaabba 6
4 aabaab 9
5 aababa 10
6 aabbaa 12
7 abaaab 17
8 abaaba 18
9 ababaa 20
10 abbaaa 24
11 baaaab 33
12 baaaba 34
13 baabaa 36
14 babaaa 40
15 bbaaaa 48
*/

package main

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

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

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

func main() {
	defer writer.Flush()

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

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

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

	unoPositionFirst := 0
	unoPositionSecond := 1

	numb := n * (n - 1) / 2
	sec := n - 1
	for {
		if k < numb {
			numb -= sec
			sec--
			unoPositionFirst++
			unoPositionSecond++
			continue
		}
		break
	}

	if numb != k {
		unoPositionSecond = n - (k - numb)
		unoPositionFirst--
	}

	result := bytes.Repeat([]byte{'a'}, n)
	result[unoPositionFirst] = 'b'
	result[unoPositionSecond] = 'b'

	printf("%s\n", result)
}

package main

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

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

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

func main() {
	defer writer.Flush()

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

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

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

	if n == 1 {
		printf("%s\n", append(bytes.Repeat([]byte{'a'}, n-2), 'b', 'b'))
		return
	}

	unoPositionFirst := 0
	unoPositionSecond := 1

	numb := n * (n - 1) / 2
	sec := n - 1
	for {
		if k < numb {
			numb -= sec
			sec--
			unoPositionFirst++
			unoPositionSecond++
			continue
		}
		break
	}

	if numb != k {
		unoPositionSecond = n - (k - numb)
		unoPositionFirst--
	}

	result := []byte(strings.Repeat("a", n))
	result[unoPositionFirst] = 'b'
	result[unoPositionSecond] = 'b'
	printf("%s\n", result)
}

package main

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

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

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

func main() {
	defer writer.Flush()

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

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

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

	unoPositionFirst := 0
	unoPositionSecond := 1

	numb := n * (n - 1) / 2
	sec := n - 1
	for {
		if k < numb {
			numb -= sec
			sec--
			unoPositionFirst++
			unoPositionSecond++
			continue
		}
		break
	}

	if numb != k {
		unoPositionSecond = n - (k - numb)
		unoPositionFirst--
	}

	result := append(bytes.Repeat([]byte{'a'}, n), '\n')
	result[unoPositionFirst] = 'b'
	result[unoPositionSecond] = 'b'
	_, err := writer.Write(result)
	if err != nil {
		fmt.Println(err.Error())
		panic(err)
	}
}

package main

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

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

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

func main() {
	defer writer.Flush()

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

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

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

	if n == 1 {
		printf("%s\n", strings.Repeat("a", n-2)+"bb")
		return
	}

	unoPositionFirst := 0
	unoPositionSecond := 1

	numb := n * (n - 1) / 2
	sec := n - 1
	for {
		if k < numb {
			numb -= sec
			sec--
			unoPositionFirst++
			unoPositionSecond++
			continue
		}
		break
	}

	if numb != k {
		unoPositionSecond = n - (k - numb)
		unoPositionFirst--
	}

	result := []byte(strings.Repeat("a", n))
	result[unoPositionFirst] = 'b'
	result[unoPositionSecond] = 'b'
	println(string(result))
}

package main

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

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

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

func main() {
	defer writer.Flush()

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

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

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

	if n == 1 {
		writer.Write(append(bytes.Repeat([]byte{'a'}, n-2), 'b', 'b'))
		return
	}

	unoPositionFirst := 0
	unoPositionSecond := 1

	numb := n * (n - 1) / 2
	sec := n - 1
	for {
		if k < numb {
			numb -= sec
			sec--
			unoPositionFirst++
			unoPositionSecond++
			continue
		}
		break
	}

	if numb != k {
		unoPositionSecond = n - (k - numb)
		unoPositionFirst--
	}

	result := []byte(strings.Repeat("a", n))
	result[unoPositionFirst] = 'b'
	result[unoPositionSecond] = 'b'
	printf("%s\n", result)
}

package main

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

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

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

func main() {
	defer writer.Flush()

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

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

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

	unoPositionFirst := 0
	unoPositionSecond := 1

	numb := n * (n - 1) / 2
	sec := n - 1
	for {
		if k < numb {
			numb -= sec
			sec--
			unoPositionFirst++
			unoPositionSecond++
			continue
		}
		break
	}

	if numb != k {
		unoPositionSecond = n - (k - numb)
		unoPositionFirst--
	}

	result := []byte(strings.Repeat("a", n))
	result[unoPositionFirst] = 'b'
	result[unoPositionSecond] = 'b'
	printf("%s\n", string(result))
	fmt.Println(len(string(result)))
	fmt.Println(unoPositionFirst, unoPositionSecond)
}

package main

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

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

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

func main() {
	defer writer.Flush()

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

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

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

	unoPositionFirst := 0
	unoPositionSecond := 1

	numb := n * (n - 1) / 2
	sec := n - 1
	for {
		if k < numb {
			numb -= sec
			sec--
			unoPositionFirst++
			unoPositionSecond++
			continue
		}
		break
	}

	if numb != k {
		unoPositionSecond = n - (k - numb)
		unoPositionFirst--
	}

	result := make([]byte, n)
	for i := 0; i < n; i++ {
		if i == unoPositionFirst || i == unoPositionSecond {
			result[i] = 'b'
			continue
		}
		result[i] = 'a'
	}

	if _, err := writer.Write(result); err != nil {
		fmt.Println(err.Error())
		panic(err)
	}
	if _, err := writer.Write([]byte{'\n'}); err != nil {
		fmt.Println(err.Error())
		panic(err)
	}
}