For the given integer $$$n$$$ ($$$n > 2$$$) let's write down all the strings of length $$$n$$$ which contain $$$n-2$$$ letters 'a' and two letters 'b' in lexicographical (alphabetical) order.Recall that the string $$$s$$$ of length $$$n$$$ is lexicographically less than string $$$t$$$ of length $$$n$$$, if there exists such $$$i$$$ ($$$1 \le i \le n$$$), that $$$s_i < t_i$$$, and for any $$$j$$$ ($$$1 \le j < i$$$) $$$s_j = t_j$$$. The lexicographic comparison of strings is implemented by the operator < in modern programming languages.For example, if $$$n=5$$$ the strings are (the order does matter):  aaabb  aabab  aabba  abaab  ababa  abbaa  baaab  baaba  babaa  bbaaa It is easy to show that such a list of strings will contain exactly $$$\frac{n \cdot (n-1)}{2}$$$ strings.You are given $$$n$$$ ($$$n > 2$$$) and $$$k$$$ ($$$1 \le k \le \frac{n \cdot (n-1)}{2}$$$). Print the $$$k$$$-th string from the list.

The input contains one or more test cases. The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the test. Then $$$t$$$ test cases follow. Each test case is written on the the separate line containing two integers $$$n$$$ and $$$k$$$ ($$$3 \le n \le 10^5, 1 \le k \le \min(2\cdot10^9, \frac{n \cdot (n-1)}{2})$$$. The sum of values $$$n$$$ over all test cases in the test doesn't exceed $$$10^5$$$.

For each test case print the $$$k$$$-th string from the list of all described above strings of length $$$n$$$. Strings in the list are sorted lexicographically (alphabetically).

aaabb
aabab
baaba
bbaaa
abb
bab
aaaaabaaaaabaaaaaaaa

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
}

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
}

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


You are given an array of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$You can apply the following operation an arbitrary number of times:   select an index $$$i$$$ ($$$1 \le i \le n$$$) and replace the value of the element $$$a_i$$$ with the value $$$a_i + (a_i \bmod 10)$$$, where $$$a_i \bmod 10$$$ is the remainder of the integer dividing $$$a_i$$$ by $$$10$$$. For a single index (value $$$i$$$), this operation can be applied multiple times. If the operation is applied repeatedly to the same index, then the current value of $$$a_i$$$ is taken into account each time. For example, if $$$a_i=47$$$ then after the first operation we get $$$a_i=47+7=54$$$, and after the second operation we get $$$a_i=54+4=58$$$.Check if it is possible to make all array elements equal by applying multiple (possibly zero) operations.For example, you have an array $$$[6, 11]$$$.   Let's apply this operation to the first element of the array. Let's replace $$$a_1 = 6$$$ with $$$a_1 + (a_1 \bmod 10) = 6 + (6 \bmod 10) = 6 + 6 = 12$$$. We get the array $$$[12, 11]$$$.  Then apply this operation to the second element of the array. Let's replace $$$a_2 = 11$$$ with $$$a_2 + (a_2 \bmod 10) = 11 + (11 \bmod 10) = 11 + 1 = 12$$$. We get the array $$$[12, 12]$$$. Thus, by applying $$$2$$$ operations, you can make all elements of an array equal.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. What follows is a description of each test case. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the size of the array. The second line of each test case contains $$$n$$$ integers $$$a_i$$$ ($$$0 \le a_i \le 10^9$$$) — array elements. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case print:   YES if it is possible to make all array elements equal;  NO otherwise.  You can print YES and NO in any case (for example, the strings yEs, yes, Yes and YES will be recognized as a positive answer) .

NoteThe first test case is clarified above.In the second test case, it is impossible to make all array elements equal.In the third test case, you need to apply this operation once to all elements equal to $$$5$$$.In the fourth test case, you need to apply this operation to all elements until they become equal to $$$8$$$.In the fifth test case, it is impossible to make all array elements equal.In the sixth test case, you need to apply this operation to all elements until they become equal to $$$102$$$.

package main

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

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

func solve() string {
	var n int
	fmt.Fscan(in, &n)
	arr := make([]int, n)
	var fives int
	for i := range arr {
		fmt.Fscan(in, &arr[i])
		arr[i] += arr[i] % 10
		if arr[i]%10 == 5 || arr[i]%10 == 0 {
			fives++
		}
	}

	if fives > 0 && fives != n {
		return "NO"
	}

	sort.Ints(arr)
	min := arr[0]
	max := arr[n-1]
	if min == max {
		return "YES"
	}

	if fives == n {
		if max-min == 5 && min%10 == 5 {
			return "YES"
		} else {
			return "NO"
		}
	}

	//dedup
	d := make([]int, 0, n)
	for i := 0; i < n-1; i++ {
		if arr[i] != arr[i+1] {
			d = append(d, arr[i])
		}
	}
	d = append(d, arr[n-1])

	// AHAHHA THAT ACTUALLY WORKED LMAO
	for i := 0; i < n-1; i++ {
		for arr[i]+100000000 < max {
			arr[i] += 100000000
		}
		for arr[i]+10000000 < max {
			arr[i] += 10000000
		}
		for arr[i]+1000000 < max {
			arr[i] += 1000000
		}
		for arr[i]+100000 < max {
			arr[i] += 100000
		}
		for arr[i]+10000 < max {
			arr[i] += 10000
		}
		for arr[i]-max < 10 {
			arr[i] += arr[i] % 10
		}
		if abs(max-arr[i]) == 10 {
			return "NO"
		}
	}

	return "YES"
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscanln(in, &t); t > 0; t-- {
		fmt.Fprintln(out, solve())
	}
}

// util functions
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

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

func makeMatrix(n, m int) [][]int {
	x := make([][]int, n)
	for i := range x {
		x[i] = make([]int, m)
	}
	return x
}

package main

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

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

