package main

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

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

func Print(args ...interface{})                 { out.WriteString(fmt.Sprint(args...)) }
func Printf(format string, args ...interface{}) { out.WriteString(fmt.Sprintf(format, args...)) }
func Println(args ...interface{})               { out.WriteString(fmt.Sprintln(args...)) }

func Scan(args ...interface{})   { fmt.Fscan(in, args...) }
func Scanln(args ...interface{}) { fmt.Fscanln(in, args...) }

func main() {
	defer out.Flush()

	var n, m int
	Scan(&n, &m)
	arr := make([]int, n)
	brr := make([]int, m)
	for i := 0; i < n; i++ {
		Scan(&arr[i])
	}
	for i := 0; i < m; i++ {
		Scan(&brr[i])
	}
	sort.Ints(arr)
	for i, s := range brr {
		left := 0
		right := n - 1
		for {
			if left >= n {
				break
			}
			if arr[left] > s {
				break
			}
			mid := (left + right) / 2
			if arr[mid] <= s {
				left = mid + 1
				continue
			}
			right = mid
		}

		Print(left)
		if i != m-1 {
			Print(" ")
		}
	}
	Print("\n")
}

package main

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

func main() {
	var n, m int
	fmt.Scanf("%d %d\n", &n, &m)
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), 12*2*10e5)
	a := scanArray(sc, n)
	b := scanArray(sc, m)
	sort.Sort(sort.IntSlice(a))
	for j, v := range b {
		i := sort.Search(len(a), func(i int) bool {
			if a[i] > v {
				return true
			}
			return false
		})
		b[j] = i
	}
	for _, i := range b {
		fmt.Print(i, " ")
	}
}

func scanArray(sc *bufio.Scanner, n int) []int {
	a := make([]int, n)
	if sc.Scan() {
		tmp := sc.Text()
		for i, s := range strings.Fields(tmp) {
			in, err := strconv.Atoi(s)
			if err != nil {
				fmt.Println(err)
			}
			a[i] = in
		}
	}
	if err := sc.Err(); err != nil {
		fmt.Println(err)
	}
	return a
}

package main

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

//N _
const (
	N = 2*1e5 + 5
)

func upperBound(array []int, target int) int {
	low, high, mid := 0, len(array)-1, 0

	for low <= high {
		mid = (low + high) / 2
		if array[mid] > target {
			high = mid - 1
		} else {
			low = mid + 1
		}
	}
	return low
}

func inputter(inputReader *bufio.Reader,strs chan *string){
	for {
		input , _ := inputReader.ReadString('\n')
		input = strings.TrimSpace(input)
		if len(input) > 0 {
			inputs := strings.Split(input, " ")
			for i := range inputs{
				strs <- &inputs[i]
			}
		}
	}
}

func main(){
	rs := bufio.NewReader(os.Stdin)
	ws := bufio.NewWriter(os.Stdout)

	strs := make(chan *string, 100)

	go inputter(rs, strs)

	n , _ := strconv.ParseInt(*<-strs, 10, 32)
	m , _ := strconv.ParseInt(*<-strs, 10, 32)

	a := make([]int, 0, N)

	for i := 0; i < int(n); i++ {
		x, _ := strconv.ParseInt(*<-strs, 10, 32)
		a = append(a, int(x))
	}

	sort.Ints(a)

	for i := 0; i < int(m); i++ {
		x, _ := strconv.ParseInt(*<-strs, 10, 32)
		ws.WriteString(fmt.Sprint(upperBound(a, int(x))) + " ")
	}

	ws.Flush()
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, int(math.Pow(10,8))), int(math.Pow(10, 8)))

	scanner.Scan()
	nmStr := scanner.Text()
	nmArr := strings.Split(nmStr, " ")
	n, _ := strconv.Atoi(nmArr[0])
	m, _ := strconv.Atoi(nmArr[1])

	scanner.Scan()
	aStr := scanner.Text()
	aStrArr := strings.Split(aStr, " ")
	aArr := make([]int, len(aStrArr))
	for idx := 0; idx < n; idx++ {
		aArr[idx], _ = strconv.Atoi(aStrArr[idx])
	}
	sort.Ints(aArr)

	scanner.Scan()
	bStr := scanner.Text()
	bStrArr := strings.Split(bStr, " ")
	bArrIdx := make([][]int, len(bStrArr))
	for idx := 0; idx < m; idx++ {
		b, _ := strconv.Atoi(bStrArr[idx])
		bArrIdx[idx] = []int{b, idx}
	}
	sort.Slice(bArrIdx, func(i, j int) bool {
		return bArrIdx[i][0] < bArrIdx[j][0]
	})

	resp := make([]int, m)

	if len(bArrIdx) == 0 {
		fmt.Println()
	}
	currIdx := sort.SearchInts(aArr, bArrIdx[0][0])
	for currIdx < n && bArrIdx[0][0] == aArr[currIdx] {
		currIdx++
	}
	resp[bArrIdx[0][1]] = currIdx

	for idx := 1; idx < len(bArrIdx); idx++ {
		for currIdx < n && bArrIdx[idx][0] >= aArr[currIdx] {
			currIdx++
		}
		resp[bArrIdx[idx][1]] = currIdx
	}

	for idx := range resp {
		fmt.Printf("%v ", resp[idx])
	}
	fmt.Println()
}

package main

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

func main() {
	var n, m int
	fmt.Scanf("%d %d\n", &n, &m)
	sc := bufio.NewScanner(os.Stdin)
	a := scanArray(sc, n)
	b := scanArray(sc, m)
	sort.Sort(sort.IntSlice(a))
	for j, v := range b {
		i := sort.Search(len(a), func(i int) bool {
			if a[i] > v {
				return true
			}
			return false
		})
		b[j] = i
	}
	for _, i := range b {
		fmt.Print(i, " ")
	}
}

func scanArray(sc *bufio.Scanner, n int) []int {
	a := make([]int, n)
	if sc.Scan() {
		tmp := sc.Text()
		for i, s := range strings.Fields(tmp) {
			in, err := strconv.Atoi(s)
			if err != nil {
				fmt.Println(err)
			}
			a[i] = in
		}
	}
	if err := sc.Err(); err != nil {
		fmt.Println(err)
	}
	return a
}

package main

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

func main() {
	var n, m int
	fmt.Scanf("%d %d\n", &n, &m)
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 4096), 100*2*10^5)
	a := scanArray(sc, n)
	b := scanArray(sc, m)
	sort.Sort(sort.IntSlice(a))
	for j, v := range b {
		i := sort.Search(len(a), func(i int) bool {
			if a[i] > v {
				return true
			}
			return false
		})
		b[j] = i
	}
	for _, i := range b {
		fmt.Print(i, " ")
	}
}

func scanArray(sc *bufio.Scanner, n int) []int {
	a := make([]int, n)
	if sc.Scan() {
		tmp := sc.Text()
		for i, s := range strings.Fields(tmp) {
			in, err := strconv.Atoi(s)
			if err != nil {
				fmt.Println(err)
			}
			a[i] = in
		}
	}
	if err := sc.Err(); err != nil {
		fmt.Println(err)
	}
	return a
}

package main

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

func main() {
	var n, m int
	fmt.Scanf("%d %d\n", &n, &m)
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 4096), 2*10^5*4)
	a := scanArray(sc, n)
	b := scanArray(sc, m)
	sort.Sort(sort.IntSlice(a))
	for j, v := range b {
		i := sort.Search(len(a), func(i int) bool {
			if a[i] > v {
				return true
			}
			return false
		})
		b[j] = i
	}
	for _, i := range b {
		fmt.Print(i, " ")
	}
}

func scanArray(sc *bufio.Scanner, n int) []int {
	a := make([]int, n)
	if sc.Scan() {
		tmp := sc.Text()
		for i, s := range strings.Fields(tmp) {
			in, err := strconv.Atoi(s)
			if err != nil {
				fmt.Println(err)
			}
			a[i] = in
		}
	}
	if err := sc.Err(); err != nil {
		fmt.Println(err)
	}
	return a
}

package main

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

