import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class C {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();
        sc.nextLine();

        while (t-- > 0) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            sc.nextLine();
            String s = sc.nextLine();
            HashMap<Character, Integer> map = initMap();
            StringBuilder[] strs = new StringBuilder[k];

            for (int i = 0; i < k; ++i) {
                strs[i] = new StringBuilder("");
            }

            for (int i = 0; i < n; ++i) {
                map.put(
                        s.charAt(i),
                        map.get(s.charAt(i)) + 1
                );
            }

            boolean f = true;
            int letters = 0;
            for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                if (entry.getValue() % k != 0) {
                    f = false;
                } else if(entry.getValue() != 0) {
                    letters++;
                }
            }

            lab:
            if (!f) {
                int i = 0;
                int count = 0;
                boolean filled = false;
                for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                    while (entry.getValue() > 0) {
                        for (; i < strs.length;) {
                            StringBuilder str = strs[i];
                            str.append(entry.getKey());
                            entry.setValue(entry.getValue() - 1);
                            if (i < strs.length - 1) {
                                ++i;
                            } else {
                                i = 0;
                                break;
                            }
                            if (entry.getValue() == 0)
                                break;
                        }
                        ++count;
                        if (i == 0) {
                            if (count == 1) {
                                boolean flag = true;
                                for (Map.Entry<Character, Integer> entryy : map.entrySet()) {
                                    if (entryy.getKey() != strs[0].charAt(0) && entryy.getValue() > 0) {
                                        flag = false;
                                        break;
                                    }
                                }
                                StringBuilder ans = strs[0];

                                if (!flag) {
                                    for (Map.Entry<Character, Integer> entryy : map.entrySet()) {
                                        for (int j = 0; j < entryy.getValue(); ++j) {
                                            ans.append(entryy.getKey());
                                        }
                                    }
                                } else {
                                    for (int j = 0; j < entry.getValue() / k + 1; ++j) {
                                        ans.append(entry.getKey());
                                    }
                                }

                                System.out.println(ans);
                            } else {
                                System.out.println(strs[k - 1]);

                            }
                            break lab;
                        }
                    }
                }
            } else {
                StringBuilder ans = new StringBuilder();
                if(k == 1 || letters == 1 || (letters == 2 && map.get('a') == k && map.get('b') == k)) {
                    if(k == 1) {
                        for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                            if(entry.getValue() > 0) {
                                for (int j = 0; j < entry.getValue(); ++j) {
                                    ans.append(entry.getKey());
                                }
                            }
                        }
                    } else if(letters == 1) {
                        for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                            if (entry.getValue() > 0) {
                                entry.setValue(entry.getValue() - k);
                                ans.append(entry.getKey());
                                for (int j = 0; j < entry.getValue(); ++j) {
                                    ans.append(entry.getKey());
                                }
                            }
                        }
                    } else {
                        System.out.println("ab");
                    }

                } else {
                    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                        if (entry.getValue() > 0) {
                            entry.setValue(entry.getValue() - k);
                            ans.append(entry.getKey());
                            break;
                        }
                    }
                    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                        for (int i = 0; i < entry.getValue(); ++i) {
                            ans.append(entry.getKey());
                        }
                    }
                }

                System.out.println(ans);
            }
        }
    }

    private static HashMap<Character, Integer> initMap() {
        HashMap<Character, Integer> map = new HashMap<>(26);

        for (char c = 'a'; c <= 'z'; ++c) {
            map.put(c, 0);
        }

        return map;
    }

}


import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class C {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();
        sc.nextLine();

        while (t-- > 0) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            sc.nextLine();
            String s = sc.nextLine();
            HashMap<Character, Integer> map = initMap();
            StringBuilder[] strs = new StringBuilder[k];

            for (int i = 0; i < k; ++i) {
                strs[i] = new StringBuilder("");
            }

            for (int i = 0; i < n; ++i) {
                map.put(
                        s.charAt(i),
                        map.get(s.charAt(i)) + 1
                );
            }

            boolean f = true;
            int letters = 0;
            for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                if (entry.getValue() % k != 0) {
                    f = false;
                } else if(entry.getValue() != 0) {
                    letters++;
                }
            }

            lab:
            if (!f) {
                int i = 0;
                int count = 0;
                boolean filled = false;
                for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                    while (entry.getValue() > 0) {
                        for (; i < strs.length;) {
                            StringBuilder str = strs[i];
                            str.append(entry.getKey());
                            entry.setValue(entry.getValue() - 1);
                            if (i < strs.length - 1) {
                                ++i;
                            } else {
                                i = 0;
                                break;
                            }
                            if (entry.getValue() == 0)
                                break;
                        }
                        ++count;
                        if (i == 0) {
                            if (count == 1) {
                                boolean flag = true;
                                for (Map.Entry<Character, Integer> entryy : map.entrySet()) {
                                    if (entryy.getKey() != strs[0].charAt(0) && entryy.getValue() > 0) {
                                        flag = false;
                                        break;
                                    }
                                }
                                StringBuilder ans = strs[0];

                                if (!flag) {
                                    for (Map.Entry<Character, Integer> entryy : map.entrySet()) {
                                        for (int j = 0; j < entryy.getValue(); ++j) {
                                            ans.append(entryy.getKey());
                                        }
                                    }
                                } else {
                                    for (int j = 0; j < entry.getValue() / k + 1; ++j) {
                                        ans.append(entry.getKey());
                                    }
                                }

                                System.out.println(ans);
                            } else {
                                System.out.println(strs[k - 1]);

                            }
                            break lab;
                        }
                    }
                }
            } else {
                StringBuilder ans = new StringBuilder();
                if(k == 1 || letters == 1 || (letters == 2 && map.get('a') == k && map.get('b') == k)) {
                    if(k == 1) {
                        for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                            if(entry.getValue() > 0) {
                                ans.append(entry.getKey());
                            }
                        }
                    } else if(letters == 1) {
                        for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                            if (entry.getValue() > 0) {
                                entry.setValue(entry.getValue() - k);
                                ans.append(entry.getKey());
                                for (int j = 0; j < entry.getValue(); ++j) {
                                    ans.append(entry.getKey());
                                }
                            }
                        }
                    } else {
                        System.out.println("ab");
                    }

                } else {
                    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                        if (entry.getValue() > 0) {
                            entry.setValue(entry.getValue() - k);
                            ans.append(entry.getKey());
                            break;
                        }
                    }
                    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                        for (int i = 0; i < entry.getValue(); ++i) {
                            ans.append(entry.getKey());
                        }
                    }
                }

                System.out.println(ans);
            }
        }
    }

    private static HashMap<Character, Integer> initMap() {
        HashMap<Character, Integer> map = new HashMap<>(26);

        for (char c = 'a'; c <= 'z'; ++c) {
            map.put(c, 0);
        }

        return map;
    }

}


