This is the easy version of the problem. The only difference is the constraints on $$$n$$$ and $$$k$$$. You can make hacks only if all versions of the problem are solved.You have a string $$$s$$$, and you can do two types of operations on it:   Delete the last character of the string.  Duplicate the string: $$$s:=s+s$$$, where $$$+$$$ denotes concatenation. You can use each operation any number of times (possibly none).Your task is to find the lexicographically smallest string of length exactly $$$k$$$ that can be obtained by doing these operations on string $$$s$$$.A string $$$a$$$ is lexicographically smaller than a string $$$b$$$ if and only if one of the following holds:  $$$a$$$ is a prefix of $$$b$$$, but $$$a\ne b$$$;  In the first position where $$$a$$$ and $$$b$$$ differ, the string $$$a$$$ has a letter that appears earlier in the alphabet than the corresponding letter in $$$b$$$.

The first line contains two integers $$$n$$$, $$$k$$$ ($$$1 \leq n, k \leq 5000$$$) — the length of the original string $$$s$$$ and the length of the desired string. The second line contains the string $$$s$$$, consisting of $$$n$$$ lowercase English letters.

Print the lexicographically smallest string of length $$$k$$$ that can be obtained by doing the operations on string $$$s$$$.

NoteIn the first test, it is optimal to make one duplication: "dbcadabc" $$$\to$$$ "dbcadabcdbcadabc".In the second test it is optimal to delete the last $$$3$$$ characters, then duplicate the string $$$3$$$ times, then delete the last $$$3$$$ characters to make the string have length $$$k$$$."abcd" $$$\to$$$ "abc" $$$\to$$$ "ab" $$$\to$$$ "a" $$$\to$$$ "aa" $$$\to$$$ "aaaa" $$$\to$$$ "aaaaaaaa" $$$\to$$$ "aaaaaaa" $$$\to$$$ "aaaaaa" $$$\to$$$ "aaaaa".

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) ReadByteSlice(n int) []byte {
	res := make([]byte, 0, n)
	fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) Println(v ...interface{}) {
	fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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
}

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

func zFunction(a []byte) []int {
	res := make([]int, len(a))
	l, r := 0, 0

	for i := 1; i < len(a); i++ {
		if i <= r {
			res[i] = min(r-i+1, res[i-l])
		}
		for i+res[i] < len(a) && a[res[i]] == a[i+res[i]] {
			res[i]++
		}
		if i+res[i]-1 > r {
			l = i
			r = i + res[i] - 1
		}
	}

	return res
}

func concatBytes (a ...[]byte) []byte {
	size := 0
	for _, v := range a {
		size += len(v)
	}

	res := make([]byte, size)

	size = 0
	for _, v := range a {
		size += copy(res[size:], v)
	}

	return res
}

//func findMinString(a, b []byte, mn int) []byte {
//	uh := concatBytes(b, []byte{'|'}, a, b)
//	z := zFunction(uh)
//	size := len(a)
//
//	for i := mn; i < size; i++ {
//		if a[i] > b[0] {
//			return concatBytes(a[:i], b[:i])
//		} else if a[i] < b[0] {
//			continue
//		} else {
//			k := z[size + 1 + i]
//			if k >= i - 2 {
//				return concatBytes(a[:i], b[:i])
//			} else if uh[size + 1 + i + k] < uh[k] {
//				return concatBytes(a, b)
//			} else if uh[size + 1 + i + k] > uh[k] {
//				return concatBytes(a[:i], b[:i])
//			}
//		}
//	}
//
//	return concatBytes(a, b)
//}

func getAns(a []byte, k int) []byte {
	mp := k / len(a)
	if k % len(a) != 0 {
		mp++
	}
	res := make([]byte, len(a) * mp)
	for i := 0; i < mp; i++ {
		copy(res[i * len(a):], a)
	}
	return res[:k]
}

func main() {
	io := NewIO(os.Stdin, os.Stdout)

	n, k := io.ReadPairInt()
	a := io.ReadByteSlice(n)

	uh := concatBytes(a, []byte{'|'}, a, a)
	z := zFunction(uh)

	for i := 1; i < len(a); i++ {
		//fmt.Println(i)
		if a[i] > a[0] {
			a = a[:i]
			break
		} else if a[i] < a[0] {
			continue
		} else {
			zz := z[len(a) + 1 + i]
			if zz == len(a) {
				break
			}
			if a[zz] < uh[len(a) + 1 + i + zz] {
				a = a[:i]
				break
			} else {
				continue
			}
		}
	}
	a = getAns(a, k)

	io.Println(string(a))
}

package main

import (
	"fmt"
	"strings"
)

/*
https://codeforces.com/problemset/problem/1537/E1
https://codeforces.com/problemset/problem/1537/E2

本题分为简单版本和困难版本，在困难版本中，n 和 k 不超过 5e5。

输入 n (≤5000) 和 k (≤5000)，以及一个长为 n 的字符串 s，由小写字母组成。

有如下两种操作，每种操作你都可以执行任意多次：
1. 删除 s 的最后一个字符；
2. 将 s 复制一份拼在后面，即 s = s + s。

输出你能得到的所有长为 k 的字符串中，字典序最小的字符串。
 */
func samllstr(n int, str string, k int) string{
	start := 0
	end := 1
	for ; end < n ;{
		if str[end] > str[start] {
			break
		}else if str[end] < str[start] {
			end++
			continue
		}else {
			flag := 0
			i,j := start+1, end+1
			for  ;i < end && j < n; i, j = i+1, j+1 {
				if str[i] < str[j] {
					flag = 1
					break//end-1为止
				}
				if str[i] > str[j] {
					flag = 2
					break
				}
			}
			if flag == 1  {
				break
			}
			if flag == 2 {
				end = j+1
			}else {
				if i == end {
					end = j
				}else {
					break
				}
			}
		}
	}/*
	5 10
	dcdcd
	Output
	dcdcddcdcd
	Answer
	dcdcdcdcdc
	Checker Log
	*/
	length := end-start
	return strings.Repeat(str[start:end], k/length) + str[:k%length]
}
/*
输入
8 16
dbcadabc
输出
dbcadabcdbcadabc
解释 复制一次

输入
4 5
abcd
输出
aaaaa

 */
func main() {
	var n, k int
	var str string
	fmt.Scan(&n, &k, &str)
	fmt.Printf("%v\n", samllstr(n,str, k))
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var n, k int
	fmt.Fscan(in,&n,&k)
	var s []byte
	fmt.Fscan(in,&s)
	delta := ""
	or := ""
	for i:=len(s)-1;i>=0;i--{
		now := string(s[:i+1])
		temp := now
		if delta==""{
			for len(now)<k{
				now = now+now
			}
			delta = now[:k]
			or = temp
		}else{
			for len(now)<len(delta){
				now = now + now
			}
			now = now[:len(delta)]
			flag := false
			for j:=0;j<len(delta);j++{
				if now[j]==delta[j]{
					continue
				}
				if now[j]>delta[j]{
					flag = false
					break
				}
				if now[j]<delta[j]{
					flag = true
					break
				}
			}
			if flag{
				delta = now
				or = temp
			}
		}
	}
	for len(or)<k{
		or = or + or
	}
	fmt.Fprintln(out,or[:k])
}

package main

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

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

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

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

	fmt.Println(solve(n, k, s))
}

func solve(n, k int, s string) string {

	//cafsafhat

	//baaaaa
	//14

	//xkkhaxkkhaggkgkgxkkhaxkkha

	//xkkhaxkkhaggkgkgxkkhaxkkha
	//xkkhaxkkhaggkgkgxkkhaxkkhaggkgkg

	//8 + 8
	//20

	var i int
	var found bool

	for i = 1; i < n; i++ {
		if s[0] > s[i] {
			continue

		} else if s[0] == s[i] {
			s1 := s[:i]
			lenS1 := len(s1)

			rem := n - i

			var s2 string

			if lenS1 <= rem {
				s2 = s[i: i+lenS1]

				if s1 < s2 {
					found = true
					break

				} else {
					continue
				}

			} else {
				s1 := s[: rem]

				s2 := s[i: i+rem]

				if s1 <= s2 {
					found = true
					break
				} else {
					continue
				}
			}

		} else {
			found = true
			break
		}
	}

	var temp string

	if !found {
		temp = s
	} else {
		temp = s[0: i]
	}

	t := len(temp)

	d := k/t
	r := k % t

	var ans bytes.Buffer

	if r != 0 {
		for i := 0; i < d; i++ {
			ans.WriteString(temp)
		}

		for i := 0; i < r; i++ {
			ans.WriteByte(temp[i])
		}
	} else {
		for i := 0; i < d; i++ {
			ans.WriteString(temp)
		}
	}

	return ans.String()

}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1537E2(in io.Reader, out io.Writer) {
	var n, k int
	var s string
	Fscan(bufio.NewReader(in), &n, &k, &s)
	sz := 1
	for i := range s {
		if s[i] > s[i%sz] {
			break
		}
		if s[i] < s[i%sz] {
			sz = i + 1
		}
	}
	Fprint(out, strings.Repeat(s[:sz], k/sz+1)[:k])
}

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

package main

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

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

func cf(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)

	fmt.Fprintln(out, n)
}

func cf1537E1(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n, k int
	var s string
	fmt.Fscan(in, &n, &k, &s)
	ss := []string{}
	for i := range s {
		ss = append(ss, strings.Repeat(s[:i+1], (k+i)/(i+1)))
	}
	sort.Strings(ss)

	fmt.Fprintln(out, ss[0][:k])
}

