using System;
using System.Linq;
using System.Collections.Generic;

class Root
{
    static T to<T>(string str)
    {
        return (T)Convert.ChangeType(str, typeof(T));
    }

    static string cin2str()
    {
        return System.Console.ReadLine().Trim();
    }

    static string[] cin2strs()
    {
        return cin2str().Split(' ');
    }

    static T[] cin2arr<T>()
    {
        return cin2strs().Select(line => to<T>(line)).ToArray();
    }

    static void Main(string[] args)
    {
        int[] nos  = cin2arr<int>();
        string str = cin2str();
        var    n   = nos[0];
        var    k   = nos[1];
        var    s   = str;
        for (var i = 0; i < k; ++i) {
            var t   = string.Concat(s.Reverse());
            var u   = s + t;
            var dic = new List<string>();
            for (var j = 0; j <= s.Count(); ++j) {
                dic.Add(u.Substring(j, n));
            }
            dic.Sort();
            s = dic.First();
        }
        Console.WriteLine(s);
    }
}