import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class C {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();
        sc.nextLine();

        while (t-- > 0) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            sc.nextLine();
            String s = sc.nextLine();
            HashMap<Character, Integer> map = initMap();
            StringBuilder[] strs = new StringBuilder[k];

            for (int i = 0; i < k; ++i) {
                strs[i] = new StringBuilder("");
            }

            for (int i = 0; i < n; ++i) {
                map.put(
                        s.charAt(i),
                        map.get(s.charAt(i)) + 1
                );
            }

            boolean f = true;
            int letters = 0;
            for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                if (entry.getValue() % k != 0) {
                    f = false;
                } else if (entry.getValue() != 0) {
                    letters++;
                }
            }

            lab:
            if (!f) {
                int i = 0;
                int count = 0;
                boolean filled = false;
                for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                    while (entry.getValue() > 0) {
                        for (; i < strs.length; ) {
                            StringBuilder str = strs[i];
                            str.append(entry.getKey());
                            entry.setValue(entry.getValue() - 1);
                            if (i < strs.length - 1) {
                                ++i;
                            } else {
                                i = 0;
                                break;
                            }
                            if (entry.getValue() == 0)
                                break;
                        }
                        ++count;
                        if (i == 0) {
                            if (count == 1) {
                                boolean flag = true;
                                for (Map.Entry<Character, Integer> entryy : map.entrySet()) {
                                    if (entryy.getKey() != strs[0].charAt(0) && entryy.getValue() > 0) {
                                        flag = false;
                                        break;
                                    }
                                }
                                StringBuilder ans = strs[0];

                                if (!flag) {
                                    if (letters == 2 && map.entrySet().stream().allMatch(e -> e.getValue() == k || e.getValue() == 0)
                                            && map.entrySet().stream().filter(e -> e.getValue() == k).count() == 1) {
                                        for (Map.Entry<Character, Integer> entryy : map.entrySet()) {
                                            if (entryy.getValue() > 0) {
                                                for (int j = 0; j < entryy.getValue() / k + entryy.getValue() % k; ++j) {
                                                    ans.append(entryy.getKey());
                                                }
                                            }
                                        }
                                    } else {
                                        for (Map.Entry<Character, Integer> entryy : map.entrySet()) {
                                            for (int j = 0; j < entryy.getValue(); ++j) {
                                                ans.append(entryy.getKey());
                                            }
                                        }
                                    }
                                } else {
                                    for (int j = 0; j < entry.getValue() / k + 1; ++j) {
                                        ans.append(entry.getKey());
                                    }
                                }

                                System.out.println(ans);
                            } else {
                                System.out.println(strs[k - 1]);

                            }
                            break lab;
                        }
                    }
                }
            } else {
                StringBuilder ans = new StringBuilder();
                if (k == 1 || letters == 1 || (letters == 2 && map.entrySet().stream().allMatch(e -> e.getValue() == k || e.getValue() == 0))) {
                    if (k == 1) {
                        for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                            if (entry.getValue() > 0) {
                                for (int j = 0; j < entry.getValue(); ++j) {
                                    ans.append(entry.getKey());
                                }
                            }
                        }
                    } else if (letters == 1) {
                        for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                            if (entry.getValue() > 0) {
                                entry.setValue(entry.getValue() / k);
                                for (int j = 0; j < entry.getValue(); ++j) {
                                    ans.append(entry.getKey());
                                }
                            }
                        }
                    } else {
                        map.entrySet().stream().filter(e -> e.getValue() == k).forEach(e ->
                                System.out.print(e.getValue()));
                        System.out.println();
                    }

                } else {
                    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                        if (entry.getValue() > 0) {
                            entry.setValue(entry.getValue() - k);
                            ans.append(entry.getKey());
                            break;
                        }
                    }
                    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                        for (int i = 0; i < entry.getValue(); ++i) {
                            ans.append(entry.getKey());
                        }
                    }
                }

                System.out.println(ans);
            }
        }
    }

    private static HashMap<Character, Integer> initMap() {
        HashMap<Character, Integer> map = new HashMap<>(26);

        for (char c = 'a'; c <= 'z'; ++c) {
            map.put(c, 0);
        }

        return map;
    }

}


import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class C {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();
        sc.nextLine();

        while (t-- > 0) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            sc.nextLine();
            String s = sc.nextLine();
            HashMap<Character, Integer> map = initMap();
            StringBuilder[] strs = new StringBuilder[k];

            for (int i = 0; i < k; ++i) {
                strs[i] = new StringBuilder("");
            }

            for (int i = 0; i < n; ++i) {
                map.put(
                        s.charAt(i),
                        map.get(s.charAt(i)) + 1
                );
            }

            boolean f = true;
            int letters = 0;
            for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                if (entry.getValue() % k != 0) {
                    f = false;
                } else if(entry.getValue() != 0) {
                    letters++;
                }
            }

            lab:
            if (!f) {
                int i = 0;
                int count = 0;
                boolean filled = false;
                for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                    while (entry.getValue() > 0) {
                        for (; i < strs.length;) {
                            StringBuilder str = strs[i];
                            str.append(entry.getKey());
                            entry.setValue(entry.getValue() - 1);
                            if (i < strs.length - 1) {
                                ++i;
                            } else {
                                i = 0;
                                break;
                            }
                            if (entry.getValue() == 0)
                                break;
                        }
                        ++count;
                        if (i == 0) {
                            if (count == 1) {
                                boolean flag = true;
                                for (Map.Entry<Character, Integer> entryy : map.entrySet()) {
                                    if (entryy.getKey() != strs[0].charAt(0) && entryy.getValue() > 0) {
                                        flag = false;
                                        break;
                                    }
                                }
                                StringBuilder ans = strs[0];

                                if (!flag) {
                                    for (Map.Entry<Character, Integer> entryy : map.entrySet()) {
                                        for (int j = 0; j < entryy.getValue(); ++j) {
                                            ans.append(entryy.getKey());
                                        }
                                    }
                                } else {
                                    for (int j = 0; j < entry.getValue() / k + 1; ++j) {
                                        ans.append(entry.getKey());
                                    }
                                }

                                System.out.println(ans);
                            } else {
                                System.out.println(strs[k - 1]);

                            }
                            break lab;
                        }
                    }
                }
            } else {
                StringBuilder ans = new StringBuilder();
                if(k == 1 || letters == 1 || (letters == 2 && map.get('a') == k && map.get('b') == k)) {
                    if(k == 1) {
                        for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                            if(entry.getValue() > 0) {
                                for (int j = 0; j < entry.getValue(); ++j) {
                                    ans.append(entry.getKey());
                                }
                            }
                        }
                    } else if(letters == 1) {
                        for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                            if (entry.getValue() > 0) {
                                entry.setValue(entry.getValue() / k);
                                for (int j = 0; j < entry.getValue(); ++j) {
                                    ans.append(entry.getKey());
                                }
                            }
                        }
                    } else {
                        System.out.println("ab");
                    }

                } else {
                    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                        if (entry.getValue() > 0) {
                            entry.setValue(entry.getValue() - k);
                            ans.append(entry.getKey());
                            break;
                        }
                    }
                    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                        for (int i = 0; i < entry.getValue(); ++i) {
                            ans.append(entry.getKey());
                        }
                    }
                }

                System.out.println(ans);
            }
        }
    }

    private static HashMap<Character, Integer> initMap() {
        HashMap<Character, Integer> map = new HashMap<>(26);

        for (char c = 'a'; c <= 'z'; ++c) {
            map.put(c, 0);
        }

        return map;
    }

}


import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class C {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();
        sc.nextLine();

        while (t-- > 0) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            sc.nextLine();
            String s = sc.nextLine();
            HashMap<Character, Integer> map = initMap();
            StringBuilder[] strs = new StringBuilder[k];

            for (int i = 0; i < k; ++i) {
                strs[i] = new StringBuilder("");
            }

            for (int i = 0; i < n; ++i) {
                map.put(
                        s.charAt(i),
                        map.get(s.charAt(i)) + 1
                );
            }

            boolean f = true;
            int letters = 0;
            for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                if (entry.getValue() % k != 0) {
                    f = false;
                } else if (entry.getValue() != 0) {
                    letters++;
                }
            }

            lab:
            if (!f) {
                int i = 0;
                int count = 0;
                boolean filled = false;
                for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                    while (entry.getValue() > 0) {
                        for (; i < strs.length; ) {
                            StringBuilder str = strs[i];
                            str.append(entry.getKey());
                            entry.setValue(entry.getValue() - 1);
                            if (i < strs.length - 1) {
                                ++i;
                            } else {
                                i = 0;
                                break;
                            }
                            if (entry.getValue() == 0)
                                break;
                        }
                        ++count;
                        if (i == 0) {
                            if (count == 1) {
                                boolean flag = true;
                                for (Map.Entry<Character, Integer> entryy : map.entrySet()) {
                                    if (entryy.getKey() != strs[0].charAt(0) && entryy.getValue() > 0) {
                                        flag = false;
                                        break;
                                    }
                                }
                                StringBuilder ans = strs[0];

                                if (!flag) {
                                    for (Map.Entry<Character, Integer> entryy : map.entrySet()) {
                                        for (int j = 0; j < entryy.getValue(); ++j) {
                                            ans.append(entryy.getKey());
                                        }
                                    }
                                } else {
                                    for (int j = 0; j < entry.getValue() / k + 1; ++j) {
                                        ans.append(entry.getKey());
                                    }
                                }

                                System.out.println(ans);
                            } else {
                                System.out.println(strs[k - 1]);

                            }
                            break lab;
                        }
                    }
                }
            } else {
                StringBuilder ans = new StringBuilder();
                if (k == 1 || letters == 1 || (letters == 2 && map.get('a') == k && map.get('b') == k)) {
                    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                        if (entry.getValue() > 0)
                            ans.append(entry.getKey());
                    }
                } else {
                    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                        if (entry.getValue() > 0) {
                            entry.setValue(entry.getValue() - k);
                            ans.append(entry.getKey());
                            break;
                        }
                    }
                    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                        for (int i = 0; i < entry.getValue(); ++i) {
                            ans.append(entry.getKey());
                        }
                    }
                }

                System.out.println(ans);
            }
        }
    }

    private static HashMap<Character, Integer> initMap() {
        HashMap<Character, Integer> map = new HashMap<>(26);

        for (char c = 'a'; c <= 'z'; ++c) {
            map.put(c, 0);
        }

        return map;
    }

}