func cf691C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var x string
	fmt.Fscan(in, &x)
	if !strings.Contains(x, ".") {
		x += "."
	}
	x = strings.Trim(x, "0")
	idx := strings.Index(x, ".")
	e := idx - strings.IndexAny(x, "123456789")
	if e > 0 {
		e--
	}
	x = strings.Trim(x[:idx]+x[idx+1:], "0")
	if len(x) > 1 {
		x = x[:1] + "." + x[1:]
	}
	fmt.Fprint(out, x)
	if e != 0 {
		fmt.Fprint(out, "E", e)
	}
}

func cf467C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n, m, k int
	fmt.Fscan(in, &n, &m, &k)
	sums := make([]int64, n+1)
	for i := 1; i <= n; i++ {
		fmt.Fscan(in, &sums[i])
		sums[i] += sums[i-1]
	}
	f := make([]int64, n+1)
	for j := 1; j <= k; j++ {
		ff := make([]int64, n+1)
		for i := j * m; i <= n; i++ {
			ff[i] = max64(ff[i-1], sums[i]-sums[i-m]+f[i-m])
		}
		f = ff
	}

	fmt.Fprintln(out, f[n])
}

func cf1469C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
next:
	for ; t > 0; t-- {
		var n, k int
		fmt.Fscan(in, &n, &k)
		h := make([]int, n)
		for i := range h {
			fmt.Fscan(in, &h[i])
		}
		pre := []int{h[0], h[0]}
		for i := 1; i < n; i++ {
			cur := []int{max(pre[0]-k+1, h[i]), min(pre[1]+k-1, h[i]+k-1)}
			if cur[0] > cur[1] {
				fmt.Fprintln(out, "NO")
				continue next
			}
			pre = cur
		}
		if pre[0] == h[n-1] {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

func cf1060C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n, m, x int
	fmt.Fscan(in, &n, &m)
	nums1, nums2 := make([]int64, n+1), make([]int64, m+1)
	for i := 1; i <= n; i++ {
		fmt.Fscan(in, &nums1[i])
		nums1[i] += nums1[i-1]
	}
	for i := 1; i <= m; i++ {
		fmt.Fscan(in, &nums2[i])
		nums2[i] += nums2[i-1]
	}
	fmt.Fscan(in, &x)
	mins1, mins2 := make([]int64, n+1), make([]int64, m+1)
	for i := 1; i <= n; i++ {
		mins1[i] = nums1[i]
		for j := i + 1; j <= n; j++ {
			mins1[i] = min64(mins1[i], nums1[j]-nums1[j-i])
		}
	}
	for i := 1; i <= m; i++ {
		mins2[i] = nums2[i]
		for j := i + 1; j <= m; j++ {
			mins2[i] = min64(mins2[i], nums2[j]-nums2[j-i])
		}
	}
	ans := 0
	for i := 1; i <= n; i++ {
		for j := 1; j <= m; j++ {
			if mins1[i]*mins2[j] <= int64(x) && i*j > ans {
				ans = i * j
			}
		}
	}

	fmt.Fprintln(out, ans)
}

func cf1043D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n, m int
	fmt.Fscan(in, &n, &m)
	arr, preArr := make([]int, n+1), make([]int, n+1)
	var pre, cur int
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &cur)
		preArr[cur] = pre
		arr[pre], pre = cur, cur
	}
	for ; m > 1; m-- {
		pre = 0
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &cur)
			if arr[pre] != cur {
				preArr[cur] = 0
				arr[pre] = 0
			}
			pre = cur
		}
		arr[cur] = 0
	}
	ans := int64(n)
	for i := 1; i <= n; i++ {
		if arr[i] > 0 {
			cnt, id := 0, i
			for preArr[id] != 0 {
				id = preArr[id]
			}
			for arr[id] != 0 {
				arr[id], id = 0, arr[id]
				cnt++
				ans += int64(cnt)
			}
		}
	}

	fmt.Fprintln(out, ans)
}

func cf1519D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	nums1, nums2 := make([]int64, n), make([]int64, n)
	for i := range nums1 {
		fmt.Fscan(in, &nums1[i])
	}
	for i := range nums2 {
		fmt.Fscan(in, &nums2[i])
	}
	f := make([]int64, n+1)
	for i := range nums1 {
		f[i+1] = f[i] + nums1[i]*nums2[i]
	}
	ans := f[n]
	for i := range nums1 {
		for j, d, sum := i, 1, nums1[i]*nums2[i]; j-d >= 0 && j+d < n; d++ {
			sum += nums1[j-d]*nums2[j+d] + nums1[j+d]*nums2[j-d]
			ans = max64(ans, sum+f[n]-f[j+d+1]+f[j-d])
		}
		for j1, j2, d, sum := i, i+1, 0, int64(0); j1-d >= 0 && j2+d < n; d++ {
			sum += nums1[j2+d]*nums2[j1-d] + nums1[j1-d]*nums2[j2+d]
			ans = max64(ans, sum+f[n]-f[j2+d+1]+f[j1-d])
		}
	}

	fmt.Fprintln(out, ans)
}

func cf175C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	nums := make([][2]int64, n)
	for i := range nums {
		fmt.Fscan(in, &nums[i][0], &nums[i][1])
	}
	var t int
	fmt.Fscan(in, &t)
	p := make([]int64, t+2)
	p[t+1] = 1e12
	pre := int64(0)
	for i := 1; i <= t; i++ {
		fmt.Fscan(in, &p[i])
		pre, p[i] = p[i], p[i]-pre
	}
	sort.Slice(nums, func(i, j int) bool {
		return nums[i][1] < nums[j][1]
	})
	sum := int64(0)
	for i, j := 0, 1; i < len(nums); {
		sum += min64(nums[i][0], p[j]) * nums[i][1] * int64(j)
		if nums[i][0] > p[j] {
			nums[i][0] -= p[j]
			j++
		} else {
			p[j] -= nums[i][0]
			i++
		}
	}

	fmt.Fprintln(out, sum)
}

func cf494A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var s string
	fmt.Fscan(in, &s)
	sum, minSum, cnt := 0, len(s), 0
	for i := range s {
		if s[i] == '(' {
			sum++
		} else if s[i] == ')' {
			sum--
		} else {
			sum--
			minSum = sum
			cnt++
		}
		if sum < 0 {
			fmt.Fprintln(out, -1)
			return
		}
		minSum = min(minSum, sum)
	}
	if minSum < sum {
		fmt.Fprintln(out, -1)
	} else {
		fmt.Fprintln(out, strings.Repeat("1\n", cnt-1), sum+1)
	}
}

func cf1281B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	for ; n > 0; n-- {
		var s, c string
		fmt.Fscan(in, &s, &c)
		cs := []byte(s)
		j, a, b := len(s)-1, 0, 0
		for i := len(s) - 1; i >= 0; i-- {
			if cs[i] > cs[j] {
				a, b = i, j
			} else if cs[i] < cs[j] {
				j = i
			}
		}
		cs[a], cs[b] = cs[b], cs[a]
		if s = string(cs); s < c {
			fmt.Fprintln(out, s)
		} else {
			fmt.Fprintln(out, "---")
		}
	}
}

func cf605A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	nums := make([][3]int, n) // nums[0]原数字  nums[1]原下标	nums[2]排序后的下标
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &nums[i][0])
		nums[i][1] = i
	}
	sort.SliceStable(nums, func(i, j int) bool {
		return nums[i][0] < nums[j][0]
	})
	for i := range nums {
		nums[i][2] = i
	}
	sort.Slice(nums, func(i, j int) bool {
		return nums[i][1] < nums[j][1]
	})
	f := make([]int, n+1)
	for _, num := range nums {
		f[num[2]+1] = f[num[2]] + 1
	}

	fmt.Fprintln(out, n-max(f...))
}