func main() {
	var n, m int
	fmt.Scanf("%d %d\n", &n, &m)
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 4096), 2*10^5*12)
	a := scanArray(sc, n)
	b := scanArray(sc, m)
	sort.Sort(sort.IntSlice(a))
	for j, v := range b {
		i := sort.Search(len(a), func(i int) bool {
			if a[i] > v {
				return true
			}
			return false
		})
		b[j] = i
	}
	for _, i := range b {
		fmt.Print(i, " ")
	}
}

func scanArray(sc *bufio.Scanner, n int) []int {
	a := make([]int, n)
	if sc.Scan() {
		tmp := sc.Text()
		for i, s := range strings.Fields(tmp) {
			in, err := strconv.Atoi(s)
			if err != nil {
				fmt.Println(err)
			}
			a[i] = in
		}
	}
	if err := sc.Err(); err != nil {
		fmt.Println(err)
	}
	return a
}

package main

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

func main() {
	var n, m int
	fmt.Scanf("%d %d\n", &n, &m)
	sc := bufio.NewScanner(os.Stdin)
	c := 2*10 ^ 5*12
	sc.Buffer(make([]byte, c), c)
	a := scanArray(sc, n)
	b := scanArray(sc, m)
	sort.Sort(sort.IntSlice(a))
	for j, v := range b {
		i := sort.Search(len(a), func(i int) bool {
			if a[i] > v {
				return true
			}
			return false
		})
		b[j] = i
	}
	for _, i := range b {
		fmt.Print(i, " ")
	}
}

func scanArray(sc *bufio.Scanner, n int) []int {
	a := make([]int, n)
	if sc.Scan() {
		tmp := sc.Text()
		for i, s := range strings.Fields(tmp) {
			in, err := strconv.Atoi(s)
			if err != nil {
				fmt.Println(err)
			}
			a[i] = in
		}
	}
	if err := sc.Err(); err != nil {
		fmt.Println(err)
	}
	return a
}

package main

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

func main() {
	var n, m int
	fmt.Scanf("%d %d\n", &n, &m)
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 4096), 2*10^5*11)
	a := scanArray(sc, n)
	b := scanArray(sc, m)
	sort.Sort(sort.IntSlice(a))
	for j, v := range b {
		i := sort.Search(len(a), func(i int) bool {
			if a[i] > v {
				return true
			}
			return false
		})
		b[j] = i
	}
	for _, i := range b {
		fmt.Print(i, " ")
	}
}

func scanArray(sc *bufio.Scanner, n int) []int {
	a := make([]int, n)
	if sc.Scan() {
		tmp := sc.Text()
		for i, s := range strings.Fields(tmp) {
			in, err := strconv.Atoi(s)
			if err != nil {
				fmt.Println(err)
			}
			a[i] = in
		}
	}
	if err := sc.Err(); err != nil {
		fmt.Println(err)
	}
	return a
}

package main

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

func main() {
	var n, m int
	fmt.Scanf("%d %d\n", &n, &m)
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 4096), 12*2*10^5)
	a := scanArray(sc, n)
	b := scanArray(sc, m)
	sort.Sort(sort.IntSlice(a))
	for j, v := range b {
		i := sort.Search(len(a), func(i int) bool {
			if a[i] > v {
				return true
			}
			return false
		})
		b[j] = i
	}
	for _, i := range b {
		fmt.Print(i, " ")
	}
}

func scanArray(sc *bufio.Scanner, n int) []int {
	a := make([]int, n)
	if sc.Scan() {
		tmp := sc.Text()
		for i, s := range strings.Fields(tmp) {
			in, err := strconv.Atoi(s)
			if err != nil {
				fmt.Println(err)
			}
			a[i] = in
		}
	}
	if err := sc.Err(); err != nil {
		fmt.Println(err)
	}
	return a
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer([]byte{}, int(math.Pow(10, 6)))

	scanner.Scan()
	nmStr := scanner.Text()
	nmArr := strings.Split(nmStr, " ")
	n, _ := strconv.Atoi(nmArr[0])
	m, _ := strconv.Atoi(nmArr[1])

	scanner.Scan()
	aStr := scanner.Text()
	aStrArr := strings.Split(aStr, " ")
	aArr := make([]int, len(aStrArr))
	for idx := 0; idx < n; idx++ {
		aArr[idx], _ = strconv.Atoi(aStrArr[idx])
	}
	sort.Ints(aArr)

	scanner.Scan()
	bStr := scanner.Text()
	bStrArr := strings.Split(bStr, " ")
	bArrIdx := make([][]int, len(bStrArr))
	for idx := 0; idx < m; idx++ {
		b, _ := strconv.Atoi(bStrArr[idx])
		bArrIdx[idx] = []int{b, idx}
	}
	sort.Slice(bArrIdx, func(i, j int) bool {
		return bArrIdx[i][0] < bArrIdx[j][0]
	})

	resp := make([]int, m)

	if len(bArrIdx) == 0 {
		fmt.Println()
	}
	currIdx := sort.SearchInts(aArr, bArrIdx[0][0])
	for currIdx < n && bArrIdx[0][0] == aArr[currIdx] {
		currIdx++
	}
	resp[bArrIdx[0][1]] = currIdx

	for idx := 1; idx < len(bArrIdx); idx++ {
		for currIdx < n && bArrIdx[idx][0] >= aArr[currIdx] {
			currIdx++
		}
		resp[bArrIdx[idx][1]] = currIdx
	}

	var respBuilder strings.Builder
	for idx := range resp {
		respBuilder.WriteByte(byte(resp[idx]+48))
		respBuilder.WriteString(" ")
	}
	respStr := respBuilder.String()
	fmt.Println(respStr[:len(respStr)-1])
}

package main

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

//N _
const (
	N = 2*1e5 + 5
)

func readOneLineInts(inputreader *bufio.Reader, n int) (res chan int) {
	res = make(chan int, N)
	go func() {
		input, _ :=	inputreader.ReadString('\n')
		ints := strings.Split(strings.TrimSpace(input), " ")
		for i := range ints{
			x, _ := strconv.ParseInt(ints[i],10,32)
			res <- int(x)
		}
		close(res)
	}()

	return
}

func upperBound(array []int, target int) int {
	low, high, mid := 0, len(array)-1, 0

	for low <= high {
		mid = (low + high) / 2
		if array[mid] > target {
			high = mid - 1
		} else {
			low = mid + 1
		}
	}
	return low
}

func main(){
	rs := bufio.NewReader(os.Stdin)
	ws := bufio.NewWriter(os.Stdout)

	ch := readOneLineInts(rs, 2);

	n := <- ch
	m := <- ch

	ch1 := readOneLineInts(rs, int(n));
	ch2 := readOneLineInts(rs, int(m));

	a := make([]int, 0, N)

	for x := range ch1{
		a = append(a, x)
	}

	sort.Ints(a)

	for x := range ch2{
		ws.WriteString(fmt.Sprint(upperBound(a, x)) + " ")
	}

	ws.Flush()
}

package main

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

//N _
const (
	N = 2*1e5 + 5
)

func upperBound(array []int, target int) int {
	low, high, mid := 0, len(array)-1, 0

	for low <= high {
		mid = (low + high) / 2
		if array[mid] > target {
			high = mid - 1
		} else {
			low = mid + 1
		}
	}
	return low
}

func inputter(inputReader *bufio.Reader,strs chan *string){
	for {
		input , _ := inputReader.ReadString('\n')
		input = strings.TrimSpace(input)
		if len(input) > 0 {
			inputs := strings.Split(input, " ")
			for i := range inputs{
				strs <- &inputs[i]
			}
		}
	}
}

func main(){
	rs := bufio.NewReader(os.Stdin)
	ws := bufio.NewWriter(os.Stdout)

	strs := make(chan *string, 100)

	go inputter(rs, strs)

	n , _ := strconv.ParseInt(*<-strs, 10, 32)
	m , _ := strconv.ParseInt(*<-strs, 10, 32)

	a := make([]int, 0, N)

	for i := 0; i < int(n); i++ {
		x, _ := strconv.ParseInt(*<-strs, 10, 32)
		a = append(a, int(x))
	}

	sort.Ints(a)

	fmt.Println("sorted:", a)

	for i := 0; i < int(m); i++ {
		x, _ := strconv.ParseInt(*<-strs, 10, 32)
		ws.WriteString(fmt.Sprint(upperBound(a, int(x))) + " ")
	}

	ws.Flush()
}