import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class C {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();
        sc.nextLine();

        while (t-- > 0) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            sc.nextLine();
            String s = sc.nextLine();
            HashMap<Character, Integer> map = initMap();
            StringBuilder[] strs = new StringBuilder[k];

            for (int i = 0; i < k; ++i) {
                strs[i] = new StringBuilder("");
            }

            for (int i = 0; i < n; ++i) {
                map.put(
                        s.charAt(i),
                        map.get(s.charAt(i)) + 1
                );
            }

            boolean f = true;
            int letters = 0;
            for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                if (entry.getValue() % k != 0) {
                    f = false;
                } else if (entry.getValue() != 0) {
                    letters++;
                }
            }

            lab:
            if (!f) {
                int i = 0;
                int count = 0;
                boolean filled = false;
                for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                    while (entry.getValue() > 0) {
                        for (; i < strs.length; ) {
                            StringBuilder str = strs[i];
                            str.append(entry.getKey());
                            entry.setValue(entry.getValue() - 1);
                            if (i < strs.length - 1) {
                                ++i;
                            } else {
                                i = 0;
                                break;
                            }
                            if (entry.getValue() == 0)
                                break;
                        }
                        ++count;
                        if (i == 0) {
                            if (count == 1) {
                                boolean flag = true;
                                for (Map.Entry<Character, Integer> entryy : map.entrySet()) {
                                    if (entryy.getKey() != strs[0].charAt(0) && entryy.getValue() > 0) {
                                        flag = false;
                                        break;
                                    }
                                }
                                StringBuilder ans = strs[0];

                                if (!flag) {
                                    if (letters == 2 && map.entrySet().stream().filter(e -> e.getValue() != 0).count() == 1) {
                                        for (Map.Entry<Character, Integer> entryy : map.entrySet()) {
                                            if (entryy.getValue() > 0) {
                                                for (int j = 0; j < entryy.getValue() / k + 1; ++j) {
                                                    ans.append(entryy.getKey());
                                                }
                                            }
                                        }
                                    } else {
                                        for (Map.Entry<Character, Integer> entryy : map.entrySet()) {
                                            for (int j = 0; j < entryy.getValue(); ++j) {
                                                ans.append(entryy.getKey());
                                            }
                                        }
                                    }
                                } else {
                                    for (int j = 0; j < entry.getValue() / k + 1; ++j) {
                                        ans.append(entry.getKey());
                                    }
                                }

                                System.out.println(ans);
                            } else {
                                System.out.println(strs[k - 1]);

                            }
                            break lab;
                        }
                    }
                }
            } else {
                StringBuilder ans = new StringBuilder();
                if (k == 1 || letters == 1 || (letters == 2 && map.entrySet().stream().allMatch(e -> e.getValue() == k || e.getValue() == 0))) {
                    if (k == 1) {
                        for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                            if (entry.getValue() > 0) {
                                for (int j = 0; j < entry.getValue(); ++j) {
                                    ans.append(entry.getKey());
                                }
                            }
                        }
                    } else if (letters == 1) {
                        for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                            if (entry.getValue() > 0) {
                                entry.setValue(entry.getValue() / k);
                                for (int j = 0; j < entry.getValue(); ++j) {
                                    ans.append(entry.getKey());
                                }
                            }
                        }
                    } else {
                        map.entrySet().stream().filter(e -> e.getValue() == k).forEach(e ->
                                System.out.print(e.getKey()));
                    }

                } else {
                    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                        if (entry.getValue() > 0) {
                            entry.setValue(entry.getValue() - k);
                            ans.append(entry.getKey());
                            break;
                        }
                    }
                    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                        for (int i = 0; i < entry.getValue(); ++i) {
                            ans.append(entry.getKey());
                        }
                    }
                }

                System.out.println(ans);
            }
        }
    }

    private static HashMap<Character, Integer> initMap() {
        HashMap<Character, Integer> map = new HashMap<>(26);

        for (char c = 'a'; c <= 'z'; ++c) {
            map.put(c, 0);
        }

        return map;
    }

}


import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class C {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();
        sc.nextLine();

        while (t-- > 0) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            sc.nextLine();
            String s = sc.nextLine();
            HashMap<Character, Integer> map = initMap();
            StringBuilder[] strs = new StringBuilder[k];

            for (int i = 0; i < k; ++i) {
                strs[i] = new StringBuilder("");
            }

            for (int i = 0; i < n; ++i) {
                map.put(
                        s.charAt(i),
                        map.get(s.charAt(i)) + 1
                );
            }

            boolean f = true;
            int letters = 0;
            for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                if (entry.getValue() % k != 0) {
                    f = false;
                } else if(entry.getValue() != 0) {
                    letters++;
                }
            }

            lab:
            if (!f) {
                int i = 0;
                int count = 0;
                boolean filled = false;
                for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                    while (entry.getValue() > 0) {
                        for (; i < strs.length;) {
                            StringBuilder str = strs[i];
                            str.append(entry.getKey());
                            entry.setValue(entry.getValue() - 1);
                            if (i < strs.length - 1) {
                                ++i;
                            } else {
                                i = 0;
                                break;
                            }
                            if (entry.getValue() == 0)
                                break;
                        }
                        ++count;
                        if (i == 0) {
                            if (count == 1) {
                                boolean flag = true;
                                for (Map.Entry<Character, Integer> entryy : map.entrySet()) {
                                    if (entryy.getKey() != strs[0].charAt(0) && entryy.getValue() > 0) {
                                        flag = false;
                                        break;
                                    }
                                }
                                StringBuilder ans = strs[0];

                                if (!flag) {
                                    for (Map.Entry<Character, Integer> entryy : map.entrySet()) {
                                        for (int j = 0; j < entryy.getValue(); ++j) {
                                            ans.append(entryy.getKey());
                                        }
                                    }
                                } else {
                                    for (int j = 0; j < entry.getValue() / k + 1; ++j) {
                                        ans.append(entry.getKey());
                                    }
                                }

                                System.out.println(ans);
                            } else {
                                System.out.println(strs[k - 1]);

                            }
                            break lab;
                        }
                    }
                }
            } else {
                StringBuilder ans = new StringBuilder();
                if(letters == 1 || (letters == 2 && map.get('a') == k && map.get('b') == k)) {
                    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                        for (int i = 0; i < entry.getValue() / k; ++i) {
                            ans.append(entry.getKey());
                        }
                    }
                } else {
                    for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                        for (int i = 0; i < entry.getValue(); ++i) {
                            ans.append(entry.getKey());
                        }
                    }
                }

                System.out.println(ans);
            }
        }
    }

    private static HashMap<Character, Integer> initMap() {
        HashMap<Character, Integer> map = new HashMap<>(26);

        for (char c = 'a'; c <= 'z'; ++c) {
            map.put(c, 0);
        }

        return map;
    }

}