func cf297B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n, m, k int
	fmt.Fscan(in, &n, &m, &k)
	if n > m {
		fmt.Fprintln(out, "YES")
		return
	}
	a, b := make([]int, n), make([]int, m)
	for i := range a {
		fmt.Fscan(in, &a[i])
	}
	for i := range b {
		fmt.Fscan(in, &b[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	sort.Sort(sort.Reverse(sort.IntSlice(b)))
	for i := range a {
		if a[i] > b[i] {
			fmt.Fprintln(out, "YES")
			return
		}
	}

	fmt.Fprintln(out, "NO")
}

func helan(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	nums := make([]int, n)
	for i := range nums {
		fmt.Fscan(in, &nums[i])
	}

	less, more := -1, n
	for i := 0; i < more; i++ {
		if nums[i] == 0 {
			less++
			nums[i], nums[less] = nums[less], nums[i]
		} else if nums[i] == 2 {
			more--
			nums[i], nums[more] = nums[more], nums[i]
			i--
		}
	}

	fmt.Fprintln(out, nums)
}

func cf1203D2(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var s, t string
	fmt.Fscan(in, &s, &t)
	ans := 0
	left, right := make([]int, len(t)), make([]int, len(t))
	i, j := 0, 0
	for ; i < len(s) && j < len(t); i++ {
		if s[i] == t[j] {
			left[j] = i
			j++
		}
	}
	ans = max(ans, len(s)-i)
	i, j = len(s)-1, len(t)-1
	for ; i >= 0 && j >= 0; i-- {
		if s[i] == t[j] {
			right[j] = i
			j--
		}
	}
	ans = max(ans, i+1)
	for k := 0; k < len(t)-1; k++ {
		ans = max(ans, right[k+1]-left[k]-1)
	}

	fmt.Fprintln(out, ans)

}

func cf1196D2(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var t, n, k int
	var s string
	fmt.Fscan(in, &t)
	pat := "RGB"
	for ; t > 0; t-- {
		fmt.Fscan(in, &n, &k, &s)
		ans := k
		for i := 0; i < 3; i++ {
			diff := 0
			for j := range s[:k] {
				if s[j] != pat[(i+j)%3] {
					diff++
				}
			}
			ans = min(ans, diff)
			for j := k; j < n; j++ {
				if s[j] != pat[(i+j)%3] {
					diff++
				}
				if s[j-k] != pat[(i+j-k%3)%3] {
					diff--
				}
				ans = min(ans, diff)
			}
		}

		fmt.Fprintln(out, ans)
	}
}

func cf44H(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var s string
	fmt.Fscan(in, &s)
	f := make([][10]int64, len(s))
	for i := range f[0] {
		f[0][i] = 1
	}
	for i := 1; i < len(s); i++ {
		for j := range f[i] {
			f[i][(j+int(s[i])-'0')/2] += f[i-1][j]
			if (j+int(s[i])-'0')&1 == 1 {
				f[i][(j+int(s[i])-'0'+1)/2] += f[i-1][j]
			}
		}
	}
	flag := true
	for i := range s[:len(s)-1] {
		if s[i]-s[i+1] <= 1 || s[i+1]-s[i] <= 1 {
			continue
		} else {
			flag = false
			break
		}
	}
	ans := int64(0)
	for i := range f[0] {
		ans += f[len(s)-1][i]
	}
	if flag {
		ans--
	}
	fmt.Fprintln(out, ans)
}

func cf1051D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, k int
	fmt.Fscan(in, &n, &k)
	if k == 1 {
		fmt.Fprintln(out, 2)
		return
	}
	mod := int64(998244353)
	f := make([][2]int64, k+1)
	f[1][1], f[2][0] = 2, 2
	for i := 2; i <= n; i++ {
		for j := min(k, 2*i); j >= 2; j-- {
			f[j][1] = (f[j][0]*2 + f[j][1] + f[j-1][1]) % mod
			f[j][0] = (f[j][0] + f[j-2][0] + f[j-1][1]*2) % mod
		}
	}

	fmt.Fprintln(out, (f[k][0]+f[k][1])%mod)
}

func cf1051D3(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, k int
	fmt.Fscan(in, &n, &k)
	if k == 1 {
		fmt.Fprintln(out, 2)
		return
	}
	mod := int64(998244353)
	f := make([][][2]int64, n+1)
	for i := range f {
		f[i] = make([][2]int64, k+1)
	}
	f[1][1][1], f[1][2][0] = 2, 2
	for i := 2; i <= n; i++ {
		f[i][1][1] = 2
		for j := 2; j <= k && j <= 2*i; j++ {
			f[i][j][0] = (f[i-1][j][0] + f[i-1][j-2][0] + f[i-1][j-1][1]*2) % mod
			f[i][j][1] = (f[i-1][j][0]*2 + f[i-1][j][1] + f[i-1][j-1][1]) % mod
		}
	}

	fmt.Fprintln(out, (f[n][k][0]+f[n][k][1])%mod)
}

func cf468A(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n int
	fmt.Fscan(in, &n)
	if n < 4 {
		fmt.Fprintln(out, "NO")
		return
	}
	fmt.Fprintln(out, "YES")
	if (n-4)&1 == 0 {
		fmt.Fprintln(out, "1 * 2 = 2")
		fmt.Fprintln(out, "2 * 3 = 6")
		fmt.Fprintln(out, "6 * 4 = 24")
	} else {
		fmt.Fprintln(out, "2 * 4 = 8")
		fmt.Fprintln(out, "3 * 5 = 15")
		fmt.Fprintln(out, "8 + 15 = 23")
		fmt.Fprintln(out, "23 + 1 = 24")
	}
	for i := 5 + n&1; i < n; i += 2 {
		fmt.Fprintln(out, i+1, "-", i, "= 1")
		fmt.Fprintln(out, "1 * 24 = 24")
	}
}

func cf573B(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, ans int
	fmt.Fscan(in, &n)
	arr := make([]int, n+2)
	for i := 1; i <= n; i++ {
		fmt.Fscan(in, &arr[i])
		arr[i] = min(arr[i], arr[i-1]+1)
	}
	for i := n; i >= 1; i-- {
		arr[i] = min(arr[i], arr[i+1]+1)
		ans = max(ans, arr[i])
	}

	fmt.Fprintln(out, ans)
}

func min(nums ...int) int {
	ans := nums[0]
	for _, num := range nums {
		if ans > num {
			ans = num
		}
	}
	return ans
}

func min64(nums ...int64) int64 {
	ans := nums[0]
	for _, num := range nums {
		if ans > num {
			ans = num
		}
	}
	return ans
}

func max(nums ...int) int {
	ans := nums[0]
	for _, num := range nums {
		if ans < num {
			ans = num
		}
	}
	return ans
}

func max64(nums ...int64) int64 {
	ans := nums[0]
	for _, num := range nums {
		if ans < num {
			ans = num
		}
	}
	return ans
}

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

package main

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

var (
	in   *bufio.Reader = bufio.NewReader(os.Stdin)
	n, k int
	s    string
)

func main() {
	fmt.Fscan(in, &n, &k, &s)
	sz := 1
	for i := range s {
		if s[i] > s[i%sz] {
			break
		}
		if s[i] < s[i%sz] {
			sz = i + 1
		}
	}
	ans := strings.Repeat(s[:sz], k/sz+1)[:k]
	fmt.Println(ans)
}

package main

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

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

	var n, k int
	var s string
	// for Fscan(in, &T); T > 0; T-- {
	Fscan(in, &n, &k, &s)
	sz := 1
	for i := 0; i < n; i++ {
		if s[i] > s[i%sz] {
			break
		}
		if s[i] < s[i%sz] {
			sz = i + 1
		}
	}
	Fprintf(out, strings.Repeat(s[:sz], k/sz+1)[:k])
	// }
}

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

package main

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

	var n, k int
	var s string
	Fscan(in, &n, &k, &s)
	ans := ""
	for i := 1; i <= n; i++ {
		time := (k - 1) / i + 1
		t := strings.Repeat(s[:i], time)
		if len(t) > k {
			t = t[:k]
		}
		if ans == "" || t < ans {
			ans = t
		}
	}
	Fprintln(out, ans)
}

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

package main

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

var _rbuf = bufio.NewReader(os.Stdin)
var _wbuf = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { _wbuf.Flush(); fmt.Fscan(_rbuf, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(_wbuf, f, a...) }

func main() {
	defer _wbuf.Flush()

	var n, k int
	var str string

	scan(&n, &k)
	scan(&str)

	for i := 1; i < n; i++ {
		if str[i:] > str || str[i:] == str[:n-i] {
			str = str[:i]
			break
		}
	}
	for len(str) < k {
		str += str
	}
	printf("%s\n", str[:k])
}

package main

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

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

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

	var n, k int
	var s string
	fmt.Fscan(r, &n, &k, &s)
	sz := 1
	for i := range s {
		if s[i] > s[i%sz] {
			break
		}
		if s[i] < s[i%sz] {
			sz = i + 1
		}
	}
	fmt.Fprint(w, strings.Repeat(s[:sz], k/sz+1)[:k])
}

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

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

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

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

package main

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

const (
	MOD int = 1e9+7
	NL byte = byte('\n')
	SP byte = byte(' ')
)

var (
	in *bufio.Scanner
	out *bufio.Writer

	n, k int
	s string
	res int
)

func main() {
	initBuffer()
	var t int = 1
	// t = getInt()
	for i := 0; i < t; i++ {
		solve()
	}
	// test()
	out.Flush()
}

func solve() {
	initialize()
	input()
	count()
	output()
}

func initialize() {

}

func input() {
	n = getInt()
	k = getInt()
	s = getString()
}

func count() {
	var arr []int = make([]int, n)
	for i := 1; i < n; i++ {
		if arr[i] > arr[0] {
			res = i
			return
		}
		arr[i] = arr[i-1]
		for arr[i] > 0 && s[i] != s[arr[i]%(i-arr[i])] {
			if s[i] < s[arr[i]%(i-arr[i])] {
				arr[i] = arr[arr[i]-1]
			} else {
				break
			}
		}
		if s[i] == s[arr[i]%(i-arr[i])] {
			arr[i]++
		} else if s[i] > s[arr[i]%(i-arr[i])] {
			res = i - arr[i]
			return
		}
	}
	res = n - arr[n-1]
	for i := 0; i < n; i++ {
		if s[i%res] < s[(res+i)%n] {
			return
		}
	}
	res = n
}

func output() {
	for i := 0; i < k / res; i++ {
		out.WriteString(s[:res])
	}
	out.WriteString(s[:k%res])
}

func test() {
	fmt.Print()
}

func initBuffer() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer([]byte{}, 4 * 1024 * 1024)
	in.Split(scanWords)
	out = bufio.NewWriter(os.Stdout)
}

func scanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}
	i := bytes.IndexByte(data, '\n')
	j := bytes.IndexByte(data, ' ')
	ind := min(i, j)
	if ind < 0 {
		ind = max(i, j)
	}
	if ind >= 0 {
		return ind + 1, dropCR(data[0:ind]), nil
	}
	if atEOF {
		return len(data), dropCR(data), nil
	}
	return 0, nil, nil
}

func dropCR(data []byte) []byte {
	if len(data) > 0 && data[len(data)-1] == '\r' {
		return data[:len(data)-1]
	}
	return data
}