package main

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

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < cases; i++ {
		line := readLine(reader)
		n, _ := strconv.Atoi(string(line))
		str := readLine(reader)
		// fmt.Println(cases, n, str)
		k, s := 1, string(str)
		for j := 2; j <= n; j++ {
			sss := make([]byte, n)
			copy(sss, str)
			temp := reverseS(sss, j)
			if temp < s {
				k = j
				s = temp
			}
		}
		fmt.Println(s)
		fmt.Println(k)
	}
}

func reverseS(str []byte, k int) string {
	// if k == len(str) {
	// 	s := make([]byte, 0)
	// 	for i:=len(str)-1;i>=0;i-- {
	// 		s = append(s, str[i])
	// 	}
	// 	return string(s)
	// }
	first := str[k-1:]
	second := make([]byte, 0)
	if (len(str)-k+1) % 2 == 1 { // 奇数反转
		for i:=k-2;i>=0;i--{
			second = append(second, str[i])
		}
		return string(first) + string(second)
	}
	return string(first) + string(str[:k-1])
}

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"
)

// github.com/EndlessCheng/codeforces-go
func CF1316B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	reverse := func(ss string) string {
		n := len(ss)
		s := make([]byte, n)
		for i := range s {
			s[i] = ss[n-1-i]
		}
		return string(s)
	}

	var t, n int
	var s, ss string
	Fscan(in, &t)
	for ; t > 0; t-- {
		Fscan(in, &n, &s)
		minS := s
		k := 1
		for i := 1; i < n; i++ {
			if (n-i)%2 == 1 {
				ss = s[i:] + reverse(s[:i])
			} else {
				ss = s[i:] + s[:i]
			}
			if ss < minS {
				minS = ss
				k = i + 1
			}
		}
		Fprintln(out, minS)
		Fprintln(out, k)
	}
}

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

package main

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

func main() {

	for t := ScanInt(); t > 0; t-- {
		n := ScanInt()
		s := ScanWord()

		c := []class{}
		for k := 1; k <= n; k++ {
			c = append(c, class{Str: krev(s, k), K: k})
		}
		sort.Slice(c, func(i, j int) bool {
			if c[i].Str < c[j].Str {
				return true
			} else if c[i].Str > c[j].Str {
				return false
			} else {
				return c[i].K < c[j].K
			}
		})
		P(c[0].Str)
		P(c[0].K)
	}

	close(O)
	oWg.Wait()
}

type class struct {
	Str string
	K   int
}

func krev(s string, k int) string {
	right := s[k-1:]
	left := s[:k-1]

	r := right
	if len(s)%2 == k%2 {
		r = r + rev(left)
	} else {
		r = r + left
	}
	return r
}
func rev(str string) string {
	s := []byte(str)
	n := len(s)
	for i := 0; i < n/2; i++ {
		s[i], s[n-i-1] = s[n-i-1], s[i]
	}
	return string(s)
}