import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class C {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();
        sc.nextLine();

        while (t-- > 0) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            sc.nextLine();
            String s = sc.nextLine();
            HashMap<Character, Integer> map = initMap();
            StringBuilder[] strs = new StringBuilder[k];

            for (int i = 0; i < k; ++i) {
                strs[i] = new StringBuilder("");
            }

            for (int i = 0; i < n; ++i) {
                map.put(
                        s.charAt(i),
                        map.get(s.charAt(i)) + 1
                );
            }

            boolean f = true;
            int letters = 0;
            for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                if (entry.getValue() % k != 0) {
                    f = false;
                }
                if (entry.getValue() != 0) {
                    letters++;
                }
            }

            lab:
            if (!f) {
                int i = 0;
                int count = 0;
                boolean filled = false;
                for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                    while (entry.getValue() > 0) {
                        for (; i < strs.length; ) {
                            StringBuilder str = strs[i];
                            str.append(entry.getKey());
                            entry.setValue(entry.getValue() - 1);
                            if (i < strs.length - 1) {
                                ++i;
                            } else {
                                i = 0;
                                break;
                            }
                            if (entry.getValue() == 0)
                                break;
                        }
                        ++count;
                        if (i == 0) {
                            if (count == 1) {
                                boolean flag = true;
                                for (Map.Entry<Character, Integer> entryy : map.entrySet()) {
                                    if (entryy.getKey() != strs[0].charAt(0) && entryy.getValue() > 0) {
                                        flag = false;
                                        break;
                                    }
                                }
                                StringBuilder ans = strs[0];

                                if (!flag) {
                                    if (letters == 2 && map.entrySet().stream().filter(e -> e.getValue() != 0).count() == 1) {
                                        for (Map.Entry<Character, Integer> entryy : map.entrySet()) {
                                            if (entryy.getValue() > 0) {
                                                for (int j = 0; j < entryy.getValue() / k + 1; ++j) {
                                                    ans.append(entryy.getKey());
                                                }
                                            }
                                        }
                                    } else {
                                        for (Map.Entry<Character, Integer> entryy : map.entrySet()) {
                                            for (int j = 0; j < entryy.getValue(); ++j) {
                                                ans.append(entryy.getKey());
                                            }
                                        }
                                    }
                                } else {
                                    for (int j = 0; j < entry.getValue() / k + 1; ++j) {
                                        ans.append(entry.getKey());
                                    }
                                }

                                System.out.println(ans);
                            } else {
                                System.out.println(strs[k - 1]);

                            }
                            break lab;
                        }
                    }
                }
            } else {
                StringBuilder ans = new StringBuilder();
                if (k == 1 || letters == 1 || (letters == 2 && map.entrySet().stream().allMatch(e -> e.getValue() == k || e.getValue() == 0))) {
                    if (k == 1) {
                        for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                            if (entry.getValue() > 0) {
                                for (int j = 0; j < entry.getValue(); ++j) {
                                    ans.append(entry.getKey());
                                }
                            }
                        }
                    } else if (letters == 1) {
                        for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                            if (entry.getValue() > 0) {
                                entry.setValue(entry.getValue() / k);
                                for (int j = 0; j < entry.getValue(); ++j) {
                                    ans.append(entry.getKey());
                                }
                            }
                        }
                    } else {
                        map.entrySet().stream().filter(e -> e.getValue() == k).forEach(e ->
                                System.out.print(e.getKey()));
                    }

                } else {
                    if(letters == 2 && map.entrySet().stream().min((a, b) -> a.getKey() > b.getKey() ? 1 : 0).get().getValue() == k) {
                        for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                            if (entry.getValue() > 0) {
                                entry.setValue(entry.getValue() - k);
                                ans.append(entry.getKey());
                                break;
                            }
                        }
                        for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                            for (int i = 0; i < entry.getValue() / k; ++i) {
                                ans.append(entry.getKey());
                            }
                        }
                    } else {
                        for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                            if (entry.getValue() > 0) {
                                entry.setValue(entry.getValue() - k);
                                ans.append(entry.getKey());
                                break;
                            }
                        }
                        for (Map.Entry<Character, Integer> entry : map.entrySet()) {
                            for (int i = 0; i < entry.getValue(); ++i) {
                                ans.append(entry.getKey());
                            }
                        }
                    }

                }

                System.out.println(ans);
            }
        }
    }

    private static HashMap<Character, Integer> initMap() {
        HashMap<Character, Integer> map = new HashMap<>(26);

        for (char c = 'a'; c <= 'z'; ++c) {
            map.put(c, 0);
        }

        return map;
    }

}


import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class C {

	public static void main(String[] args) {

		Scanner nik = new Scanner(System.in);
		int t = nik.nextInt();

		while (t-- > 0) {

			int n = nik.nextInt();
			int k = nik.nextInt();
			char[] c = nik.next().toCharArray();
			HashSet<Character> ht = new HashSet<>();

			for (int i = 0; i < n; i++) {
				ht.add(c[i]);
			}
			Arrays.sort(c);
			if (ht.size() > 2) {

				String[] s = new String[k];

				for (int i = 0; i < k; i++) {
					s[i] = c[i] + "";
				}
				StringBuilder st = new StringBuilder(s[0]);
				for (int i = k; i < n; i++) {
					st.append(c[i] + "");
				}
				s[0] = st.toString();
				Arrays.sort(s);
				System.out.println(s[k - 1]);
			} else {

				StringBuilder[] s = new StringBuilder[k];
				for (int i = 0; i < k; i++) {
					s[i] = new StringBuilder();
				}
				int idx = 0;
				while (idx < n) {

					for (int i = 0; i < k && idx < n; idx++, i++) {
						s[i].append(c[idx]);
					}

				}
				String[] s1 = new String[k];
				for (int i = 0; i < k; i++) {
					s1[i] = s[i].toString();
				}
				Arrays.sort(s1);
				// for (int i = 0; i < s1.length; i++) {
				// System.out.print(s1[i] + " ");
				// }
				// System.out.println();
				System.out.println(s1[k - 1]);
			}
		}

	}

}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class C {

	public static void main(String[] args) {

		Scanner nik = new Scanner(System.in);
		int t = nik.nextInt();

		while (t-- > 0) {

			int n = nik.nextInt();
			int k = nik.nextInt();
			char[] c = nik.next().toCharArray();
			HashSet<Character> ht = new HashSet<>();

			for (int i = 0; i < n; i++) {
				ht.add(c[i]);
			}
			Arrays.sort(c);
			if (k == n - 1) {
				System.out.println(c[n - 1]);
			} else if (ht.size() > 2 || (k < n - 1 && c[k] != c[n - 1])) {

				String[] s = new String[k];

				for (int i = 0; i < k; i++) {
					s[i] = c[i] + "";
				}

				int res1 = n - k;
				int idx = 0;

				Arrays.sort(s);

				StringBuilder st = new StringBuilder(s[0]);
				for (int i = k; i < n; i++) {
					st.append(c[i] + "");
				}
				s[0] = st.toString();
				Arrays.sort(s);
				System.out.println(s[k - 1]);
			} else {

				StringBuilder[] s = new StringBuilder[k];
				for (int i = 0; i < k; i++) {
					s[i] = new StringBuilder();
				}
				int idx = 0;
				while (idx < n) {

					for (int i = 0; i < k && idx < n; idx++, i++) {
						s[i].append(c[idx]);
					}

				}
				String[] s1 = new String[k];
				for (int i = 0; i < k; i++) {
					s1[i] = s[i].toString();
				}
				Arrays.sort(s1);

				System.out.println(s1[k - 1]);
			}
		}

	}

}


import java.util.Arrays;
import java.util.Scanner;

public class C {

	public static void main(String[] args) {

		Scanner nik = new Scanner(System.in);
		int t = nik.nextInt();
		StringBuilder sb = new StringBuilder();
		while (t-- > 0) {
			int n = nik.nextInt();
			int k = nik.nextInt();
			char[] c = nik.next().toCharArray();
			Arrays.sort(c);
			StringBuilder[] st = new StringBuilder[k];
			for (int i = 0; i < k; i++) {
				st[i] = new StringBuilder();
			}
			if (k == 1) {
				StringBuilder st1 = new StringBuilder();
				for (int i = 0; i < n; i++) {
					st1.append(c[i]);
				}
				System.out.println(st1);
			} else if (c[0] != c[k - 1]) {
				System.out.println(c[k - 1]);
			} else if (c[k] == c[n - 1]) {
				int idx = 0;

				while (idx < n) {

					for (int i = 0; i < k && idx < n; i++, idx++) {

						st[i].append(c[idx]);
					}
				}

			} else {

				for (int i = 0; i < k; i++) {
					st[i].append(c[i]);
				}
				for (int i = k; i < n; i++) {
					st[0].append(c[i]);
				}
			}
			String[] s = new String[k];
			for (int i = 0; i < k; i++) {
				s[i] = st[i].toString();
			}
			Arrays.sort(s);
			System.out.println(s[k - 1]);
		}
		System.out.println(sb);
	}

}


import java.util.Arrays;
import java.util.Scanner;

public class C {

	public static void main(String[] args) {

		Scanner nik = new Scanner(System.in);
		int t = nik.nextInt();
		StringBuilder sb = new StringBuilder();
		while (t-- > 0) {
			int n = nik.nextInt();
			int k = nik.nextInt();
			char[] c = nik.next().toCharArray();
			Arrays.sort(c);
			StringBuilder[] st = new StringBuilder[k];
			for (int i = 0; i < k; i++) {
				st[i] = new StringBuilder();
			}

			if (c[0] != c[k - 1]) {
				System.out.println(c[k - 1]);
			} else if (k < n && c[k] == c[n - 1]) {
				int idx = 0;

				while (idx < n) {
					for (int i = 0; i < k && idx < n; i++, idx++) {
						st[i].append(c[idx]);
					}
				}

			} else {

				for (int i = 0; i < k; i++) {
					st[i].append(c[i]);
				}
				for (int i = k; i < n; i++) {
					st[0].append(c[i]);
				}
			}
			System.out.println(st[0]);
		}
		System.out.println(sb);
	}

}