func getFloat() float64 {
	in.Scan()
	b := in.Bytes()
	var isNeg bool
	if b[0] == '-' {
		isNeg = true
		b = b[1:]
	}
	var res1 int64
	for i := 0; i < len(b); i++ {
		if b[i] == '.' {
			b = b[i+1:]
			break
		}
		res1 *= 10
		res1 += int64(b[i]) - 48
		if i == len(b) - 1 {
			b = b[:0]
		}
	}
	var res2 float64
	for i := len(b); i > 0; i-- {
		res2 += float64(b[i-1]) - 48
		res2 /= 10
	}
	if isNeg {
		res1 *= -1
		res2 *= -1
	}
	return float64(res1) + res2
}

func getInt() int {
	return int(getInt64())
}

func getInt64() int64 {
	in.Scan()
	b := in.Bytes()
	var isNeg bool
	if b[0] == '-' {
		isNeg = true
		b = b[1:]
	}
	var res int64
	for i := 0; i < len(b); i++ {
		res *= 10
		res += int64(b[i]) - 48
	}
	if isNeg {
		res *= -1
	}
	return res
}

func getString() string {
	in.Scan()
	return in.Text()
}

func intToBytes(n int) []byte {
	return int64ToBytes(int64(n))
}

func int64ToBytes(n int64) []byte {
	var res [65]byte
	var isNeg bool
	if n < 0 {
		isNeg = true
		n = -n
	}
	var l int = 65
	for n > 0 {
		l--
		res[l] = byte(n % 10 + 48)
		n /= 10
	}
	if l == 65 {
		l--
		res[l] = byte(48)
	}
	if isNeg {
		l--
		res[l] = byte(45)
	}
	return res[l:]
}

func bsLower(arr []int, n int) int {
	var minN, midN, maxN int
	maxN = len(arr)
	for maxN - 1 > minN {
		midN = (minN + maxN) / 2
		if arr[midN] < n {
			minN = midN
		} else {
			maxN = midN
		}
	}
	if arr[minN] >= n {
		return minN
	}
	return maxN
}

func bsLower64(arr []int64, n int64) int {
	var minN, midN, maxN int
	maxN = len(arr)
	for maxN - 1 > minN {
		midN = (minN + maxN) / 2
		if arr[midN] < n {
			minN = midN
		} else {
			maxN = midN
		}
	}
	if arr[minN] >= n {
		return minN
	}
	return maxN
}

func bsUpper(arr []int, n int) int {
	var minN, midN, maxN int
	maxN = len(arr)
	for maxN - 1 > minN {
		midN = (minN + maxN) / 2
		if arr[midN] <= n {
			minN = midN
		} else {
			maxN = midN
		}
	}
	if arr[minN] > n {
		return minN
	}
	return maxN
}

func bsUpper64(arr []int64, n int64) int {
	var minN, midN, maxN int
	maxN = len(arr)
	for maxN - 1 > minN {
		midN = (minN + maxN) / 2
		if arr[midN] <= n {
			minN = midN
		} else {
			maxN = midN
		}
	}
	if arr[minN] > n {
		return minN
	}
	return maxN
}

func max(n1, n2 int) int {
	return int(max64(int64(n1), int64(n2)))
}

func max64(n1, n2 int64) int64 {
	if n1 > n2 {
		return n1
	}
	return n2
}

func min(n1, n2 int) int {
	return int(min64(int64(n1), int64(n2)))
}

func min64(n1, n2 int64) int64 {
	if n1 < n2 {
		return n1
	}
	return n2
}

func yes(res, isUpperCase bool) bool {
	var arr [4]string = [4]string{"No", "Yes", "NO", "YES"}
	var ind int
	if res == true {
		ind = 1
	}
	if isUpperCase == true {
		ind += 2
	}
	out.WriteString(arr[ind])
	out.WriteByte(NL)
	return res
}

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) ReadByteSlice(n int) []byte {
	res := make([]byte, 0, n)
	fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) Println(v ...interface{}) {
	fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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
}

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

func zFunction(a []byte) []int {
	res := make([]int, len(a))
	l, r := 0, 0

	for i := 1; i < len(a); i++ {
		if i <= r {
			res[i] = min(r-i+1, res[i-l])
		}
		for i+res[i] < len(a) && a[res[i]] == a[i+res[i]] {
			res[i]++
		}
		if i+res[i]-1 > r {
			l = i
			r = i + res[i] - 1
		}
	}

	return res
}

func concatBytes (a ...[]byte) []byte {
	size := 0
	for _, v := range a {
		size += len(v)
	}

	res := make([]byte, size)

	size = 0
	for _, v := range a {
		size += copy(res[size:], v)
	}

	return res
}

//func findMinString(a, b []byte, mn int) []byte {
//	uh := concatBytes(b, []byte{'|'}, a, b)
//	z := zFunction(uh)
//	size := len(a)
//
//	for i := mn; i < size; i++ {
//		if a[i] > b[0] {
//			return concatBytes(a[:i], b[:i])
//		} else if a[i] < b[0] {
//			continue
//		} else {
//			k := z[size + 1 + i]
//			if k >= i - 2 {
//				return concatBytes(a[:i], b[:i])
//			} else if uh[size + 1 + i + k] < uh[k] {
//				return concatBytes(a, b)
//			} else if uh[size + 1 + i + k] > uh[k] {
//				return concatBytes(a[:i], b[:i])
//			}
//		}
//	}
//
//	return concatBytes(a, b)
//}

func getAns(a []byte, k int) []byte {
	mp := k / len(a)
	if k % len(a) != 0 {
		mp++
	}
	res := make([]byte, len(a) * mp)
	for i := 0; i < mp; i++ {
		copy(res[i * len(a):], a)
	}
	return res[:k]
}

func main() {
	io := NewIO(os.Stdin, os.Stdout)

	n, k := io.ReadPairInt()
	a := io.ReadByteSlice(n)

	uh := concatBytes(a, []byte{'|'}, a, a)
	z := zFunction(uh)

	for i := 1; i < len(a); i++ {
		//fmt.Println(i)
		if a[i] > a[0] {
			a = a[:i]
			break
		} else if a[i] < a[0] {
			continue
		} else {
			zz := z[len(a) + 1 + i]
			i = max(i, zz - 1)
			continue
		}
	}

	a = getAns(a, k)

	io.Println(string(a))
}

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) ReadByteSlice(n int) []byte {
	res := make([]byte, 0, n)
	fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) Println(v ...interface{}) {
	fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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
}

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

func zFunction(a []byte) []int {
	res := make([]int, len(a))
	l, r := 0, 0

	for i := 1; i < len(a); i++ {
		if i <= r {
			res[i] = min(r-i+1, res[i-l])
		}
		for i+res[i] < len(a) && a[res[i]] == a[i+res[i]] {
			res[i]++
		}
		if i+res[i]-1 > r {
			l = i
			r = i + res[i] - 1
		}
	}

	return res
}

func concatBytes (a ...[]byte) []byte {
	size := 0
	for _, v := range a {
		size += len(v)
	}

	res := make([]byte, size)

	size = 0
	for _, v := range a {
		size += copy(res[size:], v)
	}

	return res
}

//func findMinString(a, b []byte, mn int) []byte {
//	uh := concatBytes(b, []byte{'|'}, a, b)
//	z := zFunction(uh)
//	size := len(a)
//
//	for i := mn; i < size; i++ {
//		if a[i] > b[0] {
//			return concatBytes(a[:i], b[:i])
//		} else if a[i] < b[0] {
//			continue
//		} else {
//			k := z[size + 1 + i]
//			if k >= i - 2 {
//				return concatBytes(a[:i], b[:i])
//			} else if uh[size + 1 + i + k] < uh[k] {
//				return concatBytes(a, b)
//			} else if uh[size + 1 + i + k] > uh[k] {
//				return concatBytes(a[:i], b[:i])
//			}
//		}
//	}
//
//	return concatBytes(a, b)
//}

func getAns(a []byte, k int) []byte {
	mp := k / len(a)
	if k % len(a) != 0 {
		mp++
	}
	res := make([]byte, len(a) * mp)
	for i := 0; i < mp; i++ {
		copy(res[i * len(a):], a)
	}
	return res[:k]
}

func main() {
	io := NewIO(os.Stdin, os.Stdout)

	n, k := io.ReadPairInt()
	a := io.ReadByteSlice(n)

	uh := concatBytes(a, []byte{'|'}, a, a)
	z := zFunction(uh)

	for i := 1; i < len(a); i++ {
		//fmt.Println(i)
		if a[i] > a[0] {
			a = a[:i]
			break
		} else if a[i] < a[0] {
			continue
		} else {
			zz := z[len(a) + 1 + i]
			i = max(i, zz)
			continue
		}
	}

	a = getAns(a, k)

	io.Println(string(a))
}

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) ReadByteSlice(n int) []byte {
	res := make([]byte, 0, n)
	fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) Println(v ...interface{}) {
	fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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
}

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

func zFunction(a []byte) []int {
	res := make([]int, len(a))
	l, r := 0, 0

	for i := 1; i < len(a); i++ {
		if i <= r {
			res[i] = min(r-i+1, res[i-l])
		}
		for i+res[i] < len(a) && a[res[i]] == a[i+res[i]] {
			res[i]++
		}
		if i+res[i]-1 > r {
			l = i
			r = i + res[i] - 1
		}
	}

	return res
}

func concatBytes (a ...[]byte) []byte {
	size := 0
	for _, v := range a {
		size += len(v)
	}

	res := make([]byte, size)

	size = 0
	for _, v := range a {
		size += copy(res[size:], v)
	}

	return res
}