func solve() string {
	var n int
	fmt.Fscan(in, &n)
	arr := make([]int, n)
	var fives int
	for i := range arr {
		fmt.Fscan(in, &arr[i])
		arr[i] += arr[i] % 10
		if arr[i]%10 == 5 || arr[i]%10 == 0 {
			fives++
		}
	}

	if fives > 0 && fives != n {
		return "NO"
	}

	sort.Ints(arr)
	min := arr[0]
	max := arr[n-1]
	if min == max {
		return "YES"
	}

	if fives == n {
		if max-min == 5 && min%10 == 5 {
			return "YES"
		} else {
			return "NO"
		}
	}

	//dedup
	d := make([]int, 0, n)
	for i := 0; i < n-1; i++ {
		if arr[i] != arr[i+1] {
			d = append(d, arr[i])
		}
	}
	d = append(d, arr[n-1])

	for i := 0; i < n-1; i++ {
		for arr[i]+100000000 < max {
			arr[i] += 100000000
		}
		for arr[i]+10000000 < max {
			arr[i] += 10000000
		}
		for arr[i]+1000000 < max {
			arr[i] += 1000000
		}
		for arr[i]+100000 < max {
			arr[i] += 100000
		}
		for arr[i]+50000 < max {
			arr[i] += 50000
		}
		for arr[i]+10000 < max {
			arr[i] += 10000
		}
		for arr[i]-max < 10 {
			arr[i] += arr[i] % 10
		}
		if abs(max-arr[i]) == 10 {
			return "NO"
		}
	}

	return "YES"
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscanln(in, &t); t > 0; t-- {
		fmt.Fprintln(out, solve())
	}
}

// util functions
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

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

func makeMatrix(n, m int) [][]int {
	x := make([][]int, n)
	for i := range x {
		x[i] = make([]int, m)
	}
	return x
}

package main

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

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

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

		aa := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
			if aa[i]%10 == 5 {
				aa[i] += 5
			} else if aa[i]%10 != 0 {
				for aa[i]%10 != 2 {
					aa[i] += aa[i] % 10
				}
				aa[i] %= 20
			}
		}

		f := true
		for i := 1; i < n; i++ {
			if aa[i-1] != aa[i] {
				f = false
			}
		}
		if !f {
			fmt.Fprintln(out, "No")
		} else {
			fmt.Fprintln(out, "Yes")
		}
	}
}

package main

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

var (
	in   *bufio.Scanner
	out  *bufio.Writer
	once = false
)

func solve() {
	in.Scan()
	n, _ := strconv.Atoi(in.Text())
	a := make(map[int]int)
	for i := 0; i < n; i++ {
		in.Scan()
		ai, _ := strconv.Atoi(in.Text())
		if ai%10 == 5 || ai%10 == 0 {
			if ai%10 == 5 {
				ai = ai + 5
			}
			a[ai]++
		} else {
			if ai%2 != 0 {
				ai = ai + ai%10
			}
			ai = ai % 20
			switch ai {
			case 2, 4, 8, 16:
				a[-1]++
			default:
				a[-2]++
			}
		}
	}
	if len(a) > 1 {
		out.WriteString("No\n")
	} else {
		out.WriteString("Yes\n")
	}
}

func main() {
	in = bufio.NewScanner(os.Stdin)
	in.Split(bufio.ScanWords)
	out = bufio.NewWriter(os.Stdout)
	defer out.Flush()

	if once {
		solve()
		return
	}
	in.Scan()
	x, _ := strconv.Atoi(in.Text())
	for t := 0; t < x; t++ {
		solve()
	}
}

package main

import (
	"bufio"
	"flag"
	"fmt"
	"log"
	"os"
	"runtime/pprof"
	"strconv"
	"strings"
)

var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")

// func main() {
// 	flag.Parse()
// 	if *cpuprofile != "" {
// 		f, err := os.Create(*cpuprofile)
// 		if err != nil {
// 			log.Fatal(err)
// 		}
// 		pprof.StartCPUProfile(f)
// 		defer pprof.StopCPUProfile()
// 	}

// 	in := bufio.NewReader(os.Stdin)
// 	tc := readInt(in)

// 	for i := 0; i < tc; i++ {
// 		n := readInt(in)
// 		_ = readArrInt(in)
// 		fmt.Println("N: ", n)
// 		fmt.Println("DONE TC: ", i+1)
// 	}
// }

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

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

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

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

func exec(n int, arr []int) bool {
	// for i := 0; i < n; i++ {
	// 	fmt.Scan(&arr[i])
	// }
	var node11, node71, node51 = 0, 0, 0
	var node12, node72, node52 = 0, 0, 0
	for i := 0; i < n; i++ {
		var r = arr[i] % 10
		var q = arr[i] / 10
		if r == 1 || r == 2 || r == 4 || r == 8 {
			if q%2 == 0 {
				node12++
			} else {
				node11++
			}
		} else if r == 7 || r == 9 || r == 3 || r == 6 {
			if q%2 == 0 {
				node72++
			} else {
				node71++
			}
		} else {
			if q%2 == 0 {
				node52++
			} else {
				node51++
			}
		}
	}
	if node51+node52 > 0 {
		if node11+node71+node12+node72 > 0 {
			return false
		}
		var i5, i0 = -1, -1
		for i := 0; i < n; i++ {
			if arr[i]%10 == 0 {
				i0 = arr[i]
			} else if arr[i]%10 == 5 {
				i5 = arr[i]
			}
		}
		if i0 == -1 {
			i0 = i5 + 5
		}
		for i := 0; i < n; i++ {
			if arr[i]%10 == 0 {
				if i0 != arr[i] {
					return false
				}
			} else if arr[i]%10 == 5 {
				if i0-arr[i] != 5 {
					return false
				}
			}
		}
	} else {
		if node11 > 0 && node12 > 0 {
			return false
		}
		if node71 > 0 && node72 > 0 {
			return false
		}
		if node11 > 0 && node71 > 0 {
			return false
		}
		if node12 > 0 && node72 > 0 {
			return false
		}
	}
	return true
}