import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class C {

	public static void main(String[] args) {

		Scanner nik = new Scanner(System.in);
		int t = nik.nextInt();

		while (t-- > 0) {

			int n = nik.nextInt();
			int k = nik.nextInt();
			char[] c = nik.next().toCharArray();
			HashSet<Character> ht = new HashSet<>();

			for (int i = 0; i < n; i++) {
				ht.add(c[i]);
			}
			Arrays.sort(c);
			if (ht.size() > k) {

				String[] s = new String[k];

				for (int i = 0; i < k; i++) {
					s[i] = c[i] + "";
				}
				StringBuilder st = new StringBuilder(s[0]);
				for (int i = k; i < n; i++) {
					st.append(c[i] + "");
				}
				s[0] = st.toString();
				Arrays.sort(s);
				System.out.println(s[k - 1]);
			} else {

				StringBuilder[] s = new StringBuilder[k];
				for (int i = 0; i < k; i++) {
					s[i] = new StringBuilder();
				}
				int idx = 0;
				while (idx < n) {

					for (int i = 0; i < k && idx < n; idx++, i++) {
						s[i].append(c[idx]);
					}

				}
				String[] s1 = new String[k];
				for (int i = 0; i < k; i++) {
					s1[i] = s[i].toString();
				}
				Arrays.sort(s1);
				System.out.println(s1[k - 1]);
			}
		}

	}

}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class C {

	public static void main(String[] args) {

		Scanner nik = new Scanner(System.in);
		int t = nik.nextInt();

		while (t-- > 0) {

			int n = nik.nextInt();
			int k = nik.nextInt();
			char[] c = nik.next().toCharArray();
			HashSet<Character> ht = new HashSet<>();

			for (int i = 0; i < n; i++) {
				ht.add(c[i]);
			}
			Arrays.sort(c);
			if (k == n) {
				System.out.println(c[n - 1]);
			} else if (ht.size() > 2 || (k < n - 1 && c[k] != c[n - 1])) {

				String[] s = new String[k];

				for (int i = 0; i < k; i++) {
					s[i] = c[i] + "";
				}

				int res1 = n - k;
				int idx = 0;

				Arrays.sort(s);

				StringBuilder st = new StringBuilder(s[0]);
				for (int i = k; i < n; i++) {
					st.append(c[i] + "");
				}
				s[0] = st.toString();
				Arrays.sort(s);
				System.out.println(s[k - 1]);
			} else {

				StringBuilder[] s = new StringBuilder[k];
				for (int i = 0; i < k; i++) {
					s[i] = new StringBuilder();
				}
				int idx = 0;
				while (idx < n) {

					for (int i = 0; i < k && idx < n; idx++, i++) {
						s[i].append(c[idx]);
					}

				}
				String[] s1 = new String[k];
				for (int i = 0; i < k; i++) {
					s1[i] = s[i].toString();
				}
				Arrays.sort(s1);

				System.out.println(s1[k - 1]);
			}
		}

	}

}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class C {

	public static void main(String[] args) {

		Scanner nik = new Scanner(System.in);
		int t = nik.nextInt();

		while (t-- > 0) {

			int n = nik.nextInt();
			int k = nik.nextInt();
			char[] c = nik.next().toCharArray();
			HashSet<Character> ht = new HashSet<>();

			for (int i = 0; i < n; i++) {
				ht.add(c[i]);
			}
			Arrays.sort(c);
			if (k == n - 1) {
				System.out.println(c[n - 1]);
			} else if (ht.size() > 2 || c[k] != c[n - 1]) {

				String[] s = new String[k];

				for (int i = 0; i < k; i++) {
					s[i] = c[i] + "";
				}

				int res1 = n - k;
				int idx = 0;

				Arrays.sort(s);

				StringBuilder st = new StringBuilder(s[0]);
				for (int i = k; i < n; i++) {
					st.append(c[i] + "");
				}
				s[0] = st.toString();
				Arrays.sort(s);
				System.out.println(s[k - 1]);
			} else {

				StringBuilder[] s = new StringBuilder[k];
				for (int i = 0; i < k; i++) {
					s[i] = new StringBuilder();
				}
				int idx = 0;
				while (idx < n) {

					for (int i = 0; i < k && idx < n; idx++, i++) {
						s[i].append(c[idx]);
					}

				}
				String[] s1 = new String[k];
				for (int i = 0; i < k; i++) {
					s1[i] = s[i].toString();
				}
				Arrays.sort(s1);

				System.out.println(s1[k - 1]);
			}
		}

	}

}


import java.util.Arrays;
import java.util.Scanner;

public class C {

	public static void main(String[] args) {

		Scanner nik = new Scanner(System.in);
		int t = nik.nextInt();
		StringBuilder sb = new StringBuilder();
		while (t-- > 0) {
			int n = nik.nextInt();
			int k = nik.nextInt();
			char[] c = nik.next().toCharArray();
			Arrays.sort(c);
			StringBuilder[] st = new StringBuilder[k];
			for (int i = 0; i < k; i++) {
				st[i] = new StringBuilder();
			}
			if (k == 1) {
				StringBuilder st1 = new StringBuilder();
				for (int i = 0; i < n; i++) {
					st1.append(c[i]);
				}
				System.out.println(st1);
			} else if (c[0] != c[k - 1]) {
				System.out.println(c[k - 1]);
			} else if (k < n && c[k] == c[n - 1]) {
				int idx = 0;

				while (idx < n) {

					for (int i = 0; i < k && idx < n; i++, idx++) {

						st[i].append(c[idx]);
					}
				}

			} else {

				for (int i = 0; i < k; i++) {
					st[i].append(c[i]);
				}
				for (int i = k; i < n; i++) {
					st[0].append(c[i]);
				}
			}
			System.out.println(st[0]);
		}
		System.out.println(sb);
	}

}


import java.util.Arrays;
import java.util.Scanner;

public class C {

	public static void main(String[] args) {

		Scanner nik = new Scanner(System.in);
		int t = nik.nextInt();
		StringBuilder sb = new StringBuilder();
		while (t-- > 0) {
			int n = nik.nextInt();
			int k = nik.nextInt();
			char[] c = nik.next().toCharArray();
			Arrays.sort(c);
			StringBuilder[] st = new StringBuilder[k];
			for (int i = 0; i < k; i++) {
				st[i] = new StringBuilder();
			}
			if (k == 1) {
				StringBuilder st1 = new StringBuilder();
				for (int i = 0; i < n; i++) {
					st1.append(c[i]);
				}
				System.out.println(st1);
			} else if (c[0] != c[k - 1]) {
				System.out.println(c[k - 1]);
			} else if (k < n && c[k] == c[n - 1]) {
				int idx = 0;

				while (idx < n) {

					for (int i = 0; i < k && idx < n; i++, idx++) {

						st[i].append(c[idx]);
					}
				}

			} else {

				for (int i = 0; i < k; i++) {
					st[i].append(c[i]);
				}
				for (int i = k; i < n; i++) {
					st[0].append(c[i]);
				}
			}
			String[] s = new String[k];
			for (int i = 0; i < k; i++) {
				s[i] = st[i].toString();
			}
			Arrays.sort(s);
			System.out.println(s[k - 1]);
		}
		System.out.println(sb);
	}

}


import java.util.*;
public class C638_PC {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		while(t-->0)
		{
			int n = in.nextInt();
			int k = in.nextInt();in.nextLine();
			char[] arr = in.nextLine().toCharArray();
			Arrays.sort(arr);
			StringBuilder cur = new StringBuilder();
			cur.append(""+arr[0]);
			if(arr[0]!=arr[k-1])
			{
				System.out.println(arr[k-1]);
				continue;
			}
			if(k>=n)
			{
				System.out.println(cur);
				continue;
			}
			if(arr[k]==arr[n-1])
			{
				for(int i =0;i<(n-k+k-1)/k;i++)
				{
					cur.append(arr[n-1]);
				}
				System.out.println(cur);
				continue;
			}

			for(int i = k;i<n;i++)
			{
				cur.append(arr[i]);
			}

			System.out.println(cur);

		}
	}

}