func findMinString(a, b []byte, mn int) []byte {
	uh := concatBytes(b, []byte{'|'}, a, b)
	z := zFunction(uh)
	size := len(a)

	for i := mn; i < size; i++ {
		if a[i] > b[0] {
			return concatBytes(a[:i], b[:i])
		} else if a[i] < b[0] {
			continue
		} else {
			k := z[size + 1 + i]
			if k >= i - 2 {
				return concatBytes(a[:i], b[:i])
			} else if uh[size + 1 + i + k] < uh[k] {
				return concatBytes(a, b)
			} else if uh[size + 1 + i + k] > uh[k] {
				return concatBytes(a[:i], b[:i])
			}
		}
	}

	return concatBytes(a, b)
}

func main() {
	io := NewIO(os.Stdin, os.Stdout)

	n, k := io.ReadPairInt()
	a := io.ReadByteSlice(n)
	a = findMinString(a, a, 1)

	for {
		//io.Println(string(a))
		a = findMinString(a, a, len(a) / 2 + 1)
		if len(a) >= k {
			a = a[:k]
			break
		}
	}

	io.Println(string(a))
}

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) ReadByteSlice(n int) []byte {
	res := make([]byte, 0, n)
	fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) Println(v ...interface{}) {
	fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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
}

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

func multiplyByte(b byte, k int) []byte {
	a := make([]byte, 0, k)
	for i := 0; i < k; i++ {
		a = append(a, b)
	}
	return a
}

func main() {
	io := NewIO(os.Stdin, os.Stdout)

	n, k := io.ReadPairInt()
	a := io.ReadByteSlice(n)

	for {
		//io.Println(string(a))

		size := len(a)
		if size == 1 {
			a = multiplyByte(a[0], k)
			break
		}

		if a[size-1] > a[0] {
			a = a[:size-1]
			continue
		}

		if a[size-1] < a[0] {
			if size >= k {
				a = a[:k]
				break
			}
			a = append(a, a...)
			continue
		}

		indexOfDiff := 1
		for ; indexOfDiff < size; indexOfDiff++ {
			if a[indexOfDiff] != a[0] {
				break
			}
		}

		if indexOfDiff == size {
			a = multiplyByte(a[0], k)
			break
		}

		if a[indexOfDiff] < a[0] {
			a = a[:size-1]
			continue
		}

		if a[indexOfDiff] > a[0] {
			if size >= k {
				a = a[:k]
				break
			}
			a = append(a, a...)
			continue
		}
	}

	io.Println(string(a))
}

package main

import (
	"fmt"
	"strings"
)

/*
https://codeforces.com/problemset/problem/1537/E1
https://codeforces.com/problemset/problem/1537/E2

本题分为简单版本和困难版本，在困难版本中，n 和 k 不超过 5e5。

输入 n (≤5000) 和 k (≤5000)，以及一个长为 n 的字符串 s，由小写字母组成。

有如下两种操作，每种操作你都可以执行任意多次：
1. 删除 s 的最后一个字符；
2. 将 s 复制一份拼在后面，即 s = s + s。

输出你能得到的所有长为 k 的字符串中，字典序最小的字符串。
 */
func samllstr(n int, str string, k int) string{
	start := 0
	end := 1
	for ; end < n ;{
		if str[end] > str[start] {
			break
		}else if str[end] < str[start] {
			end++
			continue
		}else {
			flag := 0
			i,j := start+1, end+1
			for  ;i < end && j < n; i, j = i+1, j+1 {
				if str[i] < str[j] {
					flag = 1
					break//end-1为止
				}
				if str[i] > str[j] {
					flag = 2
					break
				}
			}
			if flag == 1  {
				break
			}
			if flag == 2 {
				end = j+1
			}else {
				end= j
			}
		}
	}
	length := end-start
	return strings.Repeat(str[start:end], k/length) + str[:k%length]
}
/*
输入
8 16
dbcadabc
输出
dbcadabcdbcadabc
解释 复制一次

输入
4 5
abcd
输出
aaaaa

 */
func main() {
	var n, k int
	var str string
	fmt.Scan(&n, &k, &str)
	fmt.Printf("%v\n", samllstr(n,str, k))
}

package main

import (
	"fmt"
	"strings"
)

/*
https://codeforces.com/problemset/problem/1537/E1
https://codeforces.com/problemset/problem/1537/E2

本题分为简单版本和困难版本，在困难版本中，n 和 k 不超过 5e5。

输入 n (≤5000) 和 k (≤5000)，以及一个长为 n 的字符串 s，由小写字母组成。

有如下两种操作，每种操作你都可以执行任意多次：
1. 删除 s 的最后一个字符；
2. 将 s 复制一份拼在后面，即 s = s + s。

输出你能得到的所有长为 k 的字符串中，字典序最小的字符串。
 */
func samllstr(n int, str string, k int) string{
	start := 0
	end := 1
	for ; end < n ;{
		if str[end] > str[start] {
			break
		}else if str[end] < str[start] {
			end++
			continue
		}else {
			flag := 0
			i,j := start+1, end+1
			for  ;i < end && j < n; i, j = i+1, j+1 {
				if str[i] < str[j] {
					flag = 1
					break//end-1为止
				}
				if str[i] > str[j] {
					flag = 2
					break
				}
			}
			if flag == 1  {
				break
			}
			if flag == 2 {
				end = j+1
			}else {
				end= j
				break
			}
		}
	}
	length := end-start
	return strings.Repeat(str[start:end], k/length) + str[:k%length]
}
/*
输入
8 16
dbcadabc
输出
dbcadabcdbcadabc
解释 复制一次

输入
4 5
abcd
输出
aaaaa

 */
func main() {
	var n, k int
	var str string
	fmt.Scan(&n, &k, &str)
	fmt.Printf("%v\n", samllstr(n,str, k))
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var n, k int
	fmt.Fscan(in,&n,&k)
	var s []byte
	fmt.Fscan(in,&s)
	delta := ""
	or := ""
	for i:=len(s)-1;i>=0;i--{
		now := string(s[:i+1])
		temp := now
		if delta==""{
			delta = now
			or = temp
		}else{
			for len(now)<len(delta){
				now = now + now
			}
			now = now[:len(delta)]
			flag := false
			for j:=0;j<len(delta);j++{
				if now[j]==delta[j]{
					continue
				}
				if now[j]>delta[j]{
					flag = false
					break
				}
				if now[j]<delta[j]{
					flag = true
					break
				}
			}
			if flag{
				delta = now
				or = temp
			}
		}
	}
	for len(or)<k{
		or = or + or
	}
	fmt.Fprintln(out,or[:k])
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var n, k int
	fmt.Fscan(in,&n,&k)
	var s []byte
	fmt.Fscan(in,&s)
	delta := ""
	for i:=len(s)-1;i>=0;i--{
		now := string(s[:i+1])
		if delta==""{
			delta = now
		}else{
			for len(now)<len(delta){
				now = now + now
			}
			now = now[:len(delta)]
			flag := false
			for j:=0;j<len(delta);j++{
				if now[j]==delta[j]{
					continue
				}
				if now[j]>delta[j]{
					flag = false
					break
				}
				if now[j]<delta[j]{
					flag = true
					break
				}
			}
			if flag{
				delta = now
			}
		}
	}
	for len(delta)<k{
		delta = delta + delta
	}
	fmt.Fprintln(out,delta[:k])
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var n, k int
	fmt.Fscan(in,&n,&k)
	var s []byte
	fmt.Fscan(in,&s)
	delta := ""
	for i:=len(s)-1;i>=0;i--{
		now := string(s[:i+1])
		if delta==""{
			delta = now
		}else{
			for len(now)<len(delta){
				now = now + now
			}
			now = now[:len(delta)]
			if now<delta{
				delta = now
			}
		}
	}
	for len(delta)<k{
		delta = delta + delta
	}
	fmt.Fprintln(out,delta[:k])
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var n, k int
	fmt.Fscan(in,&n,&k)
	var s []byte
	fmt.Fscan(in,&s)
	index := -1
	for i:=0;i<len(s);i++{
		if s[i]>s[0]&&i+1<=k{
			index = i
			break
		}
	}
	if index!=-1{
		cool := s[:index]
		ret := string(cool)
		for len(ret)<k{
			ret = ret + ret
		}
		fmt.Fprintln(out,ret[:k])
	}else{
		ret := string(s)
		for len(ret)<k{
			ret = ret + ret
		}
		fmt.Fprintln(out,ret[:k])
	}
}

package main

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

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

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

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

	fmt.Println(solve(n, k, s))
}

func solve(n, k int, s string) string {

	//cafsafhat

	//baaaaa
	//14

	//xkkhaxkkhaggkgkgxkkhaxkkha

	//xkkhaxkkhaggkgkgxkkhaxkkha
	//xkkhaxkkhaggkgkgxkkhaxkkhaggkgkg

	//8 + 8
	//20

	var i int
	var found bool

	for i = 1; i < n; i++ {
		if s[0] > s[i] {
			continue

		} else if s[0] == s[i] {
			s1 := s[:i]
			lenS1 := len(s1)

			rem := n - i

			var s2 string

			if lenS1 <= rem {
				s2 = s[i: i+lenS1]

				if s1 < s2 {
					found = true
					break

				} else {
					i += lenS1 - 1
					continue
				}

			} else {
				s1 := s[: rem]

				s2 := s[i: i+rem]

				if s1 <= s2 {
					found = true
					break
				} else {
					break
				}
			}

		} else {
			found = true
			break
		}
	}

	var temp string

	if !found {
		temp = s
	} else {
		temp = s[0: i]
	}

	t := len(temp)

	d := k/t
	r := k % t

	var ans bytes.Buffer

	if r != 0 {
		for i := 0; i < d; i++ {
			ans.WriteString(temp)
		}

		for i := 0; i < r; i++ {
			ans.WriteByte(temp[i])
		}
	} else {
		for i := 0; i < d; i++ {
			ans.WriteString(temp)
		}
	}

	return ans.String()

}

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