func main() {
	flag.Parse()
	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}

	in := bufio.NewReader(os.Stdin)

	var T, n int
	// fmt.Scan(&T)
	T = readInt(in) // var arr = make([]int, 2*100005)
	for it := 0; it < T; it++ {
		// fmt.Scan(&n)
		n = readInt(in)
		var arr = readArrInt(in)
		var is = exec(n, arr)
		if is {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

package main

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

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

func ReadInt() int{
	var i int
	fmt.Fscan(in, &i)
	return i
}

// 1 -> 2 -> 4 -> 8 -> 6 -> 2 -> ....
// 0 -> 0
// 3 -> 6 -> 2
// 5 -> 0
// 7 -> 4
// 9 -> 8

func main(){
	defer out.Flush()

	t := ReadInt()

	for ; t > 0; t--{
		n := ReadInt()
		a := make([]int, n)
		hasFiveDivisor := false
		for i:=0;i<n;i++{
			a[i]=ReadInt()
			if a[i]%5==0{
				hasFiveDivisor = true
			}
		}
		can:=true
		if hasFiveDivisor {
			for i:=0;i<n;i++{
				a[i] = a[i]+a[i]%10
				if a[i] != a[0]{
					can = false
					break
				}
			}
		} else{
			for i :=0; i < n; i++ {
				for a[i]%10!=2{
					a[i] += a[i]%10
				}
				if a[i]%20 !=a[0]%20{
					can = false
					break
				}
			}
		}
		if can{
			fmt.Fprintln(out, "Yes")
		} else{
			fmt.Fprintln(out, "No")
		}
	}
}

func Gcd(u, v int) int {
	if u == 0 {
		return v
	}

	return Gcd(v%u, u)
}

package main

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

func readLine() string {
	s, err := f.ReadString('\n')
	if err != nil {
		panic(err)
	}
	s = strings.ReplaceAll(s, "\n", "")
	s = strings.ReplaceAll(s, "\r", "")
	return s
}

func readInts(n int) []int {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	arr := make([]int, n)
	for k, a := range as {
		x, _ := strconv.ParseInt(a, 10, 64)
		arr[k] = int(x)
	}
	return arr
}

var f = bufio.NewReader(os.Stdin)

func main() {
	var t, n int

	l1 := readInts(1)
	t = l1[0]

	for i := 0; i < t; i++ {
		n = readInts(1)[0]
		arr := readInts(n)
		tt1 := -1
		tt2 := -1
		s1, s2 := false, false
		no := false
		for _, a := range arr {
			if a%10 == 0 || a%10 == 5 {
				s1 = true
				x := a
				for x%10 != 0 {
					x += x % 10
				}
				if tt1 == -1 {
					tt1 = x
				} else if tt1 != x {
					no = true
				}
			} else {
				s2 = true
				x := a
				for x%10 != 2 {
					x += x % 10
				}
				x = x % 20
				if tt2 == -1 {
					tt2 = x
				} else if tt2 != x {
					no = true
				}
			}
		}
		if s1 && s2 {
			fmt.Println("NO")
		} else {
			if no {
				fmt.Println("NO")
			} else {
				fmt.Println("YES")
			}
		}
	}
}

package main

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

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

	groups := []int {
		-1, 1, 1, 2, 1,
		-1, 2, 2, 1, 2,
		-1, 2, 2, 1, 2,
		-1, 1, 1, 2, 1 }

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		var n, a int
		fmt.Fscan(r, &n)

		g := make([]int, n)
		for i := range g {
			fmt.Fscan(r, &a)
			g[i] = groups[a % 20]
			if g[i] == -1 { g[i] = a + (a%10) }
		}

		res := "YES"
		for i := 1; i < n; i++ {
			if g[i] != g[i-1] {
				res = "NO"
				break
			}
		}

		fmt.Fprintln(w, res)

	}

}

// https://codeforces.com/problemset/problem/1714/E

// 1714E - Add Modulo 10

// You are given an array of n integers a1,a2,…,an
// You can apply the following operation an arbitrary number of times:
//  • select an index i (1≤i≤n) and replace the value of the element ai with the value ai+(aimod10), where aimod10 is the remainder of the integer dividing ai by 10.
// For a single index (value i), this operation can be applied multiple times. If the operation is applied repeatedly to the same index, then the current value of ai is taken into account each time. For example, if ai=47 then after the first operation we get ai=47+7=54, and after the second operation we get ai=54+4=58.
// Check if it is possible to make all array elements equal by applying multiple (possibly zero) operations.
// For example, you have an array [6,11].
//  • Let's apply this operation to the first element of the array. Let's replace a1=6 with a1+(a1mod10)=6+(6mod10)=6+6=12. We get the array [12,11].
//  • Then apply this operation to the second element of the array. Let's replace a2=11 with a2+(a2mod10)=11+(11mod10)=11+1=12. We get the array [12,12].
// Thus, by applying 2 operations, you can make all elements of an array equal.

// Input
// The first line contains one integer t (1≤t≤104) — the number of test cases. What follows is a description of each test case.
// The first line of each test case contains one integer n (1≤n≤2⋅105) — the size of the array.
// The second line of each test case contains n integers ai (0≤ai≤109) — array elements.
// It is guaranteed that the sum of n over all test cases does not exceed 2⋅105.

// Output
// For each test case print:
//  • YES if it is possible to make all array elements equal;
//  • NO otherwise.
// You can print YES and NO in any case (for example, the strings yEs, yes, Yes and YES will be recognized as a positive answer) .

// Example
// input
// 10
// 2
// 6 11
// 3
// 2 18 22
// 5
// 5 10 5 10 5
// 4
// 1 2 4 8
// 2
// 4 5
// 3
// 93 96 102
// 2
// 40 6
// 2
// 50 30
// 2
// 22 44
// 2
// 1 5
// output
// Yes
// No
// Yes
// Yes
// No
// Yes
// No
// No
// Yes
// No

// Note

// The first test case is clarified above.
// In the second test case, it is impossible to make all array elements equal.
// In the third test case, you need to apply this operation once to all elements equal to 5.
// In the fourth test case, you need to apply this operation to all elements until they become equal to 8.
// In the fifth test case, it is impossible to make all array elements equal.
// In the sixth test case, you need to apply this operation to all elements until they become equal to 102.

package main

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

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	var c, t, n, i int
	var a []int
	var ans bool

	for c, _ = fmt.Fscan(reader, &t); c == 1; c, _ = fmt.Fscan(reader, &t) {
		for ; t > 0; t-- {
			fmt.Fscan(reader, &n)
			a = make([]int, n)

			for i = 0; i < n; i++ {
				fmt.Fscan(reader, &a[i])

				for a[i]%10 != 2 && a[i]%10 != 0 {
					a[i] += a[i] % 10
				}
			}

			ans = true

			if a[0]%10 == 2 {
				for i = 1; i < n && ans; i++ {
					ans = ans && (a[i]%10 == 2 && a[i]%20 == a[i-1]%20)
				}
			} else {
				for i = 1; i < n && ans; i++ {
					ans = ans && (a[i] == a[i-1])
				}
			}

			if ans {
				fmt.Fprintln(writer, "Yes")
			} else {
				fmt.Fprintln(writer, "No")
			}
		}
	}

	writer.Flush()
}

package main

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