import java.util.*;
public class C638_PC {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		while(t-->0)
		{
			int n = in.nextInt();
			int k = in.nextInt();in.nextLine();
			char[] arr = in.nextLine().toCharArray();
			Arrays.sort(arr);
			String ans = ""+arr[0];
			StringBuilder cur = new StringBuilder();
			cur.append(ans);
			int repeats = 0;
			for(int i =1;i<k;i++)
			{
				if((""+arr[i]).compareTo(ans)>0)
				{
					ans = ""+arr[i];
				}
				else if((""+arr[i]).equals(""+arr[0]))
				{
					repeats++;
				}
			}
			//System.out.println(ans+" "+cur);
			if(!ans.equals(""+arr[0]))
			{
				System.out.println(ans);
				continue;
			}
			for(int i = k;i<n;i++)
			{
				cur.append(arr[i]);
			}
			char last = cur.charAt(cur.length()-1);
			//System.out.println(last+": "+ repeats+" - "+cur);
			String ret = cur.toString();
			for(int i =cur.length()-2;i>=-1;i--)
			{
				//System.out.println(i+" - "+cur.charAt(i));
				if(i==-1||i<=cur.length()-2-repeats||cur.charAt(i)!=last)
				{
					ret = cur.substring(0,i+2);
					break;
				}
			}

			System.out.println(ret);
		}
	}

}


import java.util.*;
public class C638_PC {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		while(t-->0)
		{
			int n = in.nextInt();
			int k = in.nextInt();in.nextLine();
			char[] arr = in.nextLine().toCharArray();
			Arrays.sort(arr);
			String ans = ""+arr[0];
			StringBuilder cur = new StringBuilder();
			cur.append(ans);
			int repeats = 0;
			for(int i =1;i<k;i++)
			{
				if((""+arr[i]).compareTo(ans)>0)
				{
					ans = ""+arr[i];
				}
				else if((""+arr[i]).equals(""+arr[0]))
				{
					repeats++;
				}
			}
			//System.out.println(ans+" "+cur);
			if(!ans.equals(""+arr[0]))
			{
				System.out.println(ans);
				continue;
			}
			if(k>=n)
			{
				System.out.println(cur);
				continue;
			}
			if(arr[k]==arr[n-1])
			{
				cur.append(arr[k]);
				for(int i =k+1;i<n-repeats;i++)
				{
					cur.append(arr[i]);
				}
				System.out.println(cur);
				continue;
			}
			for(int i = k;i<n;i++)
			{
				cur.append(arr[i]);
			}
			char last = cur.charAt(cur.length()-1);
			//System.out.println(last+": "+ repeats+" - "+cur);

			System.out.println(cur);

		}
	}

}


import java.util.*;
public class C638_PC {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		while(t-->0)
		{
			int n = in.nextInt();
			int k = in.nextInt();in.nextLine();
			char[] arr = in.nextLine().toCharArray();
			Arrays.sort(arr);
			String ans = ""+arr[0];
			StringBuilder cur = new StringBuilder();
			cur.append(ans);
			int repeats = 0;
			for(int i =1;i<k;i++)
			{
				if((""+arr[i]).compareTo(ans)>0)
				{
					ans = ""+arr[i];
				}
				else if((""+arr[i]).equals(""+arr[0]))
				{
					repeats++;
				}
			}
			//System.out.println(ans+" "+cur);
			if(!ans.equals(""+arr[0]))
			{
				System.out.println(ans);
				continue;
			}
			for(int i = k;i<n;i++)
			{
				cur.append(arr[i]);
			}
			char last = cur.charAt(cur.length()-1);
			//System.out.println(last+": "+ repeats);
			String ret = cur.toString();
			for(int i =cur.length()-2;i>=0;i--)
			{
				//System.out.println(i+" - "+cur.charAt(i));
				if(i==0||i<=cur.length()-2-repeats||cur.charAt(i)!=last)
				{
					ret = cur.substring(0,i+2);
					break;
				}
			}

			System.out.println(ret);
		}
	}

}


import java.util.*;
public class C638_PC {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		while(t-->0)
		{
			int n = in.nextInt();
			int k = in.nextInt();in.nextLine();
			char[] arr = in.nextLine().toCharArray();
			Arrays.sort(arr);
			String ans = ""+arr[0];
			StringBuilder cur = new StringBuilder();
			cur.append(ans);
			int repeats = 0;
			for(int i =1;i<k;i++)
			{
				if((""+arr[i]).compareTo(ans)>0)
				{
					ans = ""+arr[i];
				}
				else if((""+arr[i]).equals(""+arr[0]))
				{
					repeats++;
				}
			}
			//System.out.println(ans+" "+cur);
			if(!ans.equals(""+arr[0]))
			{
				System.out.println(ans);
				continue;
			}
			if(arr[k]==arr[n-1])
			{
				cur.append(arr[k]);
				for(int i =k+1;i<n-repeats;i++)
				{
					cur.append(arr[i]);
				}
				System.out.println(cur);
				continue;
			}
			for(int i = k;i<n;i++)
			{
				cur.append(arr[i]);
			}
			char last = cur.charAt(cur.length()-1);
			//System.out.println(last+": "+ repeats+" - "+cur);

			System.out.println(cur);

		}
	}

}


import java.util.*;
public class C638_PC {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int t = in.nextInt();
		while(t-->0)
		{
			int n = in.nextInt();
			int k = in.nextInt();in.nextLine();
			char[] arr = in.nextLine().toCharArray();
			Arrays.sort(arr);
			StringBuilder cur = new StringBuilder();
			cur.append(""+arr[0]);
			if(arr[0]!=arr[k-1])
			{
				System.out.println(arr[k-1]);
				continue;
			}
			if(k>=n)
			{
				System.out.println(cur);
				continue;
			}
			if(arr[k]==arr[n-1])
			{
				cur.append(arr[k]);
				for(int i =k+1;i<=n-k;i++)
				{
					cur.append(arr[i]);
				}
				System.out.println(cur);
				continue;
			}

			for(int i = k;i<n;i++)
			{
				cur.append(arr[i]);
			}

			System.out.println(cur);

		}
	}

}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.InputMismatchException;

public class B {
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		InputReader s = new InputReader(System.in);
		PrintWriter p = new PrintWriter(System.out);
		int t = s.nextInt();
		while (t-- > 0) {
			int n = s.nextInt();
			int k = s.nextInt();
			String str = s.nextLine();
			char[] arr = str.toCharArray();
			int[] freq = new int[26];
			for (int i = 0; i < n; i++) {
				freq[arr[i] - 'a']++;
			}
			int flag = 0;
			ArrayList<pair> list = new ArrayList<>();
			for (int i = 0; i < 26; i++) {
				if (freq[i] > 0) {
					pair temp = new pair(i, freq[i]);
					list.add(temp);
				}
			}
			if (list.size() == 1) {
				StringBuilder ans = new StringBuilder();
				for (int i = 0; i < list.get(0).y / k; i++) {
					ans.append((char) (list.get(0).x + 'a'));
				}
				if (list.get(0).y % k > 0)
					ans.append((char) (list.get(0).x + 'a'));
				p.println(ans.toString());
				continue;
			}
			int mini = 0;
			for (int i = 0; i < list.size(); i++) {
				pair temp = list.get(i);
				if (temp.y % k == 0)
					continue;
				else {
					flag = 1;
					mini = i;
					break;
				}
			}
			if (flag == 0) {
				StringBuilder ans = new StringBuilder();
				for (int i = 0; i < list.size(); i++) {
					pair temp = list.get(i);
					int val = list.get(i).y / k;
					char ch = (char) (temp.x + 'a');

					for (int j = 0; j < val; j++) {
						ans.append(ch);
					}
				}
				p.println(ans.toString());
				continue;
			}
			if (mini == 0) {
				p.println((char) (list.get(1).x + 'a'));
				continue;
			}
			StringBuilder ans = new StringBuilder();
			ans.append((char) (list.get(0).x + 'a'));
			for (int i = 1; i < list.size(); i++) {
				pair temp = list.get(i);
				int val = list.get(i).y;
				char ch = (char) (temp.x + 'a');

				for (int j = 0; j < val; j++) {
					ans.append(ch);
				}
			}
			p.println(ans.toString());
		}
		p.flush();
		p.close();
	}

	public static long GCD(long a, long b) {
		if (a == 0)
			return b;
		return GCD(b % a, a);
	}

	public static long LCM(long a, long b) {
		return (a * b) / GCD(a, b);
	}

	static class pair implements Comparable<pair> {
		Integer x, y;

		pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public int compareTo(pair o) {
			int result = x.compareTo(o.x);
			if (result == 0)
				result = y.compareTo(o.y);

			return result;
		}

		public String toString() {
			return x + " " + y;
		}

		public boolean equals(Object o) {
			if (o instanceof pair) {
				pair p = (pair) o;
				return p.x - x == 0 && p.y - y == 0;
			}
			return false;
		}

		public int hashCode() {
			return new Long(x).hashCode() * 31 + new Long(y).hashCode();
		}
	}

	static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}

		public String readString() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

	static class CodeX {
		public static void sort(long arr[]) {
			merge_sort(arr, 0, arr.length - 1);
		}

		private static void merge_sort(long A[], long start, long end) {
			if (start < end) {
				long mid = (start + end) / 2;
				merge_sort(A, start, mid);
				merge_sort(A, mid + 1, end);
				merge(A, start, mid, end);
			}

		}

		private static void merge(long A[], long start, long mid, long end) {
			long p = start, q = mid + 1;
			long Arr[] = new long[(int) (end - start + 1)];
			long k = 0;

			for (int i = (int) start; i <= end; i++) {
				if (p > mid)
					Arr[(int) k++] = A[(int) q++];

				else if (q > end)
					Arr[(int) k++] = A[(int) p++];

				else if (A[(int) p] < A[(int) q])
					Arr[(int) k++] = A[(int) p++];

				else
					Arr[(int) k++] = A[(int) q++];
			}
			for (int i = 0; i < k; i++) {
				A[(int) start++] = Arr[i];
			}

		}

	}

}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.InputMismatchException;