package main

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

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

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

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

	fmt.Println(solve(n, k, s))
}

func solve(n, k int, s string) string {

	//cafsafhat

	//baaaaa
	//14

	//baaaaabaaaaa

	//cbavasdagafasac

	//cbacba

	//40
	//cbbcbacbbcbaadad cbbcbacbbcbaadad cbbcbac

	//cbbcbacbbcba

	//8 + 8
	//20

	var i int
	var found bool

	for i = 1; i < n; i++{
		if s[0] > s[i] {
			continue

		} else if s[0] == s[i] {
			s1 := s[:i]
			lenS1 := len(s1)
			t := min(lenS1, n - i)

			s2 := s[i : i + t]

			if s1 < s2 {
				found = true
				break

			} else {
				i += t - 1
				continue
			}

		} else {
			found = true
			break
		}
	}

	var temp string

	if !found {
		temp = s
	} else {
		temp = s[0: i]
	}

	t := len(temp)

	d := k/t
	r := k % t

	var ans bytes.Buffer

	if r != 0 {
		for i := 0; i < d + 1; i++ {
			ans.WriteString(temp)
		}

		for i := 0; i < (d + 1) * t - k; i++ {
			ans.WriteByte(temp[i])
		}
	} else {
		for i := 0; i < d; i++ {
			ans.WriteString(temp)
		}
	}

	return ans.String()

}

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

package main

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

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

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

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

	fmt.Println(solve(n, k, s))
}

func solve(n, k int, s string) string {

	//cafsafhat

	//baaaaa
	//14

	//baaaaabaaaaa

	//30
	//cbbcbacbvcbadad

	//cbcacbca

	//8 + 8
	//20

	var i int
	var found bool

	for i = 1; i < n; i++{
		if s[0] > s[i] {
			continue

		} else if s[0] == s[i] {
			s1 := s[:i]
			lenS1 := len(s1)
			t := min(lenS1, n - i)

			s2 := s[i : i + t]

			if s1 <= s2 {
				found = true
				break

			} else {
				i += t - 1
				continue
			}

		} else {
			found = true
			break
		}
	}

	var temp string

	if !found {
		temp = s
	} else {
		temp = s[0: i]
	}

	t := len(temp)

	d := k/t
	r := k % t

	var ans bytes.Buffer

	if r != 0 {
		for i := 0; i < d + 1; i++ {
			ans.WriteString(temp)
		}

		for i := 0; i < (d + 1) * t - k; i++ {
			ans.WriteByte(temp[i])
		}
	} else {
		for i := 0; i < d; i++ {
			ans.WriteString(temp)
		}
	}

	return ans.String()

}

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

package main

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

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

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

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

	fmt.Println(solve(n, k, s))
}

func solve(n, k int, s string) string {

	//cafsafhat

	//

	//8 + 8
	//20

	var i int
	var found bool

	for i = 1; i < n; i++{
		if s[0] >= s[i] {
			continue
		}
		found = true
		break
	}

	var temp string

	if !found {
		temp = s
	} else {
		temp = s[0: i]
	}

	t := len(temp)

	d := k/t
	r := k % t

	var ans bytes.Buffer

	if r != 0 {
		for i := 0; i < d + 1; i++ {
			ans.WriteString(temp)
		}

		for i := 0; i < (d + 1) * t - k; i++ {
			ans.WriteByte(temp[i])
		}
	} else {
		for i := 0; i < d; i++ {
			ans.WriteString(temp)
		}
	}

	return ans.String()

}

package main

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

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

func cf(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)

	fmt.Fprintln(out, n)
}

func cf1537E1(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n, k int
	var s string
	fmt.Fscan(in, &n, &k, &s)
	ss := []string{}
	for i := range s {
		ss = append(ss, s[:i+1]+s[:i+1])
	}
	sort.Strings(ss)
	s = ss[0]
	for len(s) < k {
		s += s
	}

	fmt.Fprintln(out, s[:k])
}

func cf691C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var x string
	fmt.Fscan(in, &x)
	if !strings.Contains(x, ".") {
		x += "."
	}
	x = strings.Trim(x, "0")
	idx := strings.Index(x, ".")
	e := idx - strings.IndexAny(x, "123456789")
	if e > 0 {
		e--
	}
	x = strings.Trim(x[:idx]+x[idx+1:], "0")
	if len(x) > 1 {
		x = x[:1] + "." + x[1:]
	}
	fmt.Fprint(out, x)
	if e != 0 {
		fmt.Fprint(out, "E", e)
	}
}

func cf467C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n, m, k int
	fmt.Fscan(in, &n, &m, &k)
	sums := make([]int64, n+1)
	for i := 1; i <= n; i++ {
		fmt.Fscan(in, &sums[i])
		sums[i] += sums[i-1]
	}
	f := make([]int64, n+1)
	for j := 1; j <= k; j++ {
		ff := make([]int64, n+1)
		for i := j * m; i <= n; i++ {
			ff[i] = max64(ff[i-1], sums[i]-sums[i-m]+f[i-m])
		}
		f = ff
	}

	fmt.Fprintln(out, f[n])
}

func cf1469C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
next:
	for ; t > 0; t-- {
		var n, k int
		fmt.Fscan(in, &n, &k)
		h := make([]int, n)
		for i := range h {
			fmt.Fscan(in, &h[i])
		}
		pre := []int{h[0], h[0]}
		for i := 1; i < n; i++ {
			cur := []int{max(pre[0]-k+1, h[i]), min(pre[1]+k-1, h[i]+k-1)}
			if cur[0] > cur[1] {
				fmt.Fprintln(out, "NO")
				continue next
			}
			pre = cur
		}
		if pre[0] == h[n-1] {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

func cf1060C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n, m, x int
	fmt.Fscan(in, &n, &m)
	nums1, nums2 := make([]int64, n+1), make([]int64, m+1)
	for i := 1; i <= n; i++ {
		fmt.Fscan(in, &nums1[i])
		nums1[i] += nums1[i-1]
	}
	for i := 1; i <= m; i++ {
		fmt.Fscan(in, &nums2[i])
		nums2[i] += nums2[i-1]
	}
	fmt.Fscan(in, &x)
	mins1, mins2 := make([]int64, n+1), make([]int64, m+1)
	for i := 1; i <= n; i++ {
		mins1[i] = nums1[i]
		for j := i + 1; j <= n; j++ {
			mins1[i] = min64(mins1[i], nums1[j]-nums1[j-i])
		}
	}
	for i := 1; i <= m; i++ {
		mins2[i] = nums2[i]
		for j := i + 1; j <= m; j++ {
			mins2[i] = min64(mins2[i], nums2[j]-nums2[j-i])
		}
	}
	ans := 0
	for i := 1; i <= n; i++ {
		for j := 1; j <= m; j++ {
			if mins1[i]*mins2[j] <= int64(x) && i*j > ans {
				ans = i * j
			}
		}
	}

	fmt.Fprintln(out, ans)
}

func cf1043D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n, m int
	fmt.Fscan(in, &n, &m)
	arr, preArr := make([]int, n+1), make([]int, n+1)
	var pre, cur int
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &cur)
		preArr[cur] = pre
		arr[pre], pre = cur, cur
	}
	for ; m > 1; m-- {
		pre = 0
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &cur)
			if arr[pre] != cur {
				preArr[cur] = 0
				arr[pre] = 0
			}
			pre = cur
		}
		arr[cur] = 0
	}
	ans := int64(n)
	for i := 1; i <= n; i++ {
		if arr[i] > 0 {
			cnt, id := 0, i
			for preArr[id] != 0 {
				id = preArr[id]
			}
			for arr[id] != 0 {
				arr[id], id = 0, arr[id]
				cnt++
				ans += int64(cnt)
			}
		}
	}

	fmt.Fprintln(out, ans)
}

func cf1519D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	nums1, nums2 := make([]int64, n), make([]int64, n)
	for i := range nums1 {
		fmt.Fscan(in, &nums1[i])
	}
	for i := range nums2 {
		fmt.Fscan(in, &nums2[i])
	}
	f := make([]int64, n+1)
	for i := range nums1 {
		f[i+1] = f[i] + nums1[i]*nums2[i]
	}
	ans := f[n]
	for i := range nums1 {
		for j, d, sum := i, 1, nums1[i]*nums2[i]; j-d >= 0 && j+d < n; d++ {
			sum += nums1[j-d]*nums2[j+d] + nums1[j+d]*nums2[j-d]
			ans = max64(ans, sum+f[n]-f[j+d+1]+f[j-d])
		}
		for j1, j2, d, sum := i, i+1, 0, int64(0); j1-d >= 0 && j2+d < n; d++ {
			sum += nums1[j2+d]*nums2[j1-d] + nums1[j1-d]*nums2[j2+d]
			ans = max64(ans, sum+f[n]-f[j2+d+1]+f[j1-d])
		}
	}

	fmt.Fprintln(out, ans)
}