var _, _, _ = main, rw, do

func main() {
	r, w := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer w.Flush()
	rw(r, w)
}

func rw(r io.Reader, w io.Writer) {
	var t int
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		var n int
		fmt.Fscan(r, &n)
		a := make([]int, n)
		for i := range a {
			fmt.Fscan(r, &a[i])
		}
		w1 := do(n, a)
		fmt.Fprintln(w, w1)
	}
}

func do(n int, a []int) string {
	f := func(x int) (b map[int]bool, c int) {
		b = map[int]bool{}
		c = -1
		if x%10 == 0 {
			b[x] = true
			return
		}
		if x%10 == 5 {
			b[x] = true
			b[x+5] = true
			return
		}
		for x%10 != 2 {
			b[x] = true
			x += x % 10
		}
		c = x / 10
		return
	}
	g := func(b0, b1, b2 map[int]bool, c int) {
		for x := range b0 {
			if b1[x] {
				b2[x] = true
				continue
			}
			if c == -1 {
				continue
			}
			y := x % 10
			z := x / 10
			switch y {
			case 2, 4, 8:
				if z < c || z%2 != c%2 {
					continue
				}
			case 6:
				if z < c+1 || z%2 != (c+1)%2 {
					continue
				}
			default:
				continue
			}
			b2[x] = true
		}
	}
	b0, c0 := f(a[0])
	for i := 1; i < n; i++ {
		b1, c1 := f(a[i])
		b2, c2 := make(map[int]bool), -1
		g(b0, b1, b2, c1)
		g(b1, b0, b2, c0)
		if c0 != -1 && c1 != -1 && c0%2 == c1%2 {
			if c0 > c1 {
				c2 = c0
			} else {
				c2 = c1
			}
		}
		b0, c0 = b2, c2
		if len(b0) == 0 && c0 == -1 {
			return "No"
		}
	}
	return "Yes"
}

package main

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

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

func qwq() {
	var n int
	fmt.Fscan(in, &n)
	a := make([]int, n)
	ht := map[int]int{}
	state := -1
	for i := 0; i < n; i++ {

		fmt.Fscan(in, &a[i])
		x := a[i] % 10
		switch x {
		case 0, 5:
			if v, ok := ht[x]; !ok {
				ht[x] = a[i]
			} else if a[i] != v {
				ht[x] = -1
				state = -2
			}
		case 3:
			a[i] += 9
		case 6, 7, 9:
			a[i] += a[i] % 10
		}
		_, ok0 := ht[0]
		_, ok5 := ht[5]
		if state == -2 {
			continue
		}
		if state == -1 && x != 0 && x != 5 {
			state = a[i] / 10 & 1
		} else if state != -1 && (state != a[i]/10&1) {
			state = -2
		}
		if state != -1 && (ok0 || ok5) {
			state = -2
		}
	}

	if state == -1 {
		x, ok0 := ht[0]
		y, ok5 := ht[5]
		if ok0 && ok5 && y+5 != x {
			state = -2
		} else {
			state = 0
		}
	}
	// fmt.Fprintln(out, state)
	if state >= 0 {
		fmt.Fprintln(out, "YES")
	} else {
		fmt.Fprintln(out, "NO")
	}

}

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

package main

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

const (
	N = 1e5 + 5
)

var a []int
var b = []int{2, 4, 8, 6}
var n int
var ans bool