public class B {
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		InputReader s = new InputReader(System.in);
		PrintWriter p = new PrintWriter(System.out);
		int t = s.nextInt();
		while (t-- > 0) {
			int n = s.nextInt();
			int k = s.nextInt();
			String str = s.nextLine();
			char[] arr = str.toCharArray();
			int[] freq = new int[26];
			for (int i = 0; i < n; i++) {
				freq[arr[i] - 'a']++;
			}
			int flag = 0;
			ArrayList<pair> list = new ArrayList<>();
			for (int i = 0; i < 26; i++) {
				if (freq[i] > 0) {
					pair temp = new pair(i, freq[i]);
					list.add(temp);
				}
			}
			if (list.size() == 1) {
				StringBuilder ans = new StringBuilder();
				for (int i = 0; i < list.get(0).y / k; i++) {
					ans.append((char) (list.get(0).x + 'a'));
				}
				if (list.get(0).y % k > 0)
					ans.append((char) (list.get(0).x + 'a'));
				p.println(ans.toString());
				continue;
			}
			if (list.size() == 2 && list.get(0).y == k) {
				StringBuilder ans = new StringBuilder();
				ans.append((char) (list.get(0).x + 'a'));
				char ch = (char) (list.get(1).x + 'a');
				for (int i = 0; i < list.get(1).y / k; i++) {
					ans.append(ch);
				}
				if (list.get(1).y % k != 0)
					ans.append(ch);
				p.println(ans.toString());
				continue;
			}
			StringBuilder ans = new StringBuilder();
			flag = 0;
			if (list.get(0).y < k) {
				int temp = k;
				for (int i = 0; i < list.size(); i++) {
					if (list.get(i).y >= temp) {
						p.println((char) (list.get(i).x + 'a'));
						flag = 1;
						break;
					} else
						temp -= list.get(i).y;
				}
				if (flag == 1)
					continue;
			}
			list.get(0).y -= k;
			ans.append((char) (list.get(0).x + 'a'));
			for (int i = 0; i < list.size(); i++) {
				char ch = (char) (list.get(i).x + 'a');
				for (int j = 0; j < list.get(i).y; j++)
					ans.append(ch);
			}
			p.println(ans.toString());

		}
		p.flush();
		p.close();
	}

	public static long GCD(long a, long b) {
		if (a == 0)
			return b;
		return GCD(b % a, a);
	}

	public static long LCM(long a, long b) {
		return (a * b) / GCD(a, b);
	}

	static class pair implements Comparable<pair> {
		Integer x, y;

		pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public int compareTo(pair o) {
			int result = x.compareTo(o.x);
			if (result == 0)
				result = y.compareTo(o.y);

			return result;
		}

		public String toString() {
			return x + " " + y;
		}

		public boolean equals(Object o) {
			if (o instanceof pair) {
				pair p = (pair) o;
				return p.x - x == 0 && p.y - y == 0;
			}
			return false;
		}

		public int hashCode() {
			return new Long(x).hashCode() * 31 + new Long(y).hashCode();
		}
	}

	static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}

		public String readString() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

	static class CodeX {
		public static void sort(long arr[]) {
			merge_sort(arr, 0, arr.length - 1);
		}

		private static void merge_sort(long A[], long start, long end) {
			if (start < end) {
				long mid = (start + end) / 2;
				merge_sort(A, start, mid);
				merge_sort(A, mid + 1, end);
				merge(A, start, mid, end);
			}

		}

		private static void merge(long A[], long start, long mid, long end) {
			long p = start, q = mid + 1;
			long Arr[] = new long[(int) (end - start + 1)];
			long k = 0;

			for (int i = (int) start; i <= end; i++) {
				if (p > mid)
					Arr[(int) k++] = A[(int) q++];

				else if (q > end)
					Arr[(int) k++] = A[(int) p++];

				else if (A[(int) p] < A[(int) q])
					Arr[(int) k++] = A[(int) p++];

				else
					Arr[(int) k++] = A[(int) q++];
			}
			for (int i = 0; i < k; i++) {
				A[(int) start++] = Arr[i];
			}

		}

	}

}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.InputMismatchException;

public class B {
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		InputReader s = new InputReader(System.in);
		PrintWriter p = new PrintWriter(System.out);
		int t = s.nextInt();
		while (t-- > 0) {
			int n = s.nextInt();
			int k = s.nextInt();
			String str = s.nextLine();
			char[] arr = str.toCharArray();
			int[] freq = new int[26];
			for (int i = 0; i < n; i++) {
				freq[arr[i] - 'a']++;
			}
			int flag = 0;
			ArrayList<pair> list = new ArrayList<>();
			for (int i = 0; i < 26; i++) {
				if (freq[i] > 0) {
					pair temp = new pair(i, freq[i]);
					list.add(temp);
				}
			}
			if (list.size() == 1) {
				StringBuilder ans = new StringBuilder();
				for (int i = 0; i < list.get(0).y / k; i++) {
					ans.append((char) (list.get(0).x + 'a'));
				}
				if (list.get(0).y % k > 0)
					ans.append((char) (list.get(0).x + 'a'));
				p.println(ans.toString());
				continue;
			}
			int mini = 0;
			for (int i = 0; i < list.size(); i++) {
				pair temp = list.get(i);
				if (temp.y % k == 0)
					continue;
				else {
					flag = 1;
					mini = i;
					break;
				}
			}
			if (flag == 0) {
				StringBuilder ans = new StringBuilder();
				for (int i = 0; i < list.size(); i++) {
					pair temp = list.get(i);
					int val = list.get(i).y / k;
					char ch = (char) (temp.x + 'a');

					for (int j = 0; j < val; j++) {
						ans.append(ch);
					}
				}
				p.println(ans.toString());
				continue;
			}
			if (mini == 0) {
				if (list.get(0).y < k) {
					p.println((char) (list.get(1).x + 'a'));
					continue;
				} else {
					StringBuilder ans = new StringBuilder();
					for (int i = 0; i < list.get(0).y - (k - 1); i++) {
						ans.append((char) (list.get(0).x + 'a'));
					}
					for (int i = 1; i < list.size(); i++) {
						pair temp = list.get(i);
						int val = list.get(i).y;
						char ch = (char) (temp.x + 'a');

						for (int j = 0; j < val; j++) {
							ans.append(ch);
						}
					}
					p.println(ans);
					continue;
				}
			}
			StringBuilder ans = new StringBuilder();
			for (int i = 0; i < list.get(0).y - (k - 1); i++) {
				ans.append((char) (list.get(0).x + 'a'));
			}
			for (int i = 1; i < list.size(); i++) {
				pair temp = list.get(i);
				int val = list.get(i).y;
				char ch = (char) (temp.x + 'a');

				for (int j = 0; j < val; j++) {
					ans.append(ch);
				}
			}
			p.println(ans.toString());
		}
		p.flush();
		p.close();
	}

	public static long GCD(long a, long b) {
		if (a == 0)
			return b;
		return GCD(b % a, a);
	}

	public static long LCM(long a, long b) {
		return (a * b) / GCD(a, b);
	}

	static class pair implements Comparable<pair> {
		Integer x, y;

		pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public int compareTo(pair o) {
			int result = x.compareTo(o.x);
			if (result == 0)
				result = y.compareTo(o.y);

			return result;
		}

		public String toString() {
			return x + " " + y;
		}

		public boolean equals(Object o) {
			if (o instanceof pair) {
				pair p = (pair) o;
				return p.x - x == 0 && p.y - y == 0;
			}
			return false;
		}

		public int hashCode() {
			return new Long(x).hashCode() * 31 + new Long(y).hashCode();
		}
	}

	static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}

		public String readString() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

	static class CodeX {
		public static void sort(long arr[]) {
			merge_sort(arr, 0, arr.length - 1);
		}

		private static void merge_sort(long A[], long start, long end) {
			if (start < end) {
				long mid = (start + end) / 2;
				merge_sort(A, start, mid);
				merge_sort(A, mid + 1, end);
				merge(A, start, mid, end);
			}

		}

		private static void merge(long A[], long start, long mid, long end) {
			long p = start, q = mid + 1;
			long Arr[] = new long[(int) (end - start + 1)];
			long k = 0;

			for (int i = (int) start; i <= end; i++) {
				if (p > mid)
					Arr[(int) k++] = A[(int) q++];

				else if (q > end)
					Arr[(int) k++] = A[(int) p++];

				else if (A[(int) p] < A[(int) q])
					Arr[(int) k++] = A[(int) p++];

				else
					Arr[(int) k++] = A[(int) q++];
			}
			for (int i = 0; i < k; i++) {
				A[(int) start++] = Arr[i];
			}

		}

	}

}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.InputMismatchException;