func cf175C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	nums := make([][2]int64, n)
	for i := range nums {
		fmt.Fscan(in, &nums[i][0], &nums[i][1])
	}
	var t int
	fmt.Fscan(in, &t)
	p := make([]int64, t+2)
	p[t+1] = 1e12
	pre := int64(0)
	for i := 1; i <= t; i++ {
		fmt.Fscan(in, &p[i])
		pre, p[i] = p[i], p[i]-pre
	}
	sort.Slice(nums, func(i, j int) bool {
		return nums[i][1] < nums[j][1]
	})
	sum := int64(0)
	for i, j := 0, 1; i < len(nums); {
		sum += min64(nums[i][0], p[j]) * nums[i][1] * int64(j)
		if nums[i][0] > p[j] {
			nums[i][0] -= p[j]
			j++
		} else {
			p[j] -= nums[i][0]
			i++
		}
	}

	fmt.Fprintln(out, sum)
}

func cf494A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var s string
	fmt.Fscan(in, &s)
	sum, minSum, cnt := 0, len(s), 0
	for i := range s {
		if s[i] == '(' {
			sum++
		} else if s[i] == ')' {
			sum--
		} else {
			sum--
			minSum = sum
			cnt++
		}
		if sum < 0 {
			fmt.Fprintln(out, -1)
			return
		}
		minSum = min(minSum, sum)
	}
	if minSum < sum {
		fmt.Fprintln(out, -1)
	} else {
		fmt.Fprintln(out, strings.Repeat("1\n", cnt-1), sum+1)
	}
}

func cf1281B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	for ; n > 0; n-- {
		var s, c string
		fmt.Fscan(in, &s, &c)
		cs := []byte(s)
		j, a, b := len(s)-1, 0, 0
		for i := len(s) - 1; i >= 0; i-- {
			if cs[i] > cs[j] {
				a, b = i, j
			} else if cs[i] < cs[j] {
				j = i
			}
		}
		cs[a], cs[b] = cs[b], cs[a]
		if s = string(cs); s < c {
			fmt.Fprintln(out, s)
		} else {
			fmt.Fprintln(out, "---")
		}
	}
}

func cf605A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	nums := make([][3]int, n) // nums[0]原数字  nums[1]原下标	nums[2]排序后的下标
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &nums[i][0])
		nums[i][1] = i
	}
	sort.SliceStable(nums, func(i, j int) bool {
		return nums[i][0] < nums[j][0]
	})
	for i := range nums {
		nums[i][2] = i
	}
	sort.Slice(nums, func(i, j int) bool {
		return nums[i][1] < nums[j][1]
	})
	f := make([]int, n+1)
	for _, num := range nums {
		f[num[2]+1] = f[num[2]] + 1
	}

	fmt.Fprintln(out, n-max(f...))
}

func cf297B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n, m, k int
	fmt.Fscan(in, &n, &m, &k)
	if n > m {
		fmt.Fprintln(out, "YES")
		return
	}
	a, b := make([]int, n), make([]int, m)
	for i := range a {
		fmt.Fscan(in, &a[i])
	}
	for i := range b {
		fmt.Fscan(in, &b[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	sort.Sort(sort.Reverse(sort.IntSlice(b)))
	for i := range a {
		if a[i] > b[i] {
			fmt.Fprintln(out, "YES")
			return
		}
	}

	fmt.Fprintln(out, "NO")
}

func helan(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	nums := make([]int, n)
	for i := range nums {
		fmt.Fscan(in, &nums[i])
	}

	less, more := -1, n
	for i := 0; i < more; i++ {
		if nums[i] == 0 {
			less++
			nums[i], nums[less] = nums[less], nums[i]
		} else if nums[i] == 2 {
			more--
			nums[i], nums[more] = nums[more], nums[i]
			i--
		}
	}

	fmt.Fprintln(out, nums)
}

func cf1203D2(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var s, t string
	fmt.Fscan(in, &s, &t)
	ans := 0
	left, right := make([]int, len(t)), make([]int, len(t))
	i, j := 0, 0
	for ; i < len(s) && j < len(t); i++ {
		if s[i] == t[j] {
			left[j] = i
			j++
		}
	}
	ans = max(ans, len(s)-i)
	i, j = len(s)-1, len(t)-1
	for ; i >= 0 && j >= 0; i-- {
		if s[i] == t[j] {
			right[j] = i
			j--
		}
	}
	ans = max(ans, i+1)
	for k := 0; k < len(t)-1; k++ {
		ans = max(ans, right[k+1]-left[k]-1)
	}

	fmt.Fprintln(out, ans)

}

func cf1196D2(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var t, n, k int
	var s string
	fmt.Fscan(in, &t)
	pat := "RGB"
	for ; t > 0; t-- {
		fmt.Fscan(in, &n, &k, &s)
		ans := k
		for i := 0; i < 3; i++ {
			diff := 0
			for j := range s[:k] {
				if s[j] != pat[(i+j)%3] {
					diff++
				}
			}
			ans = min(ans, diff)
			for j := k; j < n; j++ {
				if s[j] != pat[(i+j)%3] {
					diff++
				}
				if s[j-k] != pat[(i+j-k%3)%3] {
					diff--
				}
				ans = min(ans, diff)
			}
		}

		fmt.Fprintln(out, ans)
	}
}

func cf44H(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var s string
	fmt.Fscan(in, &s)
	f := make([][10]int64, len(s))
	for i := range f[0] {
		f[0][i] = 1
	}
	for i := 1; i < len(s); i++ {
		for j := range f[i] {
			f[i][(j+int(s[i])-'0')/2] += f[i-1][j]
			if (j+int(s[i])-'0')&1 == 1 {
				f[i][(j+int(s[i])-'0'+1)/2] += f[i-1][j]
			}
		}
	}
	flag := true
	for i := range s[:len(s)-1] {
		if s[i]-s[i+1] <= 1 || s[i+1]-s[i] <= 1 {
			continue
		} else {
			flag = false
			break
		}
	}
	ans := int64(0)
	for i := range f[0] {
		ans += f[len(s)-1][i]
	}
	if flag {
		ans--
	}
	fmt.Fprintln(out, ans)
}

func cf1051D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, k int
	fmt.Fscan(in, &n, &k)
	if k == 1 {
		fmt.Fprintln(out, 2)
		return
	}
	mod := int64(998244353)
	f := make([][2]int64, k+1)
	f[1][1], f[2][0] = 2, 2
	for i := 2; i <= n; i++ {
		for j := min(k, 2*i); j >= 2; j-- {
			f[j][1] = (f[j][0]*2 + f[j][1] + f[j-1][1]) % mod
			f[j][0] = (f[j][0] + f[j-2][0] + f[j-1][1]*2) % mod
		}
	}

	fmt.Fprintln(out, (f[k][0]+f[k][1])%mod)
}

func cf1051D3(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, k int
	fmt.Fscan(in, &n, &k)
	if k == 1 {
		fmt.Fprintln(out, 2)
		return
	}
	mod := int64(998244353)
	f := make([][][2]int64, n+1)
	for i := range f {
		f[i] = make([][2]int64, k+1)
	}
	f[1][1][1], f[1][2][0] = 2, 2
	for i := 2; i <= n; i++ {
		f[i][1][1] = 2
		for j := 2; j <= k && j <= 2*i; j++ {
			f[i][j][0] = (f[i-1][j][0] + f[i-1][j-2][0] + f[i-1][j-1][1]*2) % mod
			f[i][j][1] = (f[i-1][j][0]*2 + f[i-1][j][1] + f[i-1][j-1][1]) % mod
		}
	}

	fmt.Fprintln(out, (f[n][k][0]+f[n][k][1])%mod)
}

func cf468A(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n int
	fmt.Fscan(in, &n)
	if n < 4 {
		fmt.Fprintln(out, "NO")
		return
	}
	fmt.Fprintln(out, "YES")
	if (n-4)&1 == 0 {
		fmt.Fprintln(out, "1 * 2 = 2")
		fmt.Fprintln(out, "2 * 3 = 6")
		fmt.Fprintln(out, "6 * 4 = 24")
	} else {
		fmt.Fprintln(out, "2 * 4 = 8")
		fmt.Fprintln(out, "3 * 5 = 15")
		fmt.Fprintln(out, "8 + 15 = 23")
		fmt.Fprintln(out, "23 + 1 = 24")
	}
	for i := 5 + n&1; i < n; i += 2 {
		fmt.Fprintln(out, i+1, "-", i, "= 1")
		fmt.Fprintln(out, "1 * 24 = 24")
	}
}

func cf573B(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, ans int
	fmt.Fscan(in, &n)
	arr := make([]int, n+2)
	for i := 1; i <= n; i++ {
		fmt.Fscan(in, &arr[i])
		arr[i] = min(arr[i], arr[i-1]+1)
	}
	for i := n; i >= 1; i-- {
		arr[i] = min(arr[i], arr[i+1]+1)
		ans = max(ans, arr[i])
	}

	fmt.Fprintln(out, ans)
}

func min(nums ...int) int {
	ans := nums[0]
	for _, num := range nums {
		if ans > num {
			ans = num
		}
	}
	return ans
}

func min64(nums ...int64) int64 {
	ans := nums[0]
	for _, num := range nums {
		if ans > num {
			ans = num
		}
	}
	return ans
}

func max(nums ...int) int {
	ans := nums[0]
	for _, num := range nums {
		if ans < num {
			ans = num
		}
	}
	return ans
}

func max64(nums ...int64) int64 {
	ans := nums[0]
	for _, num := range nums {
		if ans < num {
			ans = num
		}
	}
	return ans
}

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

package main

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

var (
	in   *bufio.Reader = bufio.NewReader(os.Stdin)
	n, k int
	s    string
)

func main() {
	fmt.Fscan(in, &n, &k, &s)
	// fmt.Printf("n=%d, k=%d, s=%s\n", n, k, s)
	pre := s
	for i := n - 1; i > 0; i-- {
		pre = min(pre, s[:i])
	}
	ans := ""
	for len(ans) < k {
		ans = ans + pre
	}
	fmt.Println(ans[:k])
}
func min(s1, s2 string) string {
	if s1+s1 < s2+s2 {
		return s1
	}
	return s2
}

package main

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

var _rbuf = bufio.NewReader(os.Stdin)
var _wbuf = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { _wbuf.Flush(); fmt.Fscan(_rbuf, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(_wbuf, f, a...) }

func main() {
	defer _wbuf.Flush()

	var n, k int
	var str string

	scan(&n, &k)
	scan(&str)

	for i := 1; i < n; i++ {
		if str[i:] > str {
			str = str[:i]
			break
		}
	}
	for len(str) < k {
		str += str
	}
	printf("%s\n", str[:k])
}


Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$ (and only this edge) is erased from the tree.Monocarp has given you a list of $$$n - 1$$$ pairs of numbers. He wants you to provide an example of a tree that will produce the said list if this tree exists. If such tree does not exist, say so.

The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed.

If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$) — vertices connected by an edge. Note: The numeration of edges doesn't matter for this task. Your solution will be considered correct if your tree produces the same pairs as given in the input file (possibly reordered). That means that you can print the edges of the tree you reconstructed in any order.

NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs.

package main

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

const (
	MaxN = 1024
)

var n int
var a [MaxN]int
var connected [MaxN]bool
var d [MaxN]int

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

func main() {
	inBuf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(inBuf, "%d\n", &n)
	f1 := true
	for i := 0; i < n-1; i++ {
		var v1, v2 int
		fmt.Fscanf(inBuf, "%d %d\n", &v1, &v2)
		vmin := min(v1, v2)
		vmax := v1 + v2 - vmin
		d[vmin]++
		if vmax != n {
			f1 = false
			break
		}
	}

	outBuf := bufio.NewWriter(os.Stdout)
	defer func() { outBuf.Flush() }()

	if !f1 {
		fmt.Fprintf(outBuf, "NO\n")
		return
	}

	paths := make([][]int, 0)
	for i := 1; i < n; i++ {
		if d[i] == 0 {
			continue
		}
		toAdd := make([]int, 0)
		if d[i] > 1 {
			for j := 1; j < i; j++ {
				if !connected[j] {
					toAdd = append(toAdd, j)
					connected[j] = true
					d[i]--
				}
				if d[i] == 1 {
					break
				}
			}
		}
		if d[i] == 1 {
			connected[i] = true
			toAdd = append(toAdd, i)
			paths = append(paths, toAdd)
		} else {
			fmt.Fprintf(outBuf, "NO\n")
			return
		}
	}
	fmt.Fprintf(outBuf, "YES\n")
	for i := 0; i < len(paths); i++ {
		fmt.Fprintf(outBuf, "%d %d\n", n, paths[i][0])
		for j := 0; j < len(paths[i])-1; j++ {
			fmt.Fprintf(outBuf, "%d %d\n", paths[i][j], paths[i][j+1])
		}
	}
}


Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him.Help Andrey choose people to ask. As he needs only one problem, Andrey is going to be really upset if no one comes up with a problem or if he gets more than one problem from his friends. You need to choose such a set of people that maximizes the chances of Andrey not getting upset.

The first line contains a single integer n (1 ≤ n ≤ 100) — the number of Andrey's friends. The second line contains n real numbers pi (0.0 ≤ pi ≤ 1.0) — the probability that the i-th friend can come up with a problem. The probabilities are given with at most 6 digits after decimal point.

Print a single real number — the probability that Andrey won't get upset at the optimal choice of friends. The answer will be considered valid if it differs from the correct one by at most 10 - 9.

NoteIn the first sample the best strategy for Andrey is to ask only one of his friends, the most reliable one.In the second sample the best strategy for Andrey is to ask all of his friends to come up with a problem. Then the probability that he will get exactly one problem is 0.1·0.8 + 0.9·0.2 = 0.26.

package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	p := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}
	sort.Sort(sort.Reverse(sort.Float64Slice(p)))
	var res float64 = 0.0
	var P, S float64 = 1.0, 0.0
	if p[0] == 1 {
		fmt.Println(1.0)
	} else {
		for i := 0; i < n; i++ {
			P *= (1.0 - p[i])
			S += p[i] / (1 - p[i])
			res = math.Max(res, P*S)
		}
		fmt.Printf("%0.10f\n", res)
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	p := make([]float64, n)
	for i := range p {
		fmt.Scan(&p[i])
	}
	sort.Float64s(p)
	if p[len(p)-1] >= 0.5 {
		fmt.Printf("%.11f", p[len(p)-1])
		return
	}
	var a, q float64
	q = 1
	for i := len(p) - 1; i >= 0; i-- {
		if x := a * (1 - p[i]) + p[i] * q; x > a {
			a = x
			q *= 1 - p[i]
		}
	}
	fmt.Printf("%.11f", a)
}


Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score.Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is . His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack.All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer.

