using System;
using System.Linq;
using CompLib.Util;

public class Program
{
    private int N, K;
    private string S;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        K = sc.NextInt();
        S = sc.Next();

        // 最初1回
        // 最小の文字が最後になるように切る

        // 次から
        // 最小の文字が2倍になる
        // N = 5000でも14回あれば全部最小

        char min = S.Min();

        char[] ans = new char[N];
        for (int i = 0; i < N; i++)
        {
            ans[i] = 'z';
        }

        char[] u = new char[2 * N];
        for (int i = 0; i < N; i++)
        {
            u[i] = S[i];
            u[2 * N - 1 - i] = S[i];
        }

        if (K == 1)
        {
            for (int i = 0; i <= N; i++)
            {
                var tmp = new char[N];
                for (int j = 0; j < N; j++)
                {
                    tmp[j] = u[i + j];
                }

                ChMin(ref ans, tmp);
            }

            Console.WriteLine(new string(ans));
            return;
        }

        for (int i = 0; i <= N; i++)
        {
            // 最初
            if (u[i + N - 1] != min)
            {
                continue;
            }

            char[] tmp = new char[N];
            for (int j = 0; j < N; j++)
            {
                tmp[j] = u[i + j];
            }

            int last = 0;
            for (int j = N - 1; j >= 0; j--)
            {
                if (tmp[j] == min) last++;
                else break;
            }


            // K-2回
            for (int j = 0; j < K - 2; j++)
            {
                var tmpU = new char[2 * N];
                for (int k = 0; k < N; k++)
                {
                    tmpU[j] = tmp[j];
                    tmpU[2 * N - 1 - j] = tmp[j];
                }

                if (last * 2 >= N)
                {
                    Console.WriteLine(new string(min, N));
                    return;
                }

                var next = new char[N];
                for (int k = 0; k < N; k++)
                {
                    next[k] = tmpU[k + last];
                }

                tmp = next;
                last *= 2;
            }

            if (last * 2 >= N)
            {
                Console.WriteLine(new string(min, N));
                return;
            }

            var result = new char[N];
            for (int j = 0; j < last; j++) result[j] = min;
            for (int j = 0; j < N - last; j++)
            {
                result[j + last] = tmp[N - j - 1];
            }

            ChMin(ref ans, result);
        }

        Console.WriteLine(new string(ans));
    }

    void ChMin(ref char[] s, char[] ar)
    {
        for (int i = 0; i < N; i++)
        {
            if (ar[i] < s[i])
            {
                s = ar;
                return;
            }

            if (ar[i] > s[i])
            {
                return;
            }
        }
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}