/*********************** 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 ...byte) (byte, byte) {
	minVal, maxVal := args[0], args[0]
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...byte) byte { mn, _ := MnMx(args...); return mn }
func Mx(args ...byte) byte { _, 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"
  "os"
)

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

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

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

func solve(s string) {
  var min byte = 'z'
  start := []int{}
  resS, resK := s, 1
  for i := range s {
    if s[i] < min {
      min = s[i]
      start = []int{i}
    } else if s[i] == min {
      start = append(start, i)
    }
  }
  for _, i := range start {
    res := flip(s, i)
    if res < resS {
      resS, resK = res, i+1
    }
  }
  printf("%s\n%d\n", resS, resK)
}

func flip(s string, i int) string {
  res := s[i:] + s[:i]

  if (len(s)-i)%2 == 1 {
    l, r := len(s)-i, len(s)-1
    b := []byte(res)
    for l < r {
      b[l], b[r] = b[r], b[l]
      l++
      r--
    }
    return string(b)
  } else {
    return res
  }
}

package main

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

func main() {

	for t := scanInt(); t > 0; t-- {
		lengthOfString := scanInt()
		actualString := scanString()
		answerInt := 1
		answerString := actualString
		for i := 2; i <= lengthOfString; i++ {
			subString := actualString[0 : i-1]
			if (lengthOfString-i)%2 == 0 {
				subString = reverseString(subString)
			}

			if actualString[i-1 : lengthOfString] +  subString < answerString {
				answerString = actualString[i-1 : lengthOfString] +  subString
				answerInt = i
			}

		}
		fmt.Println(answerString)
		fmt.Println(answerInt)
	}

	close(channelType)
	oWg.Wait()
}

func reverseString(str string) string {
	s := []byte(str)
	n := len(s)
	for i := 0; i < n/2; i++ {
		s[i], s[n-i-1] = s[n-i-1], s[i]
	}
	return string(s)
}

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

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

func init() {
	printFmt = fmt.Println

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

	channelType = 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 channelType {
			writer.WriteString(line + "\n")
		}
	}()
}

func scanString() string {in.Scan(); return in.Text() }
func scanInt() int {i, _ := strconv.Atoi(scanString()); return i}
func scanInt64() int64 {i, _ := strconv.ParseInt(scanString(), 10, 64); return i}
func scanStringSlice(n int) []string {s := make([]string, n); for i := 0; i < n; i++ {s[i] = scanString()}; 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 stringEquivalent(v interface{}) string {return fmt.Sprintf("%v", v)}
func spaceSeperatedStringFromArray(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 spaceSeperatedStringFromArray64(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 minMaxFromArray(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 minElementFromArray(args ...int64) int64 { mn, _ := minMaxFromArray(args...); return mn }
func maxElementFromArray(args ...int64) int64 { _, mx := minMaxFromArray(args...); return mx }
func lcmCalculation(a, b int64) int64 {return a / gcdCalculation(a, b) * b}
func gcdCalculation(a, b int64) int64 {if (a == 0) {return b}; return gcdCalculation(b%a, a)}
func sortInt64Slice(a []int64) {sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })}
func absoluteValue(x int64) int64 {if x < 0 {return -x}; return x}

package main

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

func main() {

	for t := scanInt(); t > 0; t-- {
		lengthOfString := scanInt()
		actualString := scanString()
		answerInt := 1
		answerString := actualString
		for i := 2; i <= lengthOfString; i++ {
			firstSubString := actualString[i-1 : lengthOfString]
			secondSubString := actualString[0 : i-1]

			if (lengthOfString-i)%2 == 0 {
				secondSubString = reverseString(secondSubString)
			}
			//
			firstSubString += secondSubString

			if firstSubString < answerString {
				answerString = firstSubString
				answerInt = i
			}

		}
		fmt.Println(answerString)
		fmt.Println(answerInt)
	}

	close(channelType)
	oWg.Wait()
}

func reverseString(str string) string {
	s := []byte(str)
	n := len(s)
	for i := 0; i < n/2; i++ {
		s[i], s[n-i-1] = s[n-i-1], s[i]
	}
	return string(s)
}

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

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

func init() {
	printFmt = fmt.Println

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

	channelType = 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 channelType {
			writer.WriteString(line + "\n")
		}
	}()
}

func scanString() string {in.Scan(); return in.Text() }
func scanInt() int {i, _ := strconv.Atoi(scanString()); return i}
func scanInt64() int64 {i, _ := strconv.ParseInt(scanString(), 10, 64); return i}
func scanStringSlice(n int) []string {s := make([]string, n); for i := 0; i < n; i++ {s[i] = scanString()}; 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 stringEquivalent(v interface{}) string {return fmt.Sprintf("%v", v)}
func spaceSeperatedStringFromArray(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 spaceSeperatedStringFromArray64(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 minMaxFromArray(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 minElementFromArray(args ...int64) int64 { mn, _ := minMaxFromArray(args...); return mn }
func maxElementFromArray(args ...int64) int64 { _, mx := minMaxFromArray(args...); return mx }
func lcmCalculation(a, b int64) int64 {return a / gcdCalculation(a, b) * b}
func gcdCalculation(a, b int64) int64 {if (a == 0) {return b}; return gcdCalculation(b%a, a)}
func sortInt64Slice(a []int64) {sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })}
func absoluteValue(x int64) int64 {if x < 0 {return -x}; return x}

package main

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

func main() {

	for t := scanInt(); t > 0; t-- {
		lengthOfString := scanInt()
		actualString := scanString()
		answerInt := 1
		answerString := actualString
		for i := 2; i <= lengthOfString; i++ {
			firstSubString := actualString[i-1 : lengthOfString]
			secondSubString := actualString[0 : i-1]

			if (lengthOfString-i)%2 == 0 {
				secondSubString = reverseString(secondSubString)
			}
			//
			firstSubString += secondSubString

			if firstSubString < answerString {
				answerString = firstSubString
				answerInt = i
			}

		}
		fmt.Println(answerString)
		fmt.Println(answerInt)
	}

	close(channelType)
	oWg.Wait()
}

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

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

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

func init() {
	printFmt = fmt.Println

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

	channelType = 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 channelType {
			writer.WriteString(line + "\n")
		}
	}()
}

func scanString() string {in.Scan(); return in.Text() }
func scanInt() int {i, _ := strconv.Atoi(scanString()); return i}
func scanInt64() int64 {i, _ := strconv.ParseInt(scanString(), 10, 64); return i}
func scanStringSlice(n int) []string {s := make([]string, n); for i := 0; i < n; i++ {s[i] = scanString()}; 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 stringEquivalent(v interface{}) string {return fmt.Sprintf("%v", v)}
func spaceSeperatedStringFromArray(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 spaceSeperatedStringFromArray64(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 minMaxFromArray(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 minElementFromArray(args ...int64) int64 { mn, _ := minMaxFromArray(args...); return mn }
func maxElementFromArray(args ...int64) int64 { _, mx := minMaxFromArray(args...); return mx }
func lcmCalculation(a, b int64) int64 {return a / gcdCalculation(a, b) * b}
func gcdCalculation(a, b int64) int64 {if (a == 0) {return b}; return gcdCalculation(b%a, a)}
func sortInt64Slice(a []int64) {sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })}
func absoluteValue(x int64) int64 {if x < 0 {return -x}; return x}

package main

import (
	"fmt"
)
func reversestring(s string) string{
	chars := []rune(s)
	for i, j :=0, len(s)-1; i < j; i, j = i + 1, j - 1{
		chars[i], chars[j] = chars[j], chars[i]
	}
	return string(chars)
}

func remake(s string, j int) string{
	chars := []rune(s)
	charFirst := chars[:j]
	charSecond := chars[j:]
	if len(charSecond) % 2 != 0{
		return string(charSecond) + reversestring(string(charFirst))
	} else {
		return string(charSecond) + string(charFirst)
	}
}

func main() {
	var n, ansk int
	fmt.Scanf("%d\n", &n)
	for i:=0 ; i < n; i++{
		var l int
		fmt.Scanf("%d\n", &l)
		var s string
		fmt.Scanf("%s\n", &s)
		var ans = s
		ansk = 1
		for j := 1; j < l; j++{
			var tmp = remake(s, j)
			if (tmp < ans) {
				ans = tmp
				ansk = j + 1
			}
		}
		fmt.Println(ans)
		fmt.Println(ansk)
	}
	//var s string = "qwerty"
	//var ans = s
	//ansk := 1
	//l := 5
	//for j := 2; j < l; j++{
	//	var tmp = remake(s, j)
	//	if (tmp < ans) {
	//		ans = tmp
	//		ansk = j + 1
	//	}
	//}
	//fmt.Println(ans)
	//fmt.Println(ansk)
}

package main

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

func reverseString(s string) string {
	runes := []rune(s)
	for from, to := 0, len(runes)-1; from < to; from, to = from+1, to-1 {
		runes[from], runes[to] = runes[to], runes[from]
	}
	return string(runes)
}

func main() {
	for t := ReadInt(); t > 0; t-- {
		n := ReadInt()
		s := ReadString()
		ans := s
		var k int =0
		for i := 0; i < n; i++ {
			tmp1 := s[i:n]
			tmp2 := s[0:i]
			if (n-i)%2 == 1 {
				tmp2=reverseString(tmp2)
			}
			tmp1 += tmp2
			if tmp1 < ans {
				ans = tmp1
				k = i
			}
		}
		fmt.Println(ans)
		fmt.Println(k + 1)
	}
}

////////////////////////////////////

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

var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup

func ReadString() string {
	in.Scan()
	return in.Text()
}
func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}
func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.ParseInt(intStr, 10, 32)
	return int(i)
}
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	//set output
	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(write *bufio.Writer) {
		defer outWg.Done()
		defer write.Flush()

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

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)
		s := ""
		fmt.Fscanf(in, "%s\n", &s)
		ans := s
		best := 1
		for i := 1; i < n; i++ {
			newS := []byte(s[i:])
			for j := 0; j < i; j++ {
				k := j
				if (n-i)%2 == 0 {
					k = j
				} else {
					k = i - k - 1
				}
				newS = append(newS, s[k])
			}
			if string(newS) < ans {
				ans = string(newS)
				best = i + 1
			}
		}
		fmt.Fprintf(out, "%s\n", ans)
		fmt.Fprintf(out, "%d\n", best)

	}
	return
}

func getAns1(n, x, y int) int {
	p := x - 1
	q := n - y - 1
	if q > 0 {
		p -= q
		if p < 0 {
			p = 0
		}
		return p + 1
	} else if q == 0 {
		return x
	} else {
		ans1 := x + 1
		if ans1 > n {
			ans1 = n
		}
		return ans1
	}

}

func getAns2(n, x, y int) int {
	q := y - 1
	ans2 := x + q
	if ans2 > n {
		ans2 = n
	}
	return ans2
}

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

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

// yun xu you better ge geng haode ren
func ok1(n, x, y, better int) bool {
	if better < (x - 1) {
		return can1(n-better, x-better, y-better)
	} else {
		return true
	}
}

// can be no1
func can1(n, x, y int) bool {
	if (x + y) < 1+n {
		return true
	}
	return false
}

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
}

// var fst, last int
// var nxt, prev []int
// var ch []byte

// func pushBack(i int, char byte) {
// 	prv[i] = last
// 	ch[i] = char
// 	nxt[i] = -1
// 	if last >= 0 {
// 		nxt[last] = i
// 	}
// 	last = i
// }

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()
	// nxt = make([]int, 5000)
	// prv = make([]int, 5000)
	// ch = make([]byte, 5000)
	res := make([]byte, 5001)
	curr := make([]byte, 5001)

	for t := 0; t < T; t++ {
		n := NextInt()
		s := NextBytes()
		var resK int
		for k := 1; k <= n; k++ {
			for i := k - 1; i < n; i++ {
				curr[i-k+1] = s[i]
			}

			rotated := (n-(k-1))%2 == 1
			if rotated {
				for i := 0; i < k-1; i++ {
					// stderr("ass")
					curr[n-(k-1)+i] = s[k-1-i-1]
				}
			} else {
				for i := 0; i < k-1; i++ {
					// stderr("ass")
					curr[n-(k-1)+i] = s[i]
				}
			}
			// stderr("check", string(curr))
			if k == 1 || string(curr[:n]) < string(res[:n]) {
				// stderr("yeah!")
				copy(res[:n], curr[:n])
				resK = k
			}
		}

		fmt.Fprintln(out, string(res[:n]))
		fmt.Fprintln(out, resK)
	}
}

/*
URL:
https://codeforces.com/problemset/problem/1316/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
	S []rune
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		n = ReadInt()
		S = ReadRuneSlice()

		solve()
	}
}

func solve() {
	// C := []Candidate{}

	mini := "{{{{{{}}}}}}"
	ans := 0

	for k := 1; k <= n; k++ {
		bef := []rune{}
		for i := k - 1; i < n; i++ {
			bef = append(bef, S[i])
		}
		aft := []rune{}
		for i := 0; i < k-1; i++ {
			aft = append(aft, S[i])
		}

		if (n-k+1)%2 == 1 {
			aft = Reverse(aft)
		}

		tmp := []rune{}
		tmp = append(tmp, bef...)
		tmp = append(tmp, aft...)

		// obj := Candidate{S: tmp, k: k}
		// C = append(C, obj)

		if mini > string(tmp) {
			mini = string(tmp)
			ans = k
		}
	}

	// sort.SliceStable(C, func(i, j int) bool {
	// 	if string(C[i].S) < string(C[j].S) {
	// 		return true
	// 	} else if string(C[i].S) > string(C[j].S) {
	// 		return false
	// 	} else {
	// 		return C[i].k < C[j].k
	// 	}
	// })
	// fmt.Println(string(C[0].S))
	// fmt.Println(C[0].k)

	fmt.Println(mini)
	fmt.Println(ans)
}

type Candidate struct {
	S []rune
	k int
}

func Reverse(A []rune) []rune {
	res := []rune{}

	n := len(A)
	for i := n - 1; i >= 0; i-- {
		res = append(res, A[i])
	}

	return res
}

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

/*********** 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"
	"strconv"
)

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < cases; i++ {
		line := readLine(reader)
		n, _ := strconv.Atoi(string(line))
		str := readLine(reader)
		// fmt.Println(cases, n, str)
		k, s := 1, string(str)
		for j := 2; j <= n; j++ {
			sss := make([]byte, n)
			copy(sss, str)
			temp := reverseS(sss, j)
			if temp < s {
				k = j
				s = temp
			}
		}
		fmt.Println(s)
		fmt.Println(k)
	}
}

func reverseS(str []byte, k int) string {
	first := str[k-1:]
	second := make([]byte, 0)
	if (len(str)-k+1) % 2 == 1 { // 奇数反转
		for i:=k-1;i>=0;i--{
			second = append(second, str[i])
		}
		return string(first) + string(second)
	}
	return string(first) + string(str[0:k-1])
}

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"
	"os"
	"sort"
	"strconv"
	"strings"
	"sync"
)

func main() {

	for t := ScanInt(); t > 0; t-- {
		n := ScanInt()
		s := ScanWord()

		c := []class{}
		for k := 1; k <= n; k++ {
			c = append(c, class{Str: krev(s, k), K: k})
		}
		sort.Slice(c, func(i, j int) bool {
			if c[i].Str < c[j].Str {
				return true
			} else if c[i].Str > c[j].Str {
				return false
			} else {
				return c[i].K < c[j].K
			}
		})
		P(c[0].K)
		P(c[0].Str)
	}

	close(O)
	oWg.Wait()
}

type class struct {
	Str string
	K   int
}

func krev(s string, k int) string {
	right := s[k-1:]
	left := s[:k-1]

	r := right
	if len(s)%2 == k%2 {
		r = r + rev(left)
	} else {
		r = r + left
	}
	return r
}
func rev(str string) string {
	s := []byte(str)
	n := len(s)
	for i := 0; i < n/2; i++ {
		s[i], s[n-i-1] = s[n-i-1], s[i]
	}
	return string(s)
}

/*********************** 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 ...byte) (byte, byte) {
	minVal, maxVal := args[0], args[0]
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...byte) byte { mn, _ := MnMx(args...); return mn }
func Mx(args ...byte) byte { _, 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"
	"os"
	"sort"
	"strconv"
	"strings"
	"sync"
)

func main() {
	for t := ScanInt(); t > 0; t-- {
		n := ScanInt()
		s := []byte(ScanWord())
		sCopy := s
		sarr := make([]string, 0, n)
		for i := 0; i < len(s)-1; i++ {

			sarr = append(sarr, string(s[i:]))
		}

		minI := 0
		minV := strings.Repeat("z", n)
		//P(sarr)
		for i := 0; i < len(s) - 1; i++ {
			if sarr[i] < minV {
				minI = i
				minV = sarr[i]
			}
		}

		// alabka
		// a
		//P("minI:", string(s[minI]), minI)

		right := s[minI:]
		left := []byte{}

		if len(right)%2 == 0 {
			left = s[:minI]
		} else {
			left = rev(s[:minI])
		}

		//P("left", string(left))
		//P("right", string(right))

		result := append(right, left...)

		sb := strings.Builder{}
		for i := 0; i < len(result); i++ {
			sb.WriteByte(result[i])
		}
		resultFInal := sb.String()

		revStrig := string(rev(sCopy))

		if resultFInal < revStrig {
			P(sb.String())
			P(minI + 1)
		} else {
			P(revStrig)
			P(n)
		}

	}

	close(O)
	oWg.Wait()
}

func rev(s []byte) []byte {
	n := len(s)
	for i := 0; i < n/2; i++ {
		s[i], s[n-i-1] = s[n-i-1], s[i]
	}
	return s
}

/*********************** 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 ...byte) (byte, byte) {
	minVal, maxVal := args[0], args[0]
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...byte) byte { mn, _ := MnMx(args...); return mn }
func Mx(args ...byte) byte { _, 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"
  "os"
)

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

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

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

func solve(s string) {
  var min byte = 'z'
  start := []int{}
  resS, resK := s, 1
  for i := range s {
    if s[i] < min {
      min = s[i]
      start = []int{i}
    } else if s[i] == min {
      start = append(start, i)
    }
  }
  for _, i := range start {
    res := flip(s, i)
    if res < resS {
      resS, resK = res, i+1
    }
  }
  printf("%s\n%d\n", resS, resK)
}

func flip(s string, i int) string {
  res := s[i:] + s[:i]
  if (len(s)-i)%2 == 1 {
    l, r := i, len(s)-1
    b := []byte(res)
    for l < r {
      b[l], b[r] = b[r], b[l]
      l++
      r--
    }
    return string(b)
  } else {
    return res
  }
}

package main

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

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

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

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

func solve(s string) {
  var min byte = 'z'
  start := []int{}
  resS, resK := s, 1
  for i := range s {
    if s[i] < min {
      min = s[i]
      start = []int{i}
    } else if s[i] == min {
      start = append(start, i)
    }
  }
  for _, i := range start {
    res := flip(s, i)
    if res < resS {
      resS, resK = res, i+1
    }
  }
  printf("%s\n%d\n", resS, resK)
}

func flip(s string, i int) string {
  res := s[i:] + s[:i]

  if i%2 == 1 {
    l, r := len(s)-i, len(s)-1
    b := []byte(res)
    for l < r {
      b[l], b[r] = b[r], b[l]
      l++
      r--
    }
    return string(b)
  } else {
    return res
  }
}

package main

import (
	"fmt"
)
func reversestring(s string) string{
	chars := []rune(s)
	for i, j :=0, len(s)-1; i < j; i, j = i + 1, j - 1{
		chars[i], chars[j] = chars[j], chars[i]
	}
	return string(chars)
}

func remake(s string, j int) string{
	chars := []rune(s)
	charFirst := chars[:j]
	charSecond := chars[j:]
	if j % 2 != 0{
		return string(charSecond) + reversestring(string(charFirst))
	} else {
		return string(charSecond) + string(charFirst)
	}
}

func main() {
	var n, ansk int
	fmt.Scanf("%d\n", &n)
	for i:=0 ; i < n; i++{
		var l int
		fmt.Scanf("%d\n", &l)
		var s string
		fmt.Scanf("%s\n", &s)
		var ans = s
		ansk = 1
		for j := 2; j < l; j++{
			var tmp = remake(s, j)
			if (tmp < ans) {
				ans = tmp
				ansk = j + 1
			}
		}
		fmt.Println(ans)
		fmt.Println(ansk)
	}
	//var s string = "qwerty"
	//var ans = s
	//ansk := 1
	//l := 5
	//for j := 2; j < l; j++{
	//	var tmp = remake(s, j)
	//	if (tmp < ans) {
	//		ans = tmp
	//		ansk = j + 1
	//	}
	//}
	//fmt.Println(ans)
	//fmt.Println(ansk)
}

package main

import (
	"fmt"
)
func reversestring(s string) string{
	chars := []rune(s)
	for i, j :=0, len(s)-1; i < j; i, j = i + 1, j - 1{
		chars[i], chars[j] = chars[j], chars[i]
	}
	return string(chars)
}

func remake(s string, j int) string{
	chars := []rune(s)
	charFirst := chars[:j]
	charSecond := chars[j:]
	if len(charSecond) % 2 != 0{
		return string(charSecond) + reversestring(string(charFirst))
	} else {
		return string(charSecond) + string(charFirst)
	}
}

func main() {
	var n, ansk int
	fmt.Scanf("%d\n", &n)
	for i:=0 ; i < n; i++{
		var l int
		fmt.Scanf("%d\n", &l)
		var s string
		fmt.Scanf("%s\n", &s)
		var ans = s
		ansk = 1
		for j := 2; j < l; j++{
			var tmp = remake(s, j)
			if (tmp < ans) {
				ans = tmp
				ansk = j + 1
			}
		}
		fmt.Println(ans)
		fmt.Println(ansk)
	}
	//var s string = "qwerty"
	//var ans = s
	//ansk := 1
	//l := 5
	//for j := 2; j < l; j++{
	//	var tmp = remake(s, j)
	//	if (tmp < ans) {
	//		ans = tmp
	//		ansk = j + 1
	//	}
	//}
	//fmt.Println(ans)
	//fmt.Println(ansk)
}

package main

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

func reverseString(s string) string {
	runes := []rune(s)
	for from, to := 0, len(runes)-1; from < to; from, to = from+1, to-1 {
		runes[from], runes[to] = runes[to], runes[from]
	}
	return string(runes)
}

func main() {
	for t := ReadInt(); t > 0; t-- {
		n := ReadInt()
		s := ReadString()
		ans := s
		var k int
		for i := 0; i < n; i++ {
			tmp1 := s[i:]
			tmp2 := s[0:i]
			if (n-i)&1 == 1 {
				reverseString(tmp2)
			}
			tmp1 += tmp2
			if tmp1 < ans {
				ans = tmp1
				k = i
			}
		}
		fmt.Println(ans)
		fmt.Println(k + 1)
	}
}

////////////////////////////////////

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

var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup

func ReadString() string {
	in.Scan()
	return in.Text()
}
func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}
func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.ParseInt(intStr, 10, 32)
	return int(i)
}
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	//set output
	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(write *bufio.Writer) {
		defer outWg.Done()
		defer write.Flush()

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


package main

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

type Scanner struct {
	*bufio.Scanner
}

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

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

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

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

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

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

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

type word struct {
	count  map[byte]int
	length int
}

func newWord(w string) word {
	count := make(map[byte]int)
	for _, ch := range []byte(w) {
		count[ch] += 1
	}
	return word{count: count, length: len(w)}
}

func (w word) delta(ch byte) int {
	return 2*w.count[ch] - w.length
}

func solve(w []string) int {
	words := make([]word, len(w))
	for i := range w {
		words[i] = newWord(w[i])
	}

	res := 0
	for _, ch := range []byte("abcde") {
		sort.Slice(words, func(i, j int) bool {
			return words[i].delta(ch) > words[j].delta(ch)
		})

		delta := 0
		for i := range words {
			delta += words[i].delta(ch)
			if delta <= 0 {
				break
			}
			if i+1 > res {
				res = i + 1
			}
		}
	}
	return res
}

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

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

package main

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

var a, b, c, d, e int
var count = [5]int{0, 0, 0, 0, 0}
var rescount = [5]int{0, 0, 0, 0, 0}
var values []int
var words []string

func main() {
	var (
		t, n  int
		s     string
		words []string
	)
	fmt.Scanln(&t)
	for i := 0; i < t; i++ {
		a, b, c, d, e = 0, 0, 0, 0, 0
		fmt.Scanln(&n)
		for j := 0; j < n; j++ {
			fmt.Scanln(&s)
			words = append(words, s)
		}
		fmt.Println(interestingStory(words))
		words = []string{}
	}
}

func interestingStory(words []string) int {
	values = []int{}
	for _, element := range words {
		fillMap(element, "a")
	}
	rescount[0] = countMax()
	for _, element := range words {
		fillMap(element, "b")
	}
	rescount[1] = countMax()
	for _, element := range words {
		fillMap(element, "c")
	}
	rescount[2] = countMax()
	for _, element := range words {
		fillMap(element, "d")
	}
	rescount[3] = countMax()
	for _, element := range words {
		fillMap(element, "e")
	}
	rescount[4] = countMax()
	m := 0
	for _, e := range rescount {
		if e > m {
			m = e
		}
	}
	rescount[0], rescount[1], rescount[2], rescount[3], rescount[4] = 0, 0, 0, 0, 0
	return m
}

func countMax() int {
	sort.Ints(values)
	count := 0
	sum := 0
	for i := len(values) - 1; i >= 0; i-- {
		sum += values[i]
		if sum > 0 {
			count++
		}
	}
	values = []int{}
	return count
}

func fillMap(word string, letter string) {
	value := 2*strings.Count(word, letter) - len(word)
	values = append(values, value)
}

package main

import (
	"fmt"
	"strings"
)

type word struct {
	Num        int64
	LetterSum  int64
	LetterList map[int32]int64
	Differents []int64
}

func main() {
	var t int64
	var n int64
	_, err := fmt.Scan(&t)
	if err != nil {
		return
	}

	for i := int64(0); i < t; i++ {
		_, err = fmt.Scan(&n)
		if err != nil {
			return
		}
		var stringArray []string
		var str string
		for j := int64(0); j < n; j++ {
			_, err := fmt.Scan(&str)
			if err != nil {
				return
			}
			stringArray = append(stringArray, str)
		}
		wordsInfo := countLetters(stringArray)
		result := getResult(n, wordsInfo)
		fmt.Println(result)
	}
}

func countLetters(stringArray []string) map[string]*word {
	m := make(map[string]*word)
	for _, str := range stringArray {
		if _, ok := m[str]; ok {
			m[str].Num++
			m[str].LetterSum += int64(len(str))
		} else {
			m[str] = &word{}
			m[str].LetterList = map[int32]int64{
				'a': 0,
				'b': 0,
				'c': 0,
				'd': 0,
				'e': 0,
			}
			m[str].Num = 1
			for _, c := range str {
				m[str].LetterList[c]++
			}
			m[str].LetterSum += int64(len(str))
			m[str].Differents = append(m[str].Differents, int64(len(str)-2*strings.Count(str, "a")),
				int64(len(str)-2*strings.Count(str, "b")),
				int64(len(str)-2*strings.Count(str, "c")),
				int64(len(str)-2*strings.Count(str, "d")),
				int64(len(str)-2*strings.Count(str, "e")))
		}
	}

	return m
}

func getResult(n int64, wordInfo map[string]*word) int64 {
	var max int64
	for i := 'a'; i < 'f'; i++ {
		m := n
		words := sort(wordInfo, i)
		letterNum := map[int32]int64{
			'a': 0,
			'b': 0,
			'c': 0,
			'd': 0,
			'e': 0,
		}
		var sum int64
		for _, word := range wordInfo {
			letterNum['a'] += word.Num * word.LetterList['a']
			letterNum['b'] += word.Num * word.LetterList['b']
			letterNum['c'] += word.Num * word.LetterList['c']
			letterNum['d'] += word.Num * word.LetterList['d']
			letterNum['e'] += word.Num * word.LetterList['e']
		}
		sum += letterNum['a'] + letterNum['b'] + letterNum['c'] + letterNum['d'] + letterNum['e']
		othersSum := sum - letterNum[i]
		if letterNum[i] > othersSum {
			if max < m {
				max = m
			}
			continue
		}

		for _, word := range words {
			for j := int64(0); j < word.Num; j++ {
				d := word.LetterSum/word.Num - word.LetterList[i]
				if word.LetterList[i] < d {
					letterNum[i] -= word.LetterList[i]
					othersSum -= d
					m--
				}
				if letterNum[i] > othersSum {
					if max < m {
						max = m

					}
				}
			}

		}
	}

	return max
}

func sort(m map[string]*word, l int32) []*word {
	index := l - 'a'
	var words []*word
	for _, w := range m {
		words = append(words, w)
	}

	for i := len(words) - 1; i > 0; i-- {
		for j := 0; j < i; j++ {
			if words[j].Differents[index] < words[j+1].Differents[index] {
				words[j], words[j+1] = words[j+1], words[j]
			}
		}
	}

	return words
}

package main

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

func run(r io.Reader, w io.Writer) {
	in := bufio.NewReader(r)
	out := bufio.NewWriter(w)
	defer out.Flush()

	var t int
	for Fscan(in, &t); t > 0; t-- {
		var n int
		Fscan(in, &n)

		words := make([]string, n)
		for i := 0; i < n; i++ {
			Fscan(in, &words[i])
		}

		ans := 0
		for c := 0; c < 5; c++ {
			extras := make([]int, n)
			for i := 0; i < n; i++ {
				for _, char := range words[i] {
					if char == rune('a' + c) {
						extras[i]++
					} else {
						extras[i]--
					}
				}
			}
			sort.Slice(extras, func(i, j int) bool {
				return extras[i] > extras[j]
			})
			sum := 0
			for i, val := range extras {
				sum += val
				if sum <= 0 {
					break
				}
				ans = max(ans, i + 1)
			}
		}
		Fprintln(out, ans)
	}

}

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

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

package main

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

func run(r io.Reader, w io.Writer) {
	in := bufio.NewReader(r)
	out := bufio.NewWriter(w)
	defer out.Flush()

	var t int
	for Fscan(in, &t); t > 0; t-- {
		var n int
		Fscan(in, &n)

		words := make([]string, n)
		for i := 0; i < n; i++ {
			Fscan(in, &words[i])
		}
		ans := 0

		for c := 0; c < 5; c++ {
			f := make([]int, n)
			for i := 0; i < n; i++ {
				for _, letter := range words[i]	{
					if letter == rune('a' + c) {
						f[i]++

					} else {
						f[i]--
					}
				}
			}

			sort.Slice(f, func(i, j int) bool {
				return f[i] > f[j]
			})
			sum := 0
			for i := 0; i < n; i++ {
				sum += f[i]
				if sum <= 0 {
					break
				}
				ans = max(ans, i+1)
			}
		}
		Fprintln(out, ans)
	}
}

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

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

package main

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

type Scanner struct {
	*bufio.Scanner
}

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

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

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

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

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

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

func calcDelta(word []byte, special byte) int {
	delta := 0
	for _, ch := range word {
		if ch == special {
			delta += 1
		} else {
			delta -= 1
		}
	}
	return delta
}

func score(words [][]byte, special byte) int {
	deltas := make([]int, len(words))
	for i := range words {
		deltas[i] = calcDelta(words[i], special)
	}

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

	count := 0
	delta := 0

	for i := range deltas {
		delta += deltas[i]
		if delta <= 0 {
			break
		} else {
			count += 1
		}
	}
	return count
}

func solve(words [][]byte) int {
	res := 0
	for _, ch := range []byte("abcde") {
		if attempt := score(words, ch); attempt > res {
			res = attempt
		}
	}
	return res
}

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

	for i := 0; i < tests; i += 1 {
		n := stdin.Int()
		words := make([][]byte, n)
		for j := 0; j < n; j += 1 {
			words[j] = []byte(stdin.Word())
		}
		fmt.Println(solve(words))
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var test int
	fmt.Fscan(in, &test)
	for ; test > 0; test-- {
		var n int
		fmt.Fscan(in, &n)

		ar := make([]int, n)
		br := make([]int, n)
		cr := make([]int, n)
		dr := make([]int, n)
		er := make([]int, n)
		var s string
		for i := range ar {
			fmt.Fscan(in, &s)
			var ta, tb, tc, td, te, all int
			for j := range s {
				switch s[j] {
				case 'a':
					ta++
				case 'b':
					tb++
				case 'c':
					tc++
				case 'd':
					td++
				case 'e':
					te++
				}
			}
			all = ta + tb + tc + td + te
			ar[i] = ta + ta - all
			br[i] = tb + tb - all
			cr[i] = tc + tc - all
			dr[i] = td + td - all
			er[i] = te + te - all
		}

		sort.Sort(sort.Reverse(sort.IntSlice(ar)))
		sort.Sort(sort.Reverse(sort.IntSlice(br)))
		sort.Sort(sort.Reverse(sort.IntSlice(cr)))
		sort.Sort(sort.Reverse(sort.IntSlice(dr)))
		sort.Sort(sort.Reverse(sort.IntSlice(er)))

		rr := [5]int{
			count(ar),
			count(br),
			count(cr),
			count(dr),
			count(er),
		}

		max := 0
		for i := range rr {
			if rr[i] > rr[max] {
				max = i
			}
		}

		fmt.Fprintln(out, rr[max])
	}
}

func count(ar []int) int {
	c := 0
	for i := range ar {
		if t := c + ar[i]; t < 1 {
			return i
		}
		c += ar[i]
	}
	return len(ar)
}

package main

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

var in *bufio.Reader

type word struct {
	a, b, c, d, e int
}

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

func calMaxWords(words []word, getDiff func(word) int) int {
	diffs := make([]int, len(words))
	for i, w := range words {
		diffs[i] = getDiff(w)
	}

	// sort.Slice(diffs, func(i, j int) bool {
	// 	return diffs[i] > diffs[j]
	// })
	sort.Sort(sort.Reverse(sort.IntSlice(diffs)))

	acc, cnt := 0, 0
	for _, di := range diffs {
		if acc+di > 0 {
			acc += di
			cnt++
			continue
		}
		break
	}
	return cnt
}

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

	words := make([]word, n)
	for i := 0; i < n; i++ {
		var tmp string
		fmt.Fscan(in, &tmp)
		for _, ch := range tmp {
			switch ch {
			case 'a':
				words[i].a++
			case 'b':
				words[i].b++
			case 'c':
				words[i].c++
			case 'd':
				words[i].d++
			case 'e':
				words[i].e++
			default:
				panic("unknown character")
			}
		}
	}
	result := calMaxWords(words, func(w word) int {
		return w.a - (w.b + w.c + w.d + w.e)
	})
	result = max(result, calMaxWords(words, func(w word) int {
		return w.b - (w.a + w.c + w.d + w.e)
	}))
	result = max(result, calMaxWords(words, func(w word) int {
		return w.c - (w.a + w.b + w.d + w.e)
	}))
	result = max(result, calMaxWords(words, func(w word) int {
		return w.d - (w.a + w.b + w.c + w.e)
	}))
	result = max(result, calMaxWords(words, func(w word) int {
		return w.e - (w.a + w.b + w.c + w.d)
	}))
	fmt.Println(result)
}

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

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

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

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)

		type e struct {
			s string
			c []int
		}

		arr := make([]e, n)
		count := make([]int, 5)
		for i := 0; i < n; i++ {
			var s string
			fmt.Fscan(in, &s)

			c := make([]int, 5)
			for _, ch := range s {
				c[ch-'a']++
				count[ch-'a']++
			}

			arr[i] = e{s, c}
		}

		// sort words by majority letter - total length
		sortFn := func(idx int) {
			sort.Slice(arr, func(i, j int) bool {
				c1 := arr[i].c[idx]
				c2 := arr[j].c[idx]
				return c1-(len(arr[i].s)-c1) > c2-(len(arr[j].s)-c2)
			})
		}

		var max int
		for i := 0; i < 5; i++ {
			sortFn(i)
			var tally int
			var x, y int
			for _, e := range arr {
				x += e.c[i]
				y += len(e.s) - e.c[i]

				if y >= x {
					break
				}
				tally++
			}

			if tally > max {
				max = tally
			}
		}
		fmt.Fprintln(out, max)
	}
}

package main

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

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

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

	TOKENS := []rune{'a', 'b', 'c', 'd', 'e'}

	for tc := 0; tc < TC; tc += 1 {
		var N int
		fmt.Fscan(reader, &N)

		words := make([]string, N, N)
		for i := 0; i < N; i += 1 {
			fmt.Fscan(reader, &words[i])
		}

		maxWordCnt := 0
		for _, token := range TOKENS {
			scores := make([]int, N, N)
			for i, word := range words {
				for _, r := range word {
					// debug
					// fmt.Printf("DEBUG: matching token %c vs wordchar %c\n", token, r)
					if token == r {
						scores[i] += 1
					} else {
						scores[i] -= 1
					}
				}
			}
			// debug
			// for i, word := range words {
			// 	fmt.Printf("DEBUG: token %c word %s score: %d\n", token, word, scores[i])
			// }
			sort.Ints(scores)
			sum := 0
			wordCnt := 0
			for i := len(scores)-1; i >= 0; i -= 1 {
				score := scores[i]
				if score + sum < 1 {
					break
				}
				sum += score
				wordCnt += 1
			}
			if maxWordCnt < wordCnt {
				maxWordCnt = wordCnt
			}
		}
		fmt.Printf("%d\n", maxWordCnt)
	}
}

package main

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

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

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

func main() {
	defer out.Flush()

	var (
		n, t int
	)
	fmt.Fscanf(in, "%d", &t)
	for t > 0 {
		t--
		var str [200000]string
		fmt.Fscan(in, &n)

		for i := 0; i < n; i++ {
			fmt.Fscan(in, &str[i])
		}
		cnt := 0
		for i := 0; i < 5; i++ {
			num := make([]int, n)
			for j := 0; j < n; j++ {
				ans := 0
				for k := 0; k < len(str[j]); k++ {
					if int(str[j][k]) == 97+i {
						ans++
					} else {
						ans--
					}

				}
				num[j] = ans
			}
			sort.Slice(num, func(i, j int) bool { return num[i] > num[j] })
			for j := 1; j < n; j++ {
				num[j] += num[j-1]
			}
			for j := 0; j < n; j++ {
				if num[j] <= 0 {
					if cnt < j {
						cnt = j
					}
					break
				}
				if num[j] > 0 && j+1 == n {
					cnt = n
				}
			}
		}
		printf("%d\n", cnt)

	}

}

package main

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

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

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

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

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

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

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

func main() {
	defer writer.Flush()
	for t := _int(); t > 0; t-- {
		n := _int()
		a := make([]string, n)
		for i := range a {
			a[i] = _string()
		}
		printf("%d\n", sol(n, a))
	}
}

func sol(n int, a []string) int {
	counts := make([]map[rune]int, n)
	for i := range a {
		counts[i] = makeCounts(a[i])
	}
	ret := 0
	for _, r := range []rune{'a', 'b', 'c', 'd', 'e'} {
		deltas := make([]int, n)
		for i := range counts {
			countR := counts[i][r]
			countO := counts[i][0] - counts[i][r]
			deltas[i] = countR - countO
		}
		sort.Ints(deltas)
		// printf("%v %v\n", string(r), deltas)
		cum := 0
		curr := 0
		for i := len(deltas) - 1; i >= 0; i-- {
			cum += deltas[i]
			if cum <= 0 {
				break
			}
			curr++
		}
		ret = max(ret, curr)
	}
	return ret
}

func makeCounts(w string) map[rune]int {
	ret := map[rune]int{}
	for _, r := range w {
		ret[r]++
		ret[0]++ // total
	}
	return ret
}

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

package main

import (
	"bufio"
	"bytes"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"sort"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		a := make([][]byte, n)
		cnt := make([][6]int, n)
		for i := range a {
			Fscan(in, &a[i])
			for ch := byte('a'); ch <= 'e'; ch++ {
				cnt[i][ch-'a'] = bytes.Count(a[i], []byte{ch})
			}
			cnt[i][5] = len(a[i])
		}
		ans := 0
		for k := 0; k < 5; k++ {
			sort.Slice(cnt, func(i, j int) bool {
				a, b := cnt[i], cnt[j]
				ak, ao := a[k], a[5]-a[k]
				bk, bo := b[k], b[5]-b[k]
				return ak-ao > bk-bo
			})

			s := 0
			ct := 0
			for _, c := range cnt {
				ak, ao := c[k], c[5]-c[k]
				d := ak - ao
				s += d
				if s <= 0 {
					break
				}
				ct++
			}
			ans = max(ans, ct)
		}
		Fprintln(out, ans)
	}

	T := 1
	Fscan(in, &T)
	for Case := 1; Case <= T; Case++ {
		solve(Case)
	}

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

func main() { run(os.Stdin, os.Stdout) }
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

import (
	"fmt"
	"strings"
)

var a, b, c, d, e int
var count = [5]int{0, 0, 0, 0, 0}
var values []int
var words []string

func main() {
	var (
		t, n  int
		s     string
		words []string
	)
	fmt.Scanln(&t)
	for i := 0; i < t; i++ {
		a, b, c, d, e = 0, 0, 0, 0, 0
		fmt.Scanln(&n)
		for j := 0; j < n; j++ {
			fmt.Scanln(&s)
			words = append(words, s)
		}
		fmt.Println(interestingStory(words))
		words = []string{}
	}
}

func interestingStory(words []string) int {
	letter := ""
	for _, element := range words {
		count[0] += strings.Count(element, "a")
		count[1] += strings.Count(element, "b")
		count[2] += strings.Count(element, "c")
		count[3] += strings.Count(element, "d")
		count[4] += strings.Count(element, "e")
	}
	m := 0
	mInd := 0
	for i, e := range count {
		if i == 0 || e > m {
			m = e
			mInd = i
		}
	}
	switch mInd {
	case 0:
		letter = "a"
	case 1:
		letter = "b"
	case 2:
		letter = "c"
	case 3:
		letter = "d"
	case 4:
		letter = "e"
	}
	values = []int{}
	for _, element := range words {
		fillMap(element, letter)
	}
	count[0], count[1], count[2], count[3], count[4] = 0, 0, 0, 0, 0
	return countMax()
}

func countMax() int {
	count := 0
	sum := 0
	for i := len(values) - 1; i >= 0; i-- {
		sum += values[i]
		if sum > 0 {
			count++
		}
	}
	return count
}

func fillMap(word string, letter string) {
	value := 2*strings.Count(word, letter) - len(word)
	for i, e := range values {
		if len(values) == 0 {
			values = append(values, value)
			return
		}
		if e > value {
			values = append(values, 0)
			copy(values[i+1:], values[i:])
			values[i] = value
			return
		}
	}
	values = append(values, value)
}

package main

import "fmt"

type word struct {
	Num        int64
	LetterSum  int64
	LetterList map[int32]int64
}

func main() {
	var t int64
	var n int64
	_, err := fmt.Scan(&t)
	if err != nil {
		return
	}

	for i := int64(0); i < t; i++ {
		_, err = fmt.Scan(&n)
		if err != nil {
			return
		}
		var stringArray []string
		var str string
		for j := int64(0); j < n; j++ {
			_, err := fmt.Scan(&str)
			if err != nil {
				return
			}
			stringArray = append(stringArray, str)
		}
		wordsInfo := countLetters(stringArray)
		result := getResult(n, wordsInfo)
		fmt.Println(result)
	}
}

func countLetters(stringArray []string) map[string]*word {
	m := make(map[string]*word)
	for _, str := range stringArray {
		if _, ok := m[str]; ok {
			m[str].Num++
			m[str].LetterSum += int64(len(str))
		} else {
			m[str] = &word{}
			m[str].LetterList = map[int32]int64{
				'a': 0,
				'b': 0,
				'c': 0,
				'd': 0,
				'e': 0,
			}
			m[str].Num = 1
			for _, c := range str {
				m[str].LetterList[c]++
			}
			m[str].LetterSum += int64(len(str))
		}
	}

	return m
}

func getResult(n int64, wordInfo map[string]*word) int64 {
	var max int64
	for i := 'a'; i < 'f'; i++ {
		m := n
		letterNum := map[int32]int64{
			'a': 0,
			'b': 0,
			'c': 0,
			'd': 0,
			'e': 0,
		}
		var sum int64
		for _, word := range wordInfo {
			letterNum['a'] += word.Num * word.LetterList['a']
			letterNum['b'] += word.Num * word.LetterList['b']
			letterNum['c'] += word.Num * word.LetterList['c']
			letterNum['d'] += word.Num * word.LetterList['d']
			letterNum['e'] += word.Num * word.LetterList['e']
		}
		sum += letterNum['a'] + letterNum['b'] + letterNum['c'] + letterNum['d'] + letterNum['e']
		othersSum := sum - letterNum[i]
		if letterNum[i] > othersSum {
			if max < m {
				max = m
			}
		}

		for _, word := range wordInfo {
			for j := int64(0); j < word.Num; j++ {
				d := word.LetterSum/word.Num - word.LetterList[i]
				if word.LetterList[i] < d {
					letterNum[i] -= word.LetterList[i]
					othersSum -= d
					m--
				}
				if letterNum[i] > othersSum {
					if max < m {
						max = m
					}
				}
			}

		}
	}

	return max
}