func check(now int) bool {
	for i := range a {
		if a[i]%10 == 0 {
			return false
		}
		for a[i]%10 != now {
			a[i] += a[i] % 10
		}
	}
	for i := 0; i < n-1; i++ {
		if (a[n-1]-a[i])%20 != 0 {
			return false
		}
	}
	return true
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for o := 0; o < t; o++ {
		fmt.Fscan(in, &n)
		a = make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
			if a[i]%10 == 5 {
				a[i] += 5
			}
		}
		sort.Ints(a)
		if a[0] == a[n-1] {
			fmt.Fprintln(out, "Yes")
			continue
		}
		ans = false
		for _, v := range b {
			ans = check(v)
			if ans {
				break
			}
		}
		if ans {
			fmt.Fprintln(out, "Yes")
		} else {
			fmt.Fprintln(out, "No")
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t, n, i, temp, m, last int
	var flag, u, v bool
	add := [10]int{0, 1, 0, 9, 18, 5, 6, 25, 14, 23}
	fmt.Fscan(in, &t)
	for ; t != 0; t-- {
		fmt.Fscan(in, &n)
		flag, u, v = true, false, false
		for i = 1; i <= n; i++ {
			fmt.Fscan(in, &temp)
			if !flag {
				continue
			}
			m = temp % 10
			if m == 5 || m == 0 {
				u = true
			} else {
				v = true
			}
			if u && v {
				flag = false
				continue
			}
			temp += add[m]
			if i == 1 {
				last = temp
			} else {
				if m == 5 || m == 0 {
					if temp != last {
						flag = false
						continue
					}
				} else {
					if (temp-last)%20 != 0 {
						flag = false
						continue
					}
				}
				last = temp
			}
		}
		if flag {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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

func scan(args ...*int) {

	for _, arg := range args {
		scanner.Scan()
		*arg, _ = strconv.Atoi(scanner.Text())
	}
}

func print(args ...interface{}) {
	writter.WriteString(fmt.Sprintln(args...))
}

func main() {
	scanner.Split(bufio.ScanWords)
	defer writter.Flush()
	var t int

	scan(&t)

	var n int

	for i := 0; i < t; i++ {
		scan(&n)
		a := make([]int, n, n)

		var highest *int
		for j := 0; j < n; j++ {
			scan(&a[j])
			if j == 0 || a[j] > *highest {
				highest = &a[j]
			}
		}

		for j := 0; j < n; j++ {
			if a[j]%2 == 1 && a[j] != *highest {
				a[j] = a[j] + (a[j] % 10)
				if a[j] > *highest {
					highest = &a[j]
				}
			}
		}

		failed := false
		for k := 0; k <= 4; k++ {
			failed = false
			for j := 0; j < n; j++ {
				if !canMatch(a[j], *highest) {
					failed = true
					break
				}
			}

			if !failed {
				print("Yes")
				break
			}

			*highest = *highest + (*highest % 10)
		}

		if failed {
			print("No")
		}
	}
}

func canMatch(num, x int) bool {
	if (num%10 == 0 || x%10 == 0) && num != x {
		return false
	}

	diff := (x - num) % 20

	rissen := 0
	for i := 0; i <= 4; i++ {
		if rissen == diff {
			return true
		}

		rissen += num % 10
		num = num + (num % 10)
	}
	return false
}

package main

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

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

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

func gcd(a, b int64) int64 {
	if a < b {
		a, b = b, a
	}
	if a%b == 0 {
		return b
	} else {
		return gcd(b, a%b)
	}
}

func FindAll(str string, subs []string) (*[]int, *[]int, *[]int) {
	res := make([]int, 0)
	lens := make([]int, 0)
	histstrs := make([]int, 0)
	for hister, sub := range subs {
		for i := 0; i <= len(str)-len(sub); {
			tmp := strings.Index(str[i:], sub)
			//fmt.Println("!!!!!", tmp, str[i:], sub, i)
			if tmp == -1 {
				break
			} else {
				res = append(res, tmp+i)
				lens = append(lens, len(sub))
				histstrs = append(histstrs, hister)
				i += tmp + 1
			}
		}
	}
	return &res, &lens, &histstrs
}

func FilterAll(slc []int, used []bool, lens []int) *[]int {
	ret := make([]int, 0)
	for i := range slc {
		//fmt.Println("!!!!!!!!", slc, used, lens, i)
		curr := slc[i]
		res := 0
		for j := curr; j < curr+lens[i]; j++ {
			if !used[j] {
				res++
			}
		}
		ret = append(ret, res)
	}
	return &ret
}

func HasFalse(b []bool) bool {
	for _, el := range b {
		if !el {
			return true
		}
	}
	return false
}

func main() {
	scanner := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var niter int
	fmt.Fscan(scanner, &niter)
outer:
	for iiter := 0; iiter < niter; iiter++ {
		var n int
		fmt.Fscan(scanner, &n)
		type1 := 0
		type2 := 0
		slc := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(scanner, &slc[i])
			if slc[i]%10 == 5 || slc[i]%10 == 0 {
				type2++
			} else {
				type1++
			}
		}
		if type1 > 0 && type2 > 0 {
			fmt.Fprintln(writer, "No")
			continue outer
		}
		if type1 > 0 {
			tmp := slc[0]
			for tmp%10 != 2 {
				tmp += tmp % 10
			}
			mod := tmp % 20
			for i := 1; i < n; i++ {
				tmp := slc[i]
				for tmp%10 != 2 {
					tmp += tmp % 10
				}
				if tmp%20 != mod {
					fmt.Fprintln(writer, "No")
					continue outer
				}
			}
		} else {
			tmp := slc[0]
			for tmp%10 != 0 {
				tmp += tmp % 10
			}
			mod := tmp
			for i := 1; i < n; i++ {
				tmp := slc[i]
				for tmp%10 != 0 {
					tmp += tmp % 10
				}
				if tmp != mod {
					fmt.Fprintln(writer, "No")
					continue outer
				}
			}
		}
		fmt.Fprintln(writer, "Yes")
	}
}

// 00
package main

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

func get_group(k int) int {
	if k%10 == 5 {
		return k + 5
	}
	if k%10 == 0 {
		return k
	}
	if k == 1 || k%20 == 2 || k%20 == 4 || k%20 == 8 || k%20 == 16 {
		return 1
	}
	if k == 3 || k%20 == 6 || k%20 == 12 || k%20 == 14 || k%20 == 18 {
		return 3
	}
	return get_group(k + k%10)
}

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n int
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
			a[i] = get_group(a[i])
		}
		ok := true
		for i := 1; i < n; i++ {
			if a[i] != a[i-1] {
				ok = false
				break
			}
		}
		if ok {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (

	"bufio"
	"os"
	"fmt"
)

var (

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

func main() {

	defer out.Flush()

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

		var (
			n int
			b1 = false
			b2 = false
			a []int
		)
		fmt.Fscan(in, &n)
		for j := 0; j < n; j++ {

			var x int
			fmt.Fscan(in, &x)
			k := x % 10
			if k == 0 || k == 5 {

				if k == 5 {

					x += 5
				}
				b1 = true
			} else {

				for {

					k = x % 10
					if k == 2 {

						break
					}
					x += k
				}
				b2 = true
			}
			a = append(a, x)
		}

		if b1 && b2 {

			fmt.Fprintln(out, "No")
		} else {

			var ans = false
			if b1 {

				for j := 1; j < n; j++ {

					if a[j] != a[j - 1] {

						fmt.Fprintln(out, "No")
						ans = true
						break
					}
				}
			}
			if b2 {

				for j := 1; j < n; j++ {

					k := a[j] - a[j - 1]
					if k % 20 != 0 {

						fmt.Fprintln(out, "No")
						ans = true
						break
					}
				}
			}
			if !ans {

				fmt.Fprintln(out, "Yes")
			}
		}
	}
}

package main

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

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

func solve() string {
	var n int
	fmt.Fscan(in, &n)
	arr := make([]int, n)
	var fives int
	for i := range arr {
		fmt.Fscan(in, &arr[i])
		arr[i] += arr[i] % 10
		if arr[i]%10 == 5 || arr[i]%10 == 0 {
			fives++
		}
	}

	if fives > 0 && fives != n {
		return "NO"
	}

	sort.Ints(arr)
	min := arr[0]
	max := arr[n-1]
	if min == max {
		return "YES"
	}

	if fives == n {
		if max-min == 5 && min%10 == 5 {
			return "YES"
		} else {
			return "NO"
		}
	}

	//dedup
	d := make([]int, 0, n)
	for i := 0; i < n-1; i++ {
		if arr[i] != arr[i+1] {
			d = append(d, arr[i])
		}
	}
	d = append(d, arr[n-1])

	// AHAHHA THAT ACTUALLY WORKED LMAO
	for i := 0; i < n-1; i++ {

		diff := 10
		for diff < max-arr[i] {
			diff *= 10
		}
		arr[i] += diff

		for arr[i]-max < 10 {
			arr[i] += arr[i] % 10
		}
		if abs(max-arr[i]) == 10 {
			return "NO"
		}
	}

	return "YES"
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscanln(in, &t); t > 0; t-- {
		fmt.Fprintln(out, solve())
	}
}

// util functions
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

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

func makeMatrix(n, m int) [][]int {
	x := make([][]int, n)
	for i := range x {
		x[i] = make([]int, m)
	}
	return x
}

package main

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

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

func solve() string {
	var n int
	fmt.Fscan(in, &n)
	arr := make([]int, n)
	var fives int
	for i := range arr {
		fmt.Fscan(in, &arr[i])
		if arr[i]%10 == 5 || arr[i]%10 == 0 {
			fives++
		}
	}

	if fives > 0 && fives != n {
		return "NO"
	}

	sort.Ints(arr)
	min := arr[0]
	max := arr[n-1]
	if min == max {
		return "YES"
	}

	if fives == n {
		if max-min == 5 && min%10 == 5 {
			return "YES"
		} else {
			return "NO"
		}
	}

	for i := 0; i < n-1; i++ {
		for arr[i]-max < 10 {
			arr[i] += arr[i] % 10
		}
		if abs(max-arr[i]) == 10 {
			return "NO"
		}
	}

	return "YES"
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscanln(in, &t); t > 0; t-- {
		fmt.Fprintln(out, solve())
	}
}

// util functions
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

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

func makeMatrix(n, m int) [][]int {
	x := make([][]int, n)
	for i := range x {
		x[i] = make([]int, m)
	}
	return x
}

package main

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

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

func solve() string {
	var n int
	fmt.Fscan(in, &n)
	arr := make([]int, n)
	var fives int
	var equals = true
	for i := range arr {
		fmt.Fscan(in, &arr[i])
		if arr[i]%5 == 0 || arr[i]%10 == 0 {
			fives++
		}
		if i > 0 && arr[i-1] != arr[i] {
			equals = false
		}
	}

	if equals {
		return "YES"
	}

	if fives > 0 && fives != n {
		return "NO"
	}

	sort.Ints(arr)
	max := arr[n-1]

	if fives == n {
		if max-arr[0] == 5 {
			return "YES"
		} else {
			return "NO"
		}
	}

	for i := 0; i < n-1; i++ {
		for arr[i]-max < 10 {
			arr[i] += arr[i] % 10
		}
		if abs(max-arr[i]) == 10 {
			return "NO"
		}
	}

	return "YES"
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscanln(in, &t); t > 0; t-- {
		fmt.Fprintln(out, solve())
	}
}

// util functions
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

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

func makeMatrix(n, m int) [][]int {
	x := make([][]int, n)
	for i := range x {
		x[i] = make([]int, m)
	}
	return x
}

package main

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

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

func solve() string {
	var n int
	fmt.Fscan(in, &n)
	arr := make([]int, n)
	var fives int
	for i := range arr {
		fmt.Fscan(in, &arr[i])
		if arr[i]%5 == 0 || arr[i]%10 == 0 {
			fives++
		}
	}

	if fives > 0 && fives != n {
		return "NO"
	}

	sort.Ints(arr)
	max := arr[n-1]

	if fives == n {
		if max-arr[0] == 5 {
			return "YES"
		} else {
			return "NO"
		}
	}

	for i := 0; i < n-1; i++ {
		for arr[i]-max < 10 {
			arr[i] += arr[i] % 10
		}
		if abs(max-arr[i]) == 10 {
			return "NO"
		}
	}

	return "YES"
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscanln(in, &t); t > 0; t-- {
		fmt.Fprintln(out, solve())
	}
}

// util functions
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

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

func makeMatrix(n, m int) [][]int {
	x := make([][]int, n)
	for i := range x {
		x[i] = make([]int, m)
	}
	return x
}

package main

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

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

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

		aa := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
			aa[i] %= 100
			if aa[i]%10 == 5 {
				aa[i] += 5
			} else if aa[i]%10 != 0 {
				for aa[i]%10 != 2 {
					aa[i] += aa[i] % 10
				}
				aa[i] %= 20
			}
		}
		sort.Slice(aa, func(i, j int) bool { return aa[i] >= aa[j] })

		f := true
		for i := 1; i < n; i++ {
			if aa[i-1] != aa[i] {
				f = false
			}
		}
		if !f {
			fmt.Fprintln(out, "No")
		} else {
			fmt.Fprintln(out, "Yes")
		}
	}
}