The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 ≤ mi ≤ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted. The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 ≤ wi ≤ 10) is Kevin's number of wrong submissions on problem i. The last line contains two space-separated integers hs and hu (0 ≤ hs, hu ≤ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively.

Print a single integer, the value of Kevin's final score.

NoteIn the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets  of the points on each problem. So his score from solving problems is . Adding in 10·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930.

package main

import (
	"fmt"
)

func main() {
	x := [5]int{500, 1000, 1500, 2000, 2500}

	var m [5]int
	for i := 0; i < 4; i++ {
		if _, err := fmt.Scanf("%d", &m[i]); err != nil {
			return
		}
	}
	if _, err := fmt.Scanf("%d\n", &m[4]); err != nil {
		return
	}
	var w [5]int
	for i := 0; i < 4; i++ {
		if _, err := fmt.Scanf("%d", &w[i]); err != nil {
			return
		}
	}
	if _, err := fmt.Scanf("%d\n", &w[4]); err != nil {
		return
	}
	var h_s, h_u int
	if _, err := fmt.Scanf("%d %d\n", &h_s, &h_u); err != nil {
		return
	}

	score := 0
	for i := 0; i < 5; i++ {
		s1 := x[i] * 3 / 10
		s2 := x[i] - m[i]*(x[i]/250) - 50*w[i]
		if s1 > s2 {
			score += s1
		} else {
			score += s2
		}
	}
	score += 100 * h_s
	score -= 50 * h_u

	fmt.Println(score)
}

package main

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

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

	points := []int{500, 1000, 1500, 2000, 2500}

	m := make([]int, 5)
	w := make([]int, 5)
	var hS, hU int

	fmt.Fscanf(stdin, "%d%d%d%d%d\n", &m[0], &m[1], &m[2], &m[3], &m[4])
	fmt.Fscanf(stdin, "%d%d%d%d%d\n", &w[0], &w[1], &w[2], &w[3], &w[4])
	fmt.Fscanf(stdin, "%d%d\n", &hS, &hU)

	res := 0
	for i := 0; i < 5; i++ {
		v := max(points[i]*3/10, (points[i]-m[i]*points[i]/250)-50*w[i])
		// fmt.Println(v)
		res = res + v

	}
	res += hS * 100
	res -= hU * 50
	fmt.Println(res)
}

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

	return b
}

package main

import (
	"fmt"
)

func main() {
	x := [5]int{500, 1000, 1500, 2000, 2500}

	var m [5]int
	for i := 0; i < 5; i++ {
		if _, err := fmt.Scanf("%d", &m[i]); err != nil {
			return
		}
	}
	var w [5]int
	for i := 0; i < 5; i++ {
		if _, err := fmt.Scanf("%d", &w[i]); err != nil {
			return
		}
	}
	var h_s, h_u int
	if _, err := fmt.Scanf("%d %d\n", &h_s, &h_u); err != nil {
		return
	}

	score := 0
	for i := 0; i < 5; i++ {
		s1 := int(0.3 * float32(x[i]))
		s2 := int((1.0-float32(m[i])/250.0)*float32(x[i]) - float32(50*w[i]))
		if s1 > s2 {
			score += s1
		} else {
			score += s2
		}
	}
	score += 100 * h_s
	score -= 50 * h_u

	fmt.Println(score)
}

package main

import (
	"fmt"
)

func main() {
	x := [5]int{500, 1000, 1500, 2000, 2500}

	var m [5]int
	for i := 0; i < 4; i++ {
		if _, err := fmt.Scanf("%d", &m[i]); err != nil {
			return
		}
	}
	if _, err := fmt.Scanf("%d\n", &m[4]); err != nil {
		return
	}
	var w [5]int
	for i := 0; i < 4; i++ {
		if _, err := fmt.Scanf("%d", &w[i]); err != nil {
			return
		}
	}
	if _, err := fmt.Scanf("%d\n", &w[4]); err != nil {
		return
	}
	var h_s, h_u int
	if _, err := fmt.Scanf("%d %d\n", &h_s, &h_u); err != nil {
		return
	}

	score := 0
	for i := 0; i < 5; i++ {
		s1 := int(0.3 * float32(x[i]))
		s2 := int((1.0-float32(m[i])/250.0)*float32(x[i]) - float32(50*w[i]))
		if s1 > s2 {
			score += s1
		} else {
			score += s2
		}
	}
	score += 100 * h_s
	score -= 50 * h_u

	fmt.Println(score)
}