public class B {
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		InputReader s = new InputReader(System.in);
		PrintWriter p = new PrintWriter(System.out);
		int t = s.nextInt();
		while (t-- > 0) {
			int n = s.nextInt();
			int k = s.nextInt();
			String str = s.nextLine();
			char[] arr = str.toCharArray();
			ArrayList<Character> sorted = new ArrayList<>();
			StringBuilder temp = new StringBuilder();
			for (int i = 0; i < arr.length; i++) {
				sorted.add(arr[i]);
				temp.append(arr[i]);
			}
			Collections.sort(sorted);
			StringBuilder ans = new StringBuilder();
			ans.append(sorted.get(k - 1));
			if (n == k || sorted.get(k - 1) > sorted.get(0)) {
				p.println(ans);
				continue;
			}
			if (sorted.get(k) == sorted.get(sorted.size() - 1)) {
				int i = k;
				while (n - i >= k && i < n) {
					ans.append(sorted.get(i));
					i += k;
				}
				if (i < n) {
					ans.append(sorted.get(n - 1));
				}
			} else {
				ans.append(temp.toString().substring(k));
			}
			p.println(ans);
		}
		p.flush();
		p.close();
	}

	public static long GCD(long a, long b) {
		if (a == 0)
			return b;
		return GCD(b % a, a);
	}

	public static long LCM(long a, long b) {
		return (a * b) / GCD(a, b);
	}

	static class pair implements Comparable<pair> {
		Integer x, y;

		pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public int compareTo(pair o) {
			int result = x.compareTo(o.x);
			if (result == 0)
				result = y.compareTo(o.y);

			return result;
		}

		public String toString() {
			return x + " " + y;
		}

		public boolean equals(Object o) {
			if (o instanceof pair) {
				pair p = (pair) o;
				return p.x - x == 0 && p.y - y == 0;
			}
			return false;
		}

		public int hashCode() {
			return new Long(x).hashCode() * 31 + new Long(y).hashCode();
		}
	}

	static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}

		public String readString() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

	static class CodeX {
		public static void sort(long arr[]) {
			merge_sort(arr, 0, arr.length - 1);
		}

		private static void merge_sort(long A[], long start, long end) {
			if (start < end) {
				long mid = (start + end) / 2;
				merge_sort(A, start, mid);
				merge_sort(A, mid + 1, end);
				merge(A, start, mid, end);
			}

		}

		private static void merge(long A[], long start, long mid, long end) {
			long p = start, q = mid + 1;
			long Arr[] = new long[(int) (end - start + 1)];
			long k = 0;

			for (int i = (int) start; i <= end; i++) {
				if (p > mid)
					Arr[(int) k++] = A[(int) q++];

				else if (q > end)
					Arr[(int) k++] = A[(int) p++];

				else if (A[(int) p] < A[(int) q])
					Arr[(int) k++] = A[(int) p++];

				else
					Arr[(int) k++] = A[(int) q++];
			}
			for (int i = 0; i < k; i++) {
				A[(int) start++] = Arr[i];
			}

		}

	}

}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.InputMismatchException;

public class B {
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		InputReader s = new InputReader(System.in);
		PrintWriter p = new PrintWriter(System.out);
		int t = s.nextInt();
		while (t-- > 0) {
			int n = s.nextInt();
			int k = s.nextInt();
			String str = s.nextLine();
			char[] arr = str.toCharArray();
			int[] freq = new int[26];
			for (int i = 0; i < n; i++) {
				freq[arr[i] - 'a']++;
			}
			int flag = 0;
			ArrayList<pair> list = new ArrayList<>();
			for (int i = 0; i < 26; i++) {
				if (freq[i] > 0) {
					pair temp = new pair(i, freq[i]);
					list.add(temp);
				}
			}
			if (list.size() == 1) {
				StringBuilder ans = new StringBuilder();
				for (int i = 0; i < list.get(0).y / k; i++) {
					ans.append((char) (list.get(0).x + 'a'));
				}
				if (list.get(0).y % k > 0)
					ans.append((char) (list.get(0).x + 'a'));
				p.println(ans.toString());
				continue;
			}
			if (list.size() == 2) {
				if (list.get(0).y == k && list.get(1).y == k) {
					p.println(""+(char) (list.get(0).x + 'a') + (char) (list.get(1).x + 'a'));
					continue;
				}
			}
			int mini = 0;
			for (int i = 0; i < list.size(); i++) {
				pair temp = list.get(i);
				if (temp.y % k == 0)
					continue;
				else {
					flag = 1;
					mini = i;
					break;
				}
			}
			if (mini == 0) {
				if (list.get(0).y < k) {
					p.println((char) (list.get(1).x + 'a'));
					continue;
				} else {
					StringBuilder ans = new StringBuilder();
					for (int i = 0; i < list.get(0).y - (k - 1); i++) {
						ans.append((char) (list.get(0).x + 'a'));
					}
					for (int i = 1; i < list.size(); i++) {
						pair temp = list.get(i);
						int val = list.get(i).y;
						char ch = (char) (temp.x + 'a');
						for (int j = 0; j < val; j++) {
							ans.append(ch);
						}
					}
					p.println(ans);
					continue;
				}
			}
			StringBuilder ans = new StringBuilder();
			for (int i = 0; i < list.get(0).y - (k - 1); i++) {
				ans.append((char) (list.get(0).x + 'a'));
			}
			for (int i = 1; i < list.size(); i++) {
				pair temp = list.get(i);
				int val = list.get(i).y;
				char ch = (char) (temp.x + 'a');

				for (int j = 0; j < val; j++) {
					ans.append(ch);
				}
			}
			p.println(ans.toString());
		}
		p.flush();
		p.close();
	}

	public static long GCD(long a, long b) {
		if (a == 0)
			return b;
		return GCD(b % a, a);
	}

	public static long LCM(long a, long b) {
		return (a * b) / GCD(a, b);
	}

	static class pair implements Comparable<pair> {
		Integer x, y;

		pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public int compareTo(pair o) {
			int result = x.compareTo(o.x);
			if (result == 0)
				result = y.compareTo(o.y);

			return result;
		}

		public String toString() {
			return x + " " + y;
		}

		public boolean equals(Object o) {
			if (o instanceof pair) {
				pair p = (pair) o;
				return p.x - x == 0 && p.y - y == 0;
			}
			return false;
		}

		public int hashCode() {
			return new Long(x).hashCode() * 31 + new Long(y).hashCode();
		}
	}

	static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}

		public String readString() {
			int c = snext();
			while (isSpaceChar(c)) {
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

	static class CodeX {
		public static void sort(long arr[]) {
			merge_sort(arr, 0, arr.length - 1);
		}

		private static void merge_sort(long A[], long start, long end) {
			if (start < end) {
				long mid = (start + end) / 2;
				merge_sort(A, start, mid);
				merge_sort(A, mid + 1, end);
				merge(A, start, mid, end);
			}

		}

		private static void merge(long A[], long start, long mid, long end) {
			long p = start, q = mid + 1;
			long Arr[] = new long[(int) (end - start + 1)];
			long k = 0;

			for (int i = (int) start; i <= end; i++) {
				if (p > mid)
					Arr[(int) k++] = A[(int) q++];

				else if (q > end)
					Arr[(int) k++] = A[(int) p++];

				else if (A[(int) p] < A[(int) q])
					Arr[(int) k++] = A[(int) p++];

				else
					Arr[(int) k++] = A[(int) q++];
			}
			for (int i = 0; i < k; i++) {
				A[(int) start++] = Arr[i];
			}

		}

	}

}