package main

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

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

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

		aa := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
			aa[i] %= 100
			if aa[i]%10 == 5 {
				aa[i] += 5
			} else if aa[i]%10 != 0 {
				for aa[i]+(aa[i]%10) < 120 {
					aa[i] += aa[i] % 10
				}
			}
		}
		sort.Slice(aa, func(i, j int) bool { return aa[i] >= aa[j] })

		f := true
		for i := 1; i < n; i++ {
			if aa[i-1] != aa[i] {
				f = false
			}
		}
		if !f {
			fmt.Fprintln(out, "No")
		} else {
			fmt.Fprintln(out, "Yes")
		}
	}
}

package main

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

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

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

		aa := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
			aa[i] %= 100
			if aa[i]%10 == 5 {
				aa[i] += 5
			} else if aa[i]%10 != 0 {
				for aa[i]+(aa[i]%10) < 110 {
					aa[i] += aa[i] % 10
				}
			}
		}
		sort.Slice(aa, func(i, j int) bool { return aa[i] >= aa[j] })

		f := true
		for i := 1; i < n; i++ {
			if aa[i-1] != aa[i] {
				f = false
			}
		}
		if !f {
			fmt.Fprintln(out, "No")
		} else {
			fmt.Fprintln(out, "Yes")
		}
	}
}

package main

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

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

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

		aa := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
			aa[i] %= 100
			if aa[i]%10 == 5 {
				aa[i] *= 2
			} else if aa[i]%10 != 0 {
				for aa[i]+(aa[i]%10) < 110 {
					aa[i] += aa[i] % 10
				}
			}
		}
		sort.Slice(aa, func(i, j int) bool { return aa[i] >= aa[j] })

		f := true
		for i := 1; i < n; i++ {
			if aa[i-1] != aa[i] {
				f = false
			}
		}
		if !f {
			fmt.Fprintln(out, "No")
		} else {
			fmt.Fprintln(out, "Yes")
		}
	}
}

package main

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

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

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

		aa := make([]int64, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
			if aa[i]%10 == 5 {
				aa[i] *= 2
			} else if aa[i]%10 != 0 {
				if aa[i]%2 != 0 {
					aa[i] += aa[i] % 10
				}
				aa[i] %= 20
				for aa[i]+(aa[i]%10) < 100 {
					aa[i] += aa[i] % 10
				}
			}
		}
		sort.Slice(aa, func(i, j int) bool { return aa[i] >= aa[j] })

		f := true
		for i := 1; i < n; i++ {
			if aa[i-1] != aa[i] {
				f = false
			}
		}
		if !f {
			fmt.Fprintln(out, "No")
		} else {
			fmt.Fprintln(out, "Yes")
		}
	}
}

package main

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

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

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

		aa := make([]int64, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
			if aa[i]%10 == 5 {
				aa[i] *= 2
			} else if aa[i]%10 != 0 {
				if aa[i]%2 != 0 {
					aa[i] += aa[i] % 10
				}
				aa[i] %= 100
				for aa[i]+(aa[i]%10) < 100 {
					aa[i] += aa[i] % 10
				}
			}
		}
		sort.Slice(aa, func(i, j int) bool { return aa[i] >= aa[j] })

		f := true
		for i := 1; i < n; i++ {
			if aa[i-1] != aa[i] {
				f = false
			}
		}
		if !f {
			fmt.Fprintln(out, "No")
		} else {
			fmt.Fprintln(out, "Yes")
		}
	}
}

package main

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

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

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

		aa := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
			aa[i] %= 100
			if aa[i]%10 == 5 {
				aa[i] *= 2
			} else if aa[i]%10 != 0 {
				for aa[i]+(aa[i]%10) < 100 {
					aa[i] += aa[i] % 10
				}
			}
		}
		sort.Slice(aa, func(i, j int) bool { return aa[i] >= aa[j] })

		f := true
		for i := 1; i < n; i++ {
			if aa[i-1] != aa[i] {
				f = false
			}
		}
		if !f {
			fmt.Fprintln(out, "No")
		} else {
			fmt.Fprintln(out, "Yes")
		}
	}
}

package main

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

var (
	in   *bufio.Scanner
	out  *bufio.Writer
	once = false
)

func solve() {
	in.Scan()
	n, _ := strconv.Atoi(in.Text())
	a := make(map[int]int)
	for i := 0; i < n; i++ {
		in.Scan()
		ai, _ := strconv.Atoi(in.Text())
		if ai%10 == 5 {
			ai = ai + 5
			a[ai]++
		} else {
			if ai%2 != 0 {
				ai = ai + ai%10
			}
			ai = ai % 20
			switch ai {
			case 2, 4, 8, 16:
				a[-1]++
			default:
				a[-2]++
			}
		}
	}
	if len(a) > 1 {
		out.WriteString("No\n")
	} else {
		out.WriteString("Yes\n")
	}
}

func main() {
	in = bufio.NewScanner(os.Stdin)
	in.Split(bufio.ScanWords)
	out = bufio.NewWriter(os.Stdout)
	defer out.Flush()

	if once {
		solve()
		return
	}
	in.Scan()
	x, _ := strconv.Atoi(in.Text())
	for t := 0; t < x; t++ {
		solve()
	}
}

package main

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

var (
	in   *bufio.Scanner
	out  *bufio.Writer
	once = false
)

func solve() {
	in.Scan()
	n, _ := strconv.Atoi(in.Text())
	a := make(map[int]int)
	for i := 0; i < n; i++ {
		in.Scan()
		ai, _ := strconv.Atoi(in.Text())
		if ai%10 == 5 {
			ai = ai + 5
			a[ai]++
		} else {
			if ai%2 != 0 {
				ai = ai + ai%10
			}
			ai = ai % 20
			switch ai {
			case 2, 4, 8, 16:
				a[-1]++
			default:
				a[-2]++
			}
		}
	}
	if len(a) > 1 {
		out.WriteString("No")
	} else {
		out.WriteString("Yes")
	}
}

func main() {
	in = bufio.NewScanner(os.Stdin)
	in.Split(bufio.ScanWords)
	out = bufio.NewWriter(os.Stdout)
	defer out.Flush()

	if once {
		solve()
		return
	}
	in.Scan()
	x, _ := strconv.Atoi(in.Text())
	for t := 0; t < x; t++ {
		solve()
	}
}

package main

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

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

func ReadInt() int{
	var i int
	fmt.Fscan(in, &i)
	return i
}

// 1 -> 2 -> 4 -> 8 -> 6 -> 2 -> ....
// 0 -> 0
// 3 -> 6 -> 2
// 5 -> 0
// 7 -> 4
// 9 -> 8

func main(){
	defer out.Flush()

	t := ReadInt()

	for ; t > 0; t--{
		n := ReadInt()
		a := make([]int, n)
		hasFiveDivisor := false
		for i:=0;i<n;i++{
			a[i]=ReadInt()
			if a[i]%5==0{
				hasFiveDivisor = true
			}
		}
		can:=true
		if hasFiveDivisor {
			for i:=0;i<n;i++{
				a[i] = a[i]+a[i]%10
				if a[i] != a[0]{
					can = false
					break
				}
			}
		} else{
			for i :=0; i < n; i++ {
				for a[i]%10!=2{
					a[i] += a[i]%10
				}
				fmt.Println(a[0], " ", a[i])
				if a[i]%20 !=a[0]%20{
					can = false
					break
				}
			}
		}
		if can{
			fmt.Fprintln(out, "Yes")
		} else{
			fmt.Fprintln(out, "No")
		}
	}
}

func Gcd(u, v int) int {
	if u == 0 {
		return v
	}

	return Gcd(v%u, u)
}

package main

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

func readLine() string {
	s, err := f.ReadString('\n')
	if err != nil {
		panic(err)
	}
	s = strings.ReplaceAll(s, "\n", "")
	s = strings.ReplaceAll(s, "\r", "")
	return s
}

func readInts(n int) []int {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	arr := make([]int, n)
	for k, a := range as {
		x, _ := strconv.ParseInt(a, 10, 64)
		arr[k] = int(x)
	}
	return arr
}

var f = bufio.NewReader(os.Stdin)

func main() {
	var t, n int

	l1 := readInts(1)
	t = l1[0]

	for i := 0; i < t; i++ {
		n = readInts(1)[0]
		arr := readInts(n)
		tt := -1
		s1, s2 := false, false
		s3, s4 := false, false
		no := false
		for _, a := range arr {
			if a%10 == 0 || a%10 == 5 {
				if tt == -1 {
					tt = a + a%10
				} else {
					if tt != a+a%10 {
						no = true
					}
				}
				s1 = true
			} else {
				s2 = true
				if a%10 == 3 || a%10 == 6 {
					if (a/10)%2 == 0 {
						s3 = true
					} else {
						s4 = true
					}
				} else {
					if (a/10)%2 == 1 {
						s3 = true
					} else {
						s4 = true
					}
				}
			}
		}
		if s1 && s2 {
			fmt.Println("NO")
		} else if s1 {
			if no {
				fmt.Println("NO")
			} else {
				fmt.Println("YES")
			}
		} else {
			if s3 && s4 {
				fmt.Println("NO")
			} else {
				fmt.Println("YES")
			}
		}
	}
}


In this task, Nastya asked us to write a formal statement.An array $$$a$$$ of length $$$n$$$ and an array $$$k$$$ of length $$$n-1$$$ are given. Two types of queries should be processed:   increase $$$a_i$$$ by $$$x$$$. Then if $$$a_{i+1} < a_i + k_i$$$, $$$a_{i+1}$$$ becomes exactly $$$a_i + k_i$$$; again, if $$$a_{i+2} < a_{i+1} + k_{i+1}$$$, $$$a_{i+2}$$$ becomes exactly $$$a_{i+1} + k_{i+1}$$$, and so far for $$$a_{i+3}$$$, ..., $$$a_n$$$;  print the sum of the contiguous subarray from the $$$l$$$-th element to the $$$r$$$-th element of the array $$$a$$$. It's guaranteed that initially $$$a_i + k_i \leq a_{i+1}$$$ for all $$$1 \leq i \leq n-1$$$.

The first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the number of elements in the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$-10^{9} \leq a_i \leq 10^{9}$$$) — the elements of the array $$$a$$$. The third line contains $$$n-1$$$ integers $$$k_1, k_2, \ldots, k_{n-1}$$$ ($$$-10^{6} \leq k_i \leq 10^{6}$$$) — the elements of the array $$$k$$$. The fourth line contains a single integer $$$q$$$ ($$$1 \leq q \leq 10^{5}$$$) — the number of queries. Each of the following $$$q$$$ lines contains a query of one of two types:    if the query has the first type, the corresponding line contains the character '+' (without quotes), and then there are two integers $$$i$$$ and $$$x$$$ ($$$1 \leq i \leq n$$$, $$$0 \leq x \leq 10^{6}$$$), it means that integer $$$x$$$ is added to the $$$i$$$-th element of the array $$$a$$$ as described in the statement.  if the query has the second type, the corresponding line contains the character 's' (without quotes) and then there are two integers $$$l$$$ and $$$r$$$ ($$$1 \leq l \leq r \leq n$$$).

For each query of the second type print a single integer in a new line — the sum of the corresponding subarray.

NoteIn the first example:   after the first change $$$a = [3, 4, 3]$$$;  after the second change $$$a = [3, 4, 4]$$$. In the second example:   after the first change $$$a = [6, 9, 10]$$$;  after the second change $$$a = [6, 13, 14]$$$.

package main

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

type input struct {
  scanner *bufio.Scanner
}

func NewInput() input {
  in := input{scanner: bufio.NewScanner(os.Stdin)}
  in.scanner.Split(bufio.ScanWords)
  return in
}

func (in* input) Token() string {
  in.scanner.Scan()
  return in.scanner.Text()
}

func (in* input) IntToken() int {
  result, _ := strconv.Atoi(in.Token())
  return result
}

type node struct  {
  sum, mx, psh int64
}

func (n *node) agg(lft, rht node) {
  n.sum = lft.sum + rht.sum
  n.mx = rht.mx
}

func Sum(arr []node, x, a, b, A, B int) int64 {
  if a <= A && B <= b {
    return arr[x].sum
  } else if b <= A || B <= a {
    return 0
  }
  M := (A + B) / 2
  if arr[x].psh != 0 {
    Increase(arr, 2 * x + 0, A, A, M, arr[x].psh)
    Increase(arr, 2 * x + 1, A, M, B, arr[x].psh)
    arr[x].psh = 0
  }
  return Sum(arr, 2 * x + 0, a, b, A, M) +
         Sum(arr, 2 * x + 1, a, b, M, B)
}

func Increase(arr []node, x, a, A, B int, val int64) {
  if B <= a {
    return
  } else if a <= A && arr[x].mx <= val {
    arr[x].mx = val
    arr[x].sum = val * int64(B - A)
    arr[x].psh = val
    return
  } else if (A + 1 == B) {
    return
  }
  M := (A + B) / 2
  if arr[x].psh != 0 {
    Increase(arr, 2 * x + 0, A, A, M, arr[x].psh)
    Increase(arr, 2 * x + 1, A, M, B, arr[x].psh)
    arr[x].psh = 0
  }
  Increase(arr, 2 * x + 0, a, A, M, val)
  if arr[2 * x + 0].mx <= val {
    Increase(arr, 2 * x + 1, a, M, B, val)
  }
  arr[x].agg(arr[2 * x + 0], arr[2 * x + 1])
}

const MAXN int = 1 << 18

func main() {
  in := NewInput()
  N := in.IntToken()

  A := make([]int, N)
  for i := 0; i < N; i++ {
    A[i] = in.IntToken()
  }

  K := make([]int, N - 1)
  for i := 0; i < N - 1; i++ {
    K[i] = in.IntToken()
  }

  arr := make([]node, MAXN * 2)

  ksum := int64(0)
  KSS := make([]int64, N + 1)
  for i := 0; i < N; i++ {
    if i == 0 {
      ksum += int64(A[0])
    } else {
      ksum += int64(K[i - 1])
    }
    val := int64(A[i]) - ksum
    KSS[i + 1] = KSS[i] + int64(ksum)
    arr[MAXN + i] = node{sum: val, mx: val}
  }
  for i := N; i < MAXN; i++ {
    arr[MAXN + i] = arr[MAXN + N - 1]
  }
  for i := MAXN - 1; i > 0; i-- {
    arr[i].agg(arr[2 * i + 0], arr[2 * i + 1])
  }

  Q := in.IntToken()
  for i := 0; i < Q; i++ {
    op := in.Token()
    a := in.IntToken() - 1
    b := in.IntToken()
    if op == "s" {
      fmt.Println(Sum(arr, 1, a, b, 0, MAXN) + KSS[b] - KSS[a])
    } else {
      cur := Sum(arr, 1, a, a + 1, 0, MAXN)
      Increase(arr, 1, a, 0, MAXN, cur + int64(b))
    }
  }
}