import java.io.*;
import java.math.BigInteger;
import java.net.PortUnreachableException;
import java.util.*;

// written by luchy0120

public class Main {
    public static void main(String[] args) throws Exception {

        new Main().run();
    }

    static int groups = 0;
    static int[] fa;
    static int[] sz;

    static void init(int n) {
        groups = n;
        fa = new int[n];
        for (int i = 1; i < n; ++i) {
            fa[i] = i;
        }
        sz = new int[n];
        Arrays.fill(sz, 1);
    }

    static int root(int p) {
        while (p != fa[p]) {
            fa[p] = fa[fa[p]];
            p = fa[p];
        }
        return p;
    }

    static void combine(int p, int q) {
        int i = root(p);
        int j = root(q);
        if (i == j) {
            return;
        }
        if (sz[i] < sz[j]) {
            fa[i] = j;
            sz[j] += sz[i];
        } else {
            fa[j] = i;
            sz[i] += sz[j];
        }
        groups--;
    }

    int child[];
    int color[],dfn[],low[],stack[],cnt[];
    boolean vis[];
    boolean iscut[];
    int deep,top,n,m,sum,ans;
    List<Integer> g[];
    int root = 0;
    //  无向图的强连通分量
    void tarjanNonDirect(int u1) {

        int stk[] = new int[10001];
        int fatk[] = new int[10001];
        int p = 0;
        stk[p] = u1;
        fatk[p] = -1;
        p= 1;
        ot: while(p>0) {
            int u  = stk[p-1];
            int fa = fatk[p-1];

            if(dfn[u]==0) {
                low[u] = dfn[u] = ++deep;
            }
            // stack[top++] = u;

            for (; h[u] != -1; h[u] = ne[h[u]]) {
                int v = to[h[u]];
                if (dfn[v] == 0) {
                    //tarjanNonDirect(v);

                    fatk[p] = u;
                    stk[p++] = v;
                    continue ot;
                } else {
                    low[u] = Math.min(low[u], dfn[v]);
                    // 没有特判是否直接指向父亲
                    // 回边，使用dfn【v】更新low【u】,因为可能是指向父亲，而父亲的low可能比较小
                }
            }
            --p;

            if (fa != -1) {
                low[fa] = Math.min(low[fa], low[u]);
                if (low[u] >= dfn[fa]) {
                    if (fa != root || ++child[fa] > 1) {     // 不是root，直接记为cut，是root，判断是否有两个儿子
                        iscut[fa] = true;
                    }
                    ++dcc_cnt;
                    // 一个割点可能会被多个点双共享
                    //  int z = -1;
                    //    do {
                    //        z = stack[--top];
                    //      dcc[dcc_cnt].add(z);
                    //    } while(z != v);
                    //   dcc[dcc_cnt].add(u);
                }

            }

        }
    }
    int gd = 0;
    int id =-1;
    int scc_cnt = 0;
    int sccno[];
    // 有向图的强连通分量
    void tarjan(int u) {
        int stk[] = new int[10001];
        //   int tptk[] = new int[10001];

        //  int fatk[] = new int[10001];
        int p  =1; stk[0] = u;//fatk[0] =-1;
        ot:while(p>0) {
            u  = stk[p-1];
            //  int fa  = fatk[p-1];
            if (dfn[u] == 0) {
                low[u] = dfn[u] = ++deep;
                stack[top++] = u;

            }

            for (; hc[u] != -1; hc[u] = ne[hc[u]]) {
                int v = to[hc[u]];
                if (dfn[v] == 0) {
                    stk[p++] = v;
                    continue ot;
                    //  low[u] = Math.min(low[u], low[v]);
                } else if (sccno[v] == 0) {
                    // dfn>0 but sccno==0, means it's in current stack
                    low[u] = Math.min(low[u], low[v]);
                }
            }

            p--;
            if (dfn[u] == low[u]) {
                sccno[u] = ++scc_cnt;
                if(u==1){
                    id = scc_cnt;
                }

                while (stack[top - 1] != u) {
                    sccno[stack[top - 1]] = scc_cnt;
                    if(stack[top - 1]==1){
                        id = scc_cnt;
                    }
                    --top;
                }

                --top;
            }
            if(p>=1){
                int fa = stk[p-1];
                low[fa] = Math.min(low[fa], low[u]);
            }
        }
    }
    int rr =0;
//    void solve() {
//
//    }

//    int get_room(int i,int j){
//        return i/3*3 + j/3;
//    }

//    int a[][] = new int[9][9];
//    int space = 0;
//
//    boolean vis_row[][] = new boolean[9][10];
//    boolean vis_col[][] = new boolean[9][10];
//    boolean vis_room[][] = new boolean[9][10];
//    int val[][][] =new int[9][9][];
//    int prepare[][];
//
//    void dfs(int rt){
//
//    }

    int h[],to[],ne[];int ct =0;
    void add(int u,int v){
        // u--;v--;
        to[ct] = v;
        ne[ct] = h[u];
        h[u] = ct++;

    }

    int dcc_cnt = 0;
    int time = 0;

    long summ[];
    int v[];
    int hc[];
    void solve() {
        int t = 1000;
        ot:for(int i=1;i<=t;++i){
            int n = ni();
            int k = ni();

            char c[] = ns().toCharArray();
            Arrays.sort(c);
            boolean first = true;
            StringBuilder sb = new StringBuilder();
            for(int j=0;j<n;){
                int nj = j+1;
                while(nj<n&&c[j]==c[nj])++nj;
                int len = nj-j;
                if(j==0) {
                    if (len < k) {
                        println(c[k-1]);
                        continue ot;
                    } else if (len%k!=0){
                        if(nj<n) {
                            for (int m = k - 1; m < n; ++m) {
                                print(c[m]);
                            }
                            println();
                        }else{
                            for (int m = 0; m < len/k+1; ++m) {
                                print(c[0]);
                            }
                            println();
                        }
                        continue ot;
                    } else{
                        for(int m=0;m<len/k;++m){
                            sb.append(c[0]);
                        }
                    }
                }else{
                    if (len%k!=0){
                        for(int m = k-1;m<n;++m){
                            print(c[m]);
                        }
                        println();
                        continue ot;
                    } else{
                        for(int m=0;m<len/k;++m){
                            sb.append(c[j]);
                        }
                    }
                }
                j = nj;
            }
            println(sb);
        }

//        int n = ni();
//        int m  = n*(n+1)/2;
//        int k = ni();
//        int p = 0;
//
//        double x[] = new double[n];
//        double y[] = new double[n];
//
//        for(int i=0;i<n;++i){
//            x[i] = nd();
//            y[i] = nd();
//        }
//
//        List<Item> li = new ArrayList<>();
//        for(int i=0;i<n;++i){
//            for(int j=i+1;j<n;++j){
//               double r =  (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]);
//               li.add(new Item(r,i,j));
//            }
//        }
//        Collections.sort(li,(xx,yy)->Double.compare(xx.s,yy.s));
//
//        init(n + 1);
//
//        int s = 0;
//        int c = n;
//        for (int i = 0; i < li.size(); ++i) {
//            int p1 = li.get(i).a;
//            int p2 = li.get(i).b;
//            if (root(p1) != root(p2)) {
//                combine(p1, p2);
//                c--;
//                if(c==k-1){
//                    print(roundS(Math.sqrt(li.get(i).s),2));
//                    break;
//                }
//            }
//        }

    }
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//    }

    static long mul(long a, long b, long p)
    {
        long res=0,base=a;
        while(b>0)
        {
            if((b&1L)>0)
                res=(res+base)%p;
            base=(base+base)%p;
            b>>=1;
        }
        return res;
    }

    static long mod_pow(long k,long n,long p){
        long res = 1L;
        long temp = (k%p+p)%p;
        while(n!=0L){
            if((n&1L)==1L){
                res = ((res*temp)%p+p)%p;
            }
            temp = ((temp * temp)%p+p)%p;
            n = n>>1L;
        }
        return res%p;
    }
    public static String roundS(double result, int scale){
        String fmt = String.format("%%.%df", scale);
        return String.format(fmt, result);
    }

//    void solve() {
//
//        for(int i=0;i<9;++i) {
//            for (int j = 0; j < 9; ++j) {
//                int v = ni();
//                a[i][j] = v;
//                if(v>0) {
//                    vis_row[i][v] = true;
//                    vis_col[j][v] = true;
//                    vis_room[get_room(i, j)][v] = true;
//                }else{
//                    space++;
//                }
//            }
//        }
//
//
//        prepare = new int[space][2];
//
//        int p = 0;
//
//        for(int i=0;i<9;++i) {
//            for (int j = 0; j < 9; ++j) {
//                if(a[i][j]==0){
//                    prepare[p][0] = i;
//                    prepare[p][1]= j;p++;
//                    List<Integer> temp =new ArrayList<>();
//                    for(int k=1;k<=9;++k){
//                        if(!vis_col[j][k]&&!vis_row[i][k]&&!vis_room[get_room(i,j)][k]){
//                            temp.add(k);
//                        }
//                    }
//                    int sz = temp.size();
//                    val[i][j] = new int[sz];
//                    for(int k=0;k<sz;++k){
//                        val[i][j][k] = temp.get(k);
//                    }
//                }
//            }
//        }
//        Arrays.sort(prepare,(x,y)->{
//           return Integer.compare(val[x[0]][x[1]].length,val[y[0]][y[1]].length);
//        });
//        dfs(0);
//
//
//
//
//
//
//
//
//
//
//    }

    InputStream is;
    PrintWriter out;

    void run() throws Exception {
        //is = new FileInputStream(new File("C:\\Users\\Luqi\\Downloads\\P3387_9.in"));
        is = System.in;
        out = new PrintWriter(System.out);

        solve();
        out.flush();
    }

    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private char ncc() {
        int b = readByte();
        return (char) b;
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private String nline() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!isSpaceChar(b) || b == ' ') {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[][] nm(int n, int m) {
        char[][] a = new char[n][];
        for (int i = 0; i < n; i++) a[i] = ns(m);
        return a;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = ni();
        return a;
    }

    private long[] nal(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) a[i] = nl();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) {
        }
        ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        while (true) {
            if (b >= '0' && b <= '9') num = (num << 3) + (num << 1) + (b - '0');
            else return minus ? -num : num;
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) {
        }
        ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        while (true) {
            if (b >= '0' && b <= '9') num = num * 10 + (b - '0');
            else return minus ? -num : num;
            b = readByte();
        }
    }

    void print(Object obj) {
        out.print(obj);
    }

    void println(Object obj) {
        out.println(obj);
    }

    void println() {
        out.println();
    }

    void printArray(int a[],int from){
        int l = a.length;
        for(int i=from;i<l;++i){
            print(a[i]);
            if(i!=l-1){
                print(" ");
            }
        }
        println();
    }

    void printArray(long a[],int from){
        int l = a.length;
        for(int i=from;i<l;++i){
            print(a[i]);
            if(i!=l-1){
                print(" ");
            }
        }
        println();
    }
}


import java.io.*;
import java.math.BigInteger;
import java.net.PortUnreachableException;
import java.util.*;

// written by luchy0120

public class Main {
    public static void main(String[] args) throws Exception {

        new Main().run();
    }

    static int groups = 0;
    static int[] fa;
    static int[] sz;

    static void init(int n) {
        groups = n;
        fa = new int[n];
        for (int i = 1; i < n; ++i) {
            fa[i] = i;
        }
        sz = new int[n];
        Arrays.fill(sz, 1);
    }

    static int root(int p) {
        while (p != fa[p]) {
            fa[p] = fa[fa[p]];
            p = fa[p];
        }
        return p;
    }

    static void combine(int p, int q) {
        int i = root(p);
        int j = root(q);
        if (i == j) {
            return;
        }
        if (sz[i] < sz[j]) {
            fa[i] = j;
            sz[j] += sz[i];
        } else {
            fa[j] = i;
            sz[i] += sz[j];
        }
        groups--;
    }

    int child[];
    int color[],dfn[],low[],stack[],cnt[];
    boolean vis[];
    boolean iscut[];
    int deep,top,n,m,sum,ans;
    List<Integer> g[];
    int root = 0;
    //  无向图的强连通分量
    void tarjanNonDirect(int u1) {

        int stk[] = new int[10001];
        int fatk[] = new int[10001];
        int p = 0;
        stk[p] = u1;
        fatk[p] = -1;
        p= 1;
        ot: while(p>0) {
            int u  = stk[p-1];
            int fa = fatk[p-1];

            if(dfn[u]==0) {
                low[u] = dfn[u] = ++deep;
            }
            // stack[top++] = u;

            for (; h[u] != -1; h[u] = ne[h[u]]) {
                int v = to[h[u]];
                if (dfn[v] == 0) {
                    //tarjanNonDirect(v);

                    fatk[p] = u;
                    stk[p++] = v;
                    continue ot;
                } else {
                    low[u] = Math.min(low[u], dfn[v]);
                    // 没有特判是否直接指向父亲
                    // 回边，使用dfn【v】更新low【u】,因为可能是指向父亲，而父亲的low可能比较小
                }
            }
            --p;

            if (fa != -1) {
                low[fa] = Math.min(low[fa], low[u]);
                if (low[u] >= dfn[fa]) {
                    if (fa != root || ++child[fa] > 1) {     // 不是root，直接记为cut，是root，判断是否有两个儿子
                        iscut[fa] = true;
                    }
                    ++dcc_cnt;
                    // 一个割点可能会被多个点双共享
                    //  int z = -1;
                    //    do {
                    //        z = stack[--top];
                    //      dcc[dcc_cnt].add(z);
                    //    } while(z != v);
                    //   dcc[dcc_cnt].add(u);
                }

            }

        }
    }
    int gd = 0;
    int id =-1;
    int scc_cnt = 0;
    int sccno[];
    // 有向图的强连通分量
    void tarjan(int u) {
        int stk[] = new int[10001];
        //   int tptk[] = new int[10001];

        //  int fatk[] = new int[10001];
        int p  =1; stk[0] = u;//fatk[0] =-1;
        ot:while(p>0) {
            u  = stk[p-1];
            //  int fa  = fatk[p-1];
            if (dfn[u] == 0) {
                low[u] = dfn[u] = ++deep;
                stack[top++] = u;

            }

            for (; hc[u] != -1; hc[u] = ne[hc[u]]) {
                int v = to[hc[u]];
                if (dfn[v] == 0) {
                    stk[p++] = v;
                    continue ot;
                    //  low[u] = Math.min(low[u], low[v]);
                } else if (sccno[v] == 0) {
                    // dfn>0 but sccno==0, means it's in current stack
                    low[u] = Math.min(low[u], low[v]);
                }
            }

            p--;
            if (dfn[u] == low[u]) {
                sccno[u] = ++scc_cnt;
                if(u==1){
                    id = scc_cnt;
                }

                while (stack[top - 1] != u) {
                    sccno[stack[top - 1]] = scc_cnt;
                    if(stack[top - 1]==1){
                        id = scc_cnt;
                    }
                    --top;
                }

                --top;
            }
            if(p>=1){
                int fa = stk[p-1];
                low[fa] = Math.min(low[fa], low[u]);
            }
        }
    }
    int rr =0;
//    void solve() {
//
//    }

//    int get_room(int i,int j){
//        return i/3*3 + j/3;
//    }

//    int a[][] = new int[9][9];
//    int space = 0;
//
//    boolean vis_row[][] = new boolean[9][10];
//    boolean vis_col[][] = new boolean[9][10];
//    boolean vis_room[][] = new boolean[9][10];
//    int val[][][] =new int[9][9][];
//    int prepare[][];
//
//    void dfs(int rt){
//
//    }

    int h[],to[],ne[];int ct =0;
    void add(int u,int v){
        // u--;v--;
        to[ct] = v;
        ne[ct] = h[u];
        h[u] = ct++;

    }

    int dcc_cnt = 0;
    int time = 0;

    long summ[];
    int v[];
    int hc[];
    void solve() {

        ot:for(int i=ni();i>=1;--i){
            int n = ni();
            int k = ni();

            char c[] = ns().toCharArray();
            Arrays.sort(c);
            boolean first = true;
            StringBuilder sb = new StringBuilder();
            for(int j=0;j<n;){
                int nj = j+1;
                while(nj<n&&c[j]==c[nj])++nj;
                int len = nj-j;
                if(j==0) {
                    if (len < k) {
                        println(c[k-1]);
                        continue ot;
                    } else if (len%k!=0){
                        if(nj<len) {
                            for (int m = k - 1; m < n; ++m) {
                                print(c[m]);
                            }
                            println();
                        }else{
                            for (int m = 0; m < len/k+1; ++m) {
                                print(c[0]);
                            }
                            println();
                        }
                        continue ot;
                    } else{
                        for(int m=0;m<len/k;++m){
                            sb.append(c[0]);
                        }
                    }
                }else{
                    if (len%k!=0){
                        for(int m = k-1;m<n;++m){
                            print(c[m]);
                        }
                        println();
                        continue ot;
                    } else{
                        for(int m=0;m<len/k;++m){
                            sb.append(c[j]);
                        }
                    }
                }
                j = nj;
            }
            println(sb);
        }

//        int n = ni();
//        int m  = n*(n+1)/2;
//        int k = ni();
//        int p = 0;
//
//        double x[] = new double[n];
//        double y[] = new double[n];
//
//        for(int i=0;i<n;++i){
//            x[i] = nd();
//            y[i] = nd();
//        }
//
//        List<Item> li = new ArrayList<>();
//        for(int i=0;i<n;++i){
//            for(int j=i+1;j<n;++j){
//               double r =  (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]);
//               li.add(new Item(r,i,j));
//            }
//        }
//        Collections.sort(li,(xx,yy)->Double.compare(xx.s,yy.s));
//
//        init(n + 1);
//
//        int s = 0;
//        int c = n;
//        for (int i = 0; i < li.size(); ++i) {
//            int p1 = li.get(i).a;
//            int p2 = li.get(i).b;
//            if (root(p1) != root(p2)) {
//                combine(p1, p2);
//                c--;
//                if(c==k-1){
//                    print(roundS(Math.sqrt(li.get(i).s),2));
//                    break;
//                }
//            }
//        }

    }
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//    }

    static long mul(long a, long b, long p)
    {
        long res=0,base=a;
        while(b>0)
        {
            if((b&1L)>0)
                res=(res+base)%p;
            base=(base+base)%p;
            b>>=1;
        }
        return res;
    }

    static long mod_pow(long k,long n,long p){
        long res = 1L;
        long temp = (k%p+p)%p;
        while(n!=0L){
            if((n&1L)==1L){
                res = ((res*temp)%p+p)%p;
            }
            temp = ((temp * temp)%p+p)%p;
            n = n>>1L;
        }
        return res%p;
    }
    public static String roundS(double result, int scale){
        String fmt = String.format("%%.%df", scale);
        return String.format(fmt, result);
    }

//    void solve() {
//
//        for(int i=0;i<9;++i) {
//            for (int j = 0; j < 9; ++j) {
//                int v = ni();
//                a[i][j] = v;
//                if(v>0) {
//                    vis_row[i][v] = true;
//                    vis_col[j][v] = true;
//                    vis_room[get_room(i, j)][v] = true;
//                }else{
//                    space++;
//                }
//            }
//        }
//
//
//        prepare = new int[space][2];
//
//        int p = 0;
//
//        for(int i=0;i<9;++i) {
//            for (int j = 0; j < 9; ++j) {
//                if(a[i][j]==0){
//                    prepare[p][0] = i;
//                    prepare[p][1]= j;p++;
//                    List<Integer> temp =new ArrayList<>();
//                    for(int k=1;k<=9;++k){
//                        if(!vis_col[j][k]&&!vis_row[i][k]&&!vis_room[get_room(i,j)][k]){
//                            temp.add(k);
//                        }
//                    }
//                    int sz = temp.size();
//                    val[i][j] = new int[sz];
//                    for(int k=0;k<sz;++k){
//                        val[i][j][k] = temp.get(k);
//                    }
//                }
//            }
//        }
//        Arrays.sort(prepare,(x,y)->{
//           return Integer.compare(val[x[0]][x[1]].length,val[y[0]][y[1]].length);
//        });
//        dfs(0);
//
//
//
//
//
//
//
//
//
//
//    }

    InputStream is;
    PrintWriter out;

    void run() throws Exception {
        //is = new FileInputStream(new File("C:\\Users\\Luqi\\Downloads\\P3387_9.in"));
        is = System.in;
        out = new PrintWriter(System.out);

        solve();
        out.flush();
    }

    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private char ncc() {
        int b = readByte();
        return (char) b;
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private String nline() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!isSpaceChar(b) || b == ' ') {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[][] nm(int n, int m) {
        char[][] a = new char[n][];
        for (int i = 0; i < n; i++) a[i] = ns(m);
        return a;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = ni();
        return a;
    }

    private long[] nal(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) a[i] = nl();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) {
        }
        ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        while (true) {
            if (b >= '0' && b <= '9') num = (num << 3) + (num << 1) + (b - '0');
            else return minus ? -num : num;
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) {
        }
        ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        while (true) {
            if (b >= '0' && b <= '9') num = num * 10 + (b - '0');
            else return minus ? -num : num;
            b = readByte();
        }
    }

    void print(Object obj) {
        out.print(obj);
    }

    void println(Object obj) {
        out.println(obj);
    }

    void println() {
        out.println();
    }

    void printArray(int a[],int from){
        int l = a.length;
        for(int i=from;i<l;++i){
            print(a[i]);
            if(i!=l-1){
                print(" ");
            }
        }
        println();
    }

    void printArray(long a[],int from){
        int l = a.length;
        for(int i=from;i<l;++i){
            print(a[i]);
            if(i!=l-1){
                print(" ");
            }
        }
        println();
    }
}


import java.io.*;
import java.math.BigInteger;
import java.net.PortUnreachableException;
import java.util.*;

// written by luchy0120

public class Main {
    public static void main(String[] args) throws Exception {

        new Main().run();
    }

    static int groups = 0;
    static int[] fa;
    static int[] sz;

    static void init(int n) {
        groups = n;
        fa = new int[n];
        for (int i = 1; i < n; ++i) {
            fa[i] = i;
        }
        sz = new int[n];
        Arrays.fill(sz, 1);
    }

    static int root(int p) {
        while (p != fa[p]) {
            fa[p] = fa[fa[p]];
            p = fa[p];
        }
        return p;
    }

    static void combine(int p, int q) {
        int i = root(p);
        int j = root(q);
        if (i == j) {
            return;
        }
        if (sz[i] < sz[j]) {
            fa[i] = j;
            sz[j] += sz[i];
        } else {
            fa[j] = i;
            sz[i] += sz[j];
        }
        groups--;
    }

    int child[];
    int color[],dfn[],low[],stack[],cnt[];
    boolean vis[];
    boolean iscut[];
    int deep,top,n,m,sum,ans;
    List<Integer> g[];
    int root = 0;
    //  无向图的强连通分量
    void tarjanNonDirect(int u1) {

        int stk[] = new int[10001];
        int fatk[] = new int[10001];
        int p = 0;
        stk[p] = u1;
        fatk[p] = -1;
        p= 1;
        ot: while(p>0) {
            int u  = stk[p-1];
            int fa = fatk[p-1];

            if(dfn[u]==0) {
                low[u] = dfn[u] = ++deep;
            }
            // stack[top++] = u;

            for (; h[u] != -1; h[u] = ne[h[u]]) {
                int v = to[h[u]];
                if (dfn[v] == 0) {
                    //tarjanNonDirect(v);

                    fatk[p] = u;
                    stk[p++] = v;
                    continue ot;
                } else {
                    low[u] = Math.min(low[u], dfn[v]);
                    // 没有特判是否直接指向父亲
                    // 回边，使用dfn【v】更新low【u】,因为可能是指向父亲，而父亲的low可能比较小
                }
            }
            --p;

            if (fa != -1) {
                low[fa] = Math.min(low[fa], low[u]);
                if (low[u] >= dfn[fa]) {
                    if (fa != root || ++child[fa] > 1) {     // 不是root，直接记为cut，是root，判断是否有两个儿子
                        iscut[fa] = true;
                    }
                    ++dcc_cnt;
                    // 一个割点可能会被多个点双共享
                    //  int z = -1;
                    //    do {
                    //        z = stack[--top];
                    //      dcc[dcc_cnt].add(z);
                    //    } while(z != v);
                    //   dcc[dcc_cnt].add(u);
                }

            }

        }
    }
    int gd = 0;
    int id =-1;
    int scc_cnt = 0;
    int sccno[];
    // 有向图的强连通分量
    void tarjan(int u) {
        int stk[] = new int[10001];
        //   int tptk[] = new int[10001];

        //  int fatk[] = new int[10001];
        int p  =1; stk[0] = u;//fatk[0] =-1;
        ot:while(p>0) {
            u  = stk[p-1];
            //  int fa  = fatk[p-1];
            if (dfn[u] == 0) {
                low[u] = dfn[u] = ++deep;
                stack[top++] = u;

            }

            for (; hc[u] != -1; hc[u] = ne[hc[u]]) {
                int v = to[hc[u]];
                if (dfn[v] == 0) {
                    stk[p++] = v;
                    continue ot;
                    //  low[u] = Math.min(low[u], low[v]);
                } else if (sccno[v] == 0) {
                    // dfn>0 but sccno==0, means it's in current stack
                    low[u] = Math.min(low[u], low[v]);
                }
            }

            p--;
            if (dfn[u] == low[u]) {
                sccno[u] = ++scc_cnt;
                if(u==1){
                    id = scc_cnt;
                }

                while (stack[top - 1] != u) {
                    sccno[stack[top - 1]] = scc_cnt;
                    if(stack[top - 1]==1){
                        id = scc_cnt;
                    }
                    --top;
                }

                --top;
            }
            if(p>=1){
                int fa = stk[p-1];
                low[fa] = Math.min(low[fa], low[u]);
            }
        }
    }
    int rr =0;
//    void solve() {
//
//    }

//    int get_room(int i,int j){
//        return i/3*3 + j/3;
//    }

//    int a[][] = new int[9][9];
//    int space = 0;
//
//    boolean vis_row[][] = new boolean[9][10];
//    boolean vis_col[][] = new boolean[9][10];
//    boolean vis_room[][] = new boolean[9][10];
//    int val[][][] =new int[9][9][];
//    int prepare[][];
//
//    void dfs(int rt){
//
//    }

    int h[],to[],ne[];int ct =0;
    void add(int u,int v){
        // u--;v--;
        to[ct] = v;
        ne[ct] = h[u];
        h[u] = ct++;

    }

    int dcc_cnt = 0;
    int time = 0;

    long summ[];
    int v[];
    int hc[];
    void solve() {

        ot:for(int i=ni();i>=1;--i){
            int n = ni();
            int k = ni();

            char c[] = ns().toCharArray();
            Arrays.sort(c);
            boolean first = true;
            StringBuilder sb = new StringBuilder();
            for(int j=0;j<n;){
                int nj = j+1;
                while(nj<n&&c[j]==c[nj])++nj;
                int len = nj-j;
                if(j==0) {
                    if (len < k) {
                        println(c[nj]);
                        continue ot;
                    } else if (len%k!=0){
                        if(nj<len) {
                            for (int m = k - 1; m < n; ++m) {
                                print(c[m]);
                            }
                            println();
                        }else{
                            for (int m = 0; m < len/k+1; ++m) {
                                print(c[0]);
                            }
                            println();
                        }
                        continue ot;
                    } else{
                        for(int m=0;m<len/k;++m){
                            sb.append(c[0]);
                        }
                    }
                }else{
                    if (len%k!=0){
                        for(int m = k-1;m<n;++m){
                            print(c[m]);
                        }
                        println();
                        continue ot;
                    } else{
                        for(int m=0;m<len/k;++m){
                            sb.append(c[j]);
                        }
                    }
                }
                j = nj;
            }
            println(sb);
        }

//        int n = ni();
//        int m  = n*(n+1)/2;
//        int k = ni();
//        int p = 0;
//
//        double x[] = new double[n];
//        double y[] = new double[n];
//
//        for(int i=0;i<n;++i){
//            x[i] = nd();
//            y[i] = nd();
//        }
//
//        List<Item> li = new ArrayList<>();
//        for(int i=0;i<n;++i){
//            for(int j=i+1;j<n;++j){
//               double r =  (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]);
//               li.add(new Item(r,i,j));
//            }
//        }
//        Collections.sort(li,(xx,yy)->Double.compare(xx.s,yy.s));
//
//        init(n + 1);
//
//        int s = 0;
//        int c = n;
//        for (int i = 0; i < li.size(); ++i) {
//            int p1 = li.get(i).a;
//            int p2 = li.get(i).b;
//            if (root(p1) != root(p2)) {
//                combine(p1, p2);
//                c--;
//                if(c==k-1){
//                    print(roundS(Math.sqrt(li.get(i).s),2));
//                    break;
//                }
//            }
//        }

    }
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//    }

    static long mul(long a, long b, long p)
    {
        long res=0,base=a;
        while(b>0)
        {
            if((b&1L)>0)
                res=(res+base)%p;
            base=(base+base)%p;
            b>>=1;
        }
        return res;
    }

    static long mod_pow(long k,long n,long p){
        long res = 1L;
        long temp = (k%p+p)%p;
        while(n!=0L){
            if((n&1L)==1L){
                res = ((res*temp)%p+p)%p;
            }
            temp = ((temp * temp)%p+p)%p;
            n = n>>1L;
        }
        return res%p;
    }
    public static String roundS(double result, int scale){
        String fmt = String.format("%%.%df", scale);
        return String.format(fmt, result);
    }

//    void solve() {
//
//        for(int i=0;i<9;++i) {
//            for (int j = 0; j < 9; ++j) {
//                int v = ni();
//                a[i][j] = v;
//                if(v>0) {
//                    vis_row[i][v] = true;
//                    vis_col[j][v] = true;
//                    vis_room[get_room(i, j)][v] = true;
//                }else{
//                    space++;
//                }
//            }
//        }
//
//
//        prepare = new int[space][2];
//
//        int p = 0;
//
//        for(int i=0;i<9;++i) {
//            for (int j = 0; j < 9; ++j) {
//                if(a[i][j]==0){
//                    prepare[p][0] = i;
//                    prepare[p][1]= j;p++;
//                    List<Integer> temp =new ArrayList<>();
//                    for(int k=1;k<=9;++k){
//                        if(!vis_col[j][k]&&!vis_row[i][k]&&!vis_room[get_room(i,j)][k]){
//                            temp.add(k);
//                        }
//                    }
//                    int sz = temp.size();
//                    val[i][j] = new int[sz];
//                    for(int k=0;k<sz;++k){
//                        val[i][j][k] = temp.get(k);
//                    }
//                }
//            }
//        }
//        Arrays.sort(prepare,(x,y)->{
//           return Integer.compare(val[x[0]][x[1]].length,val[y[0]][y[1]].length);
//        });
//        dfs(0);
//
//
//
//
//
//
//
//
//
//
//    }

    InputStream is;
    PrintWriter out;

    void run() throws Exception {
        //is = new FileInputStream(new File("C:\\Users\\Luqi\\Downloads\\P3387_9.in"));
        is = System.in;
        out = new PrintWriter(System.out);

        solve();
        out.flush();
    }

    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private char ncc() {
        int b = readByte();
        return (char) b;
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private String nline() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!isSpaceChar(b) || b == ' ') {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[][] nm(int n, int m) {
        char[][] a = new char[n][];
        for (int i = 0; i < n; i++) a[i] = ns(m);
        return a;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = ni();
        return a;
    }

    private long[] nal(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) a[i] = nl();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) {
        }
        ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        while (true) {
            if (b >= '0' && b <= '9') num = (num << 3) + (num << 1) + (b - '0');
            else return minus ? -num : num;
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) {
        }
        ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        while (true) {
            if (b >= '0' && b <= '9') num = num * 10 + (b - '0');
            else return minus ? -num : num;
            b = readByte();
        }
    }

    void print(Object obj) {
        out.print(obj);
    }

    void println(Object obj) {
        out.println(obj);
    }

    void println() {
        out.println();
    }

    void printArray(int a[],int from){
        int l = a.length;
        for(int i=from;i<l;++i){
            print(a[i]);
            if(i!=l-1){
                print(" ");
            }
        }
        println();
    }

    void printArray(long a[],int from){
        int l = a.length;
        for(int i=from;i<l;++i){
            print(a[i]);
            if(i!=l-1){
                print(" ");
            }
        }
        println();
    }
}


import java.io.*;
import java.math.BigInteger;
import java.net.PortUnreachableException;
import java.util.*;

// written by luchy0120

public class Main {
    public static void main(String[] args) throws Exception {

        new Main().run();
    }

    static int groups = 0;
    static int[] fa;
    static int[] sz;

    static void init(int n) {
        groups = n;
        fa = new int[n];
        for (int i = 1; i < n; ++i) {
            fa[i] = i;
        }
        sz = new int[n];
        Arrays.fill(sz, 1);
    }

    static int root(int p) {
        while (p != fa[p]) {
            fa[p] = fa[fa[p]];
            p = fa[p];
        }
        return p;
    }

    static void combine(int p, int q) {
        int i = root(p);
        int j = root(q);
        if (i == j) {
            return;
        }
        if (sz[i] < sz[j]) {
            fa[i] = j;
            sz[j] += sz[i];
        } else {
            fa[j] = i;
            sz[i] += sz[j];
        }
        groups--;
    }

    int child[];
    int color[],dfn[],low[],stack[],cnt[];
    boolean vis[];
    boolean iscut[];
    int deep,top,n,m,sum,ans;
    List<Integer> g[];
    int root = 0;
    //  无向图的强连通分量
    void tarjanNonDirect(int u1) {

        int stk[] = new int[10001];
        int fatk[] = new int[10001];
        int p = 0;
        stk[p] = u1;
        fatk[p] = -1;
        p= 1;
        ot: while(p>0) {
            int u  = stk[p-1];
            int fa = fatk[p-1];

            if(dfn[u]==0) {
                low[u] = dfn[u] = ++deep;
            }
            // stack[top++] = u;

            for (; h[u] != -1; h[u] = ne[h[u]]) {
                int v = to[h[u]];
                if (dfn[v] == 0) {
                    //tarjanNonDirect(v);

                    fatk[p] = u;
                    stk[p++] = v;
                    continue ot;
                } else {
                    low[u] = Math.min(low[u], dfn[v]);
                    // 没有特判是否直接指向父亲
                    // 回边，使用dfn【v】更新low【u】,因为可能是指向父亲，而父亲的low可能比较小
                }
            }
            --p;

            if (fa != -1) {
                low[fa] = Math.min(low[fa], low[u]);
                if (low[u] >= dfn[fa]) {
                    if (fa != root || ++child[fa] > 1) {     // 不是root，直接记为cut，是root，判断是否有两个儿子
                        iscut[fa] = true;
                    }
                    ++dcc_cnt;
                    // 一个割点可能会被多个点双共享
                    //  int z = -1;
                    //    do {
                    //        z = stack[--top];
                    //      dcc[dcc_cnt].add(z);
                    //    } while(z != v);
                    //   dcc[dcc_cnt].add(u);
                }

            }

        }
    }
    int gd = 0;
    int id =-1;
    int scc_cnt = 0;
    int sccno[];
    // 有向图的强连通分量
    void tarjan(int u) {
        int stk[] = new int[10001];
        //   int tptk[] = new int[10001];

        //  int fatk[] = new int[10001];
        int p  =1; stk[0] = u;//fatk[0] =-1;
        ot:while(p>0) {
            u  = stk[p-1];
            //  int fa  = fatk[p-1];
            if (dfn[u] == 0) {
                low[u] = dfn[u] = ++deep;
                stack[top++] = u;

            }

            for (; hc[u] != -1; hc[u] = ne[hc[u]]) {
                int v = to[hc[u]];
                if (dfn[v] == 0) {
                    stk[p++] = v;
                    continue ot;
                    //  low[u] = Math.min(low[u], low[v]);
                } else if (sccno[v] == 0) {
                    // dfn>0 but sccno==0, means it's in current stack
                    low[u] = Math.min(low[u], low[v]);
                }
            }

            p--;
            if (dfn[u] == low[u]) {
                sccno[u] = ++scc_cnt;
                if(u==1){
                    id = scc_cnt;
                }

                while (stack[top - 1] != u) {
                    sccno[stack[top - 1]] = scc_cnt;
                    if(stack[top - 1]==1){
                        id = scc_cnt;
                    }
                    --top;
                }

                --top;
            }
            if(p>=1){
                int fa = stk[p-1];
                low[fa] = Math.min(low[fa], low[u]);
            }
        }
    }
    int rr =0;
//    void solve() {
//
//    }

//    int get_room(int i,int j){
//        return i/3*3 + j/3;
//    }

//    int a[][] = new int[9][9];
//    int space = 0;
//
//    boolean vis_row[][] = new boolean[9][10];
//    boolean vis_col[][] = new boolean[9][10];
//    boolean vis_room[][] = new boolean[9][10];
//    int val[][][] =new int[9][9][];
//    int prepare[][];
//
//    void dfs(int rt){
//
//    }

    int h[],to[],ne[];int ct =0;
    void add(int u,int v){
        // u--;v--;
        to[ct] = v;
        ne[ct] = h[u];
        h[u] = ct++;

    }

    int dcc_cnt = 0;
    int time = 0;

    long summ[];
    int v[];
    int hc[];
    void solve() {
        int t =ni();
        ot:for(int i=1;i<=t;++i){
            int n = ni();
            int k = ni();

            char c[] = ns().toCharArray();
            Arrays.sort(c);
            boolean first = true;
            StringBuilder sb = new StringBuilder();
            for(int j=0;j<n;){
                int nj = j+1;
                while(nj<n&&c[j]==c[nj])++nj;
                int len = nj-j;
                if(j==0) {
                    if (len < k) {
                        println(c[k-1]);
                        continue ot;
                    } else if (len%k!=0){
                        if(nj<n) {
                            for (int m = k - 1; m < n; ++m) {
                                print(c[m]);
                            }
                            println();
                        }else{
                            for (int m = 0; m < len/k+1; ++m) {
                                print(c[0]);
                            }
                            println();
                        }
                        continue ot;
                    } else{
                        for(int m=0;m<len/k;++m){
                            sb.append(c[0]);
                        }
                    }
                }else{
                    if (len%k!=0){
                        for(int m = k-1;m<n;++m){
                            print(c[m]);
                        }
                        println();
                        continue ot;
                    } else{
                        for(int m=0;m<len/k;++m){
                            sb.append(c[j]);
                        }
                    }
                }
                j = nj;
            }
            println(sb);
        }

//        int n = ni();
//        int m  = n*(n+1)/2;
//        int k = ni();
//        int p = 0;
//
//        double x[] = new double[n];
//        double y[] = new double[n];
//
//        for(int i=0;i<n;++i){
//            x[i] = nd();
//            y[i] = nd();
//        }
//
//        List<Item> li = new ArrayList<>();
//        for(int i=0;i<n;++i){
//            for(int j=i+1;j<n;++j){
//               double r =  (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]);
//               li.add(new Item(r,i,j));
//            }
//        }
//        Collections.sort(li,(xx,yy)->Double.compare(xx.s,yy.s));
//
//        init(n + 1);
//
//        int s = 0;
//        int c = n;
//        for (int i = 0; i < li.size(); ++i) {
//            int p1 = li.get(i).a;
//            int p2 = li.get(i).b;
//            if (root(p1) != root(p2)) {
//                combine(p1, p2);
//                c--;
//                if(c==k-1){
//                    print(roundS(Math.sqrt(li.get(i).s),2));
//                    break;
//                }
//            }
//        }

    }
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//    }

    static long mul(long a, long b, long p)
    {
        long res=0,base=a;
        while(b>0)
        {
            if((b&1L)>0)
                res=(res+base)%p;
            base=(base+base)%p;
            b>>=1;
        }
        return res;
    }

    static long mod_pow(long k,long n,long p){
        long res = 1L;
        long temp = (k%p+p)%p;
        while(n!=0L){
            if((n&1L)==1L){
                res = ((res*temp)%p+p)%p;
            }
            temp = ((temp * temp)%p+p)%p;
            n = n>>1L;
        }
        return res%p;
    }
    public static String roundS(double result, int scale){
        String fmt = String.format("%%.%df", scale);
        return String.format(fmt, result);
    }

//    void solve() {
//
//        for(int i=0;i<9;++i) {
//            for (int j = 0; j < 9; ++j) {
//                int v = ni();
//                a[i][j] = v;
//                if(v>0) {
//                    vis_row[i][v] = true;
//                    vis_col[j][v] = true;
//                    vis_room[get_room(i, j)][v] = true;
//                }else{
//                    space++;
//                }
//            }
//        }
//
//
//        prepare = new int[space][2];
//
//        int p = 0;
//
//        for(int i=0;i<9;++i) {
//            for (int j = 0; j < 9; ++j) {
//                if(a[i][j]==0){
//                    prepare[p][0] = i;
//                    prepare[p][1]= j;p++;
//                    List<Integer> temp =new ArrayList<>();
//                    for(int k=1;k<=9;++k){
//                        if(!vis_col[j][k]&&!vis_row[i][k]&&!vis_room[get_room(i,j)][k]){
//                            temp.add(k);
//                        }
//                    }
//                    int sz = temp.size();
//                    val[i][j] = new int[sz];
//                    for(int k=0;k<sz;++k){
//                        val[i][j][k] = temp.get(k);
//                    }
//                }
//            }
//        }
//        Arrays.sort(prepare,(x,y)->{
//           return Integer.compare(val[x[0]][x[1]].length,val[y[0]][y[1]].length);
//        });
//        dfs(0);
//
//
//
//
//
//
//
//
//
//
//    }

    InputStream is;
    PrintWriter out;

    void run() throws Exception {
        //is = new FileInputStream(new File("C:\\Users\\Luqi\\Downloads\\P3387_9.in"));
        is = System.in;
        out = new PrintWriter(System.out);

        solve();
        out.flush();
    }

    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private char ncc() {
        int b = readByte();
        return (char) b;
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private String nline() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!isSpaceChar(b) || b == ' ') {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[][] nm(int n, int m) {
        char[][] a = new char[n][];
        for (int i = 0; i < n; i++) a[i] = ns(m);
        return a;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = ni();
        return a;
    }

    private long[] nal(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) a[i] = nl();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) {
        }
        ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        while (true) {
            if (b >= '0' && b <= '9') num = (num << 3) + (num << 1) + (b - '0');
            else return minus ? -num : num;
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) {
        }
        ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        while (true) {
            if (b >= '0' && b <= '9') num = num * 10 + (b - '0');
            else return minus ? -num : num;
            b = readByte();
        }
    }

    void print(Object obj) {
        out.print(obj);
    }

    void println(Object obj) {
        out.println(obj);
    }

    void println() {
        out.println();
    }

    void printArray(int a[],int from){
        int l = a.length;
        for(int i=from;i<l;++i){
            print(a[i]);
            if(i!=l-1){
                print(" ");
            }
        }
        println();
    }

    void printArray(long a[],int from){
        int l = a.length;
        for(int i=from;i<l;++i){
            print(a[i]);
            if(i!=l-1){
                print(" ");
            }
        }
        println();
    }
}


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

public class Main {

    public static void main(String args[]){

        Scanner in = new Scanner(System.in);
        int testCases = in.nextInt();
        while (testCases!=0){
            testCases--;
            int n = in.nextInt();
            int m = in.nextInt();
            String s = in.next();
            char[] str = s.toCharArray();
            Arrays.sort(str);
            if(str[0]!=str[m-1]||m==n){
                System.out.println(str[m-1]);
                continue;
            }
            if(str[m]!=str[n-1]){
                for(int i=m-1;i<n;i++) {
                    System.out.print(str[i]);
                }
            } else {
                for(int i=0;i<n;i+=m){
                    System.out.print(str[i]);
                }
            }
            System.out.println();
        }
    }
}


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

public class Main {

    public static void main(String args[]){

        Scanner in = new Scanner(System.in);
        int testCases = in.nextInt();
        while (testCases!=0){
            testCases--;
            int n = in.nextInt();
            int m = in.nextInt();
            String s = in.nextLine();
            char[] str = s.toCharArray();
            Arrays.sort(str);
            if(str[0]!=str[m-1]||m==n){
                System.out.println(str[m-1]);
                continue;
            }
            if(str[m]!=str[n-1]){
                for(int i=m-1;i<n;i++) {
                    System.out.print(str[i]);
                }
            } else {
                for(int i=0;i<n;i+=m){
                    System.out.print(str[i]);
                }
            }
            System.out.println();
        }
    }
}


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

public class Main {

    public static void main(String args[]){

        Scanner in = new Scanner(System.in);
        int testCases = in.nextInt();
        while (testCases!=0){
            testCases--;
            int n = in.nextInt();
            int m = in.nextInt();
            String s = in.next();
            char[] str = s.toCharArray();
            Arrays.sort(str);
            if(str[0]!=str[m-1]){
                System.out.println(str[m-1]);
                continue;
            }
            if(str[m]!=str[n-1]){
                for(int i=m-1;i<n;i++) {
                    System.out.print(str[i]);
                }
            } else {
                for(int i=0;i<n;i+=m){
                    System.out.print(str[i]);
                }
            }
            System.out.println();
        }
    }
}


import java.io.*;
import java.util.*;

public class utkarsh {

    BufferedReader br;
    PrintWriter out;

    long mod = (long) (1e9 + 7), inf = (long) (3e18);

    void solve() {
        int t = ni();
        while(t-- > 0) {
            int n = ni(), k = ni();
            char s[] = ns().toCharArray();
            int a[] = new int[26];
            for(char c : s) a[c - 'a']++;

            boolean b = true;
            int cnt = 0;
            for(int i = 0; i < 26; i++) {
                if(a[i] > 0) {
                    cnt++;
                    if(a[i] != k)   b = false;
                }
            }
            if(b && cnt <= 2) {
                for(int i = 0; i < 26; i++) {
                    if(a[i] > 0) {
                        out.print((char)(i + 'a'));
                    }
                }
            } else {
                for(int i = 0; i < n; i++) {
                    int j = (int)(Math.random() * i);
                    char c = s[i];  s[i] = s[j];    s[j] = c;
                }
                Arrays.sort(s);
                if(s[n-1] == s[0]) {
                    while(n > 0) {
                        out.print(s[0]);    n -= k;
                    }
                } else if(s[k-1] == s[0]) {
                    for(int i = k-1; i < n; i++)    out.print(s[i]);
                } else {
                    out.print(s[k-1]);
                }
            }
            out.println();
        }
    }

    long gcd(long a, long b) {
        if(b == 0)  return a;
        return gcd(b, a % b);
    }

    long mp(long b, long e) {
        long r = 1;
        while(e > 0) {
            if( (e&1) == 1 )    r = (r * b) % mod;
            b = (b * b) % mod;
            e >>= 1;
        }
        return r;
    }

    // -------- I/O Template -------------

    char nc() {
        return ns().charAt(0);
    }

    String nLine() {
        try {
            return br.readLine();
        } catch(IOException e) {
            return "-1";
        }
    }

    double nd() {
        return Double.parseDouble(ns());
    }

    long nl() {
        return Long.parseLong(ns());
    }

    int ni() {
        return Integer.parseInt(ns());
    }

    StringTokenizer ip;

    String ns() {
        if(ip == null || !ip.hasMoreTokens()) {
            try {
                ip = new StringTokenizer(br.readLine());
            } catch(IOException e) {
                throw new InputMismatchException();
            }
        }
        return ip.nextToken();
    }

    void run() {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.flush();
    }

    public static void main(String[] args) {
        new utkarsh().run();
    }
}


import java.io.*;
import java.util.*;

public class utkarsh {

    BufferedReader br;
    PrintWriter out;

    long mod = (long) (1e9 + 7), inf = (long) (3e18);

    void solve() {
        int t = ni();
        while(t-- > 0) {
            int n = ni(), k = ni();
            char s[] = ns().toCharArray();
            int a[] = new int[26];
            for(char c : s) a[c - 'a']++;
            boolean b = true;
            for(int i = 0; i < 26; i++) {
                if(a[i] % k != 0)   b = false;
            }
            if(b) {
                for(int i = 0; i < 26; i++) {
                    while(a[i] > 0) {
                        a[i] -= k;
                        out.print((char)(i + 'a'));
                    }
                }
            } else {
                for(int i = 0; i < n; i++) {
                    int j = (int)(Math.random() * i);
                    char c = s[i];  s[i] = s[j];    s[j] = c;
                }
                Arrays.sort(s);
                if(s[n-1] == s[0]) {
                    while(n > 0) {
                        out.print(s[0]);    n -= k;
                    }
                } else if(s[k-1] == s[0]) {
                    for(int i = k-1; i < n; i++)    out.print(s[i]);
                } else {
                    out.print(s[k-1]);
                }
            }
            out.println();
        }
    }

    long gcd(long a, long b) {
        if(b == 0)  return a;
        return gcd(b, a % b);
    }

    long mp(long b, long e) {
        long r = 1;
        while(e > 0) {
            if( (e&1) == 1 )    r = (r * b) % mod;
            b = (b * b) % mod;
            e >>= 1;
        }
        return r;
    }

    // -------- I/O Template -------------

    char nc() {
        return ns().charAt(0);
    }

    String nLine() {
        try {
            return br.readLine();
        } catch(IOException e) {
            return "-1";
        }
    }

    double nd() {
        return Double.parseDouble(ns());
    }

    long nl() {
        return Long.parseLong(ns());
    }

    int ni() {
        return Integer.parseInt(ns());
    }

    StringTokenizer ip;

    String ns() {
        if(ip == null || !ip.hasMoreTokens()) {
            try {
                ip = new StringTokenizer(br.readLine());
            } catch(IOException e) {
                throw new InputMismatchException();
            }
        }
        return ip.nextToken();
    }

    void run() {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.flush();
    }

    public static void main(String[] args) {
        new utkarsh().run();
    }
}


import java.io.*;
import java.util.*;

public class utkarsh {

    BufferedReader br;
    PrintWriter out;

    long mod = (long) (1e9 + 7), inf = (long) (3e18);

    void solve() {
        int t = ni();
        while(t-- > 0) {
            int n = ni(), k = ni();
            char s[] = ns().toCharArray();
            int a[] = new int[26];
            for(char c : s) a[c - 'a']++;
            boolean b = true;
            for(int i = 0; i < 26; i++) {
                if(a[i] != k && a[i] != 0)   b = false;
            }
            if(b) {
                for(int i = 0; i < 26; i++) {
                    while(a[i] > 0) {
                        a[i] -= k;
                        out.print((char)(i + 'a'));
                    }
                }
            } else {
                for(int i = 0; i < n; i++) {
                    int j = (int)(Math.random() * i);
                    char c = s[i];  s[i] = s[j];    s[j] = c;
                }
                Arrays.sort(s);
                if(s[n-1] == s[0]) {
                    while(n > 0) {
                        out.print(s[0]);    n -= k;
                    }
                } else if(s[k-1] == s[0]) {
                    for(int i = k-1; i < n; i++)    out.print(s[i]);
                } else {
                    out.print(s[k-1]);
                }
            }
            out.println();
        }
    }

    long gcd(long a, long b) {
        if(b == 0)  return a;
        return gcd(b, a % b);
    }

    long mp(long b, long e) {
        long r = 1;
        while(e > 0) {
            if( (e&1) == 1 )    r = (r * b) % mod;
            b = (b * b) % mod;
            e >>= 1;
        }
        return r;
    }

    // -------- I/O Template -------------

    char nc() {
        return ns().charAt(0);
    }

    String nLine() {
        try {
            return br.readLine();
        } catch(IOException e) {
            return "-1";
        }
    }

    double nd() {
        return Double.parseDouble(ns());
    }

    long nl() {
        return Long.parseLong(ns());
    }

    int ni() {
        return Integer.parseInt(ns());
    }

    StringTokenizer ip;

    String ns() {
        if(ip == null || !ip.hasMoreTokens()) {
            try {
                ip = new StringTokenizer(br.readLine());
            } catch(IOException e) {
                throw new InputMismatchException();
            }
        }
        return ip.nextToken();
    }

    void run() {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.flush();
    }

    public static void main(String[] args) {
        new utkarsh().run();
    }
}


import java.io.*;
import java.util.*;

public class utkarsh {

    BufferedReader br;
    PrintWriter out;

    long mod = (long) (1e9 + 7), inf = (long) (3e18);

    void solve() {
        int t = ni();
        while(t-- > 0) {
            int n = ni(), k = ni();
            char s[] = ns().toCharArray();
            int a[] = new int[26];
            for(char c : s) a[c - 'a']++;

            boolean b = true;
            int cnt = 0;
            for(int i = 0; i < 26; i++) {
                if(a[i] > 0) {
                    cnt++;
                    if(cnt == 1) {
                        if(a[i] != k)   b = false;
                    } else if(cnt == 2) {
                    } else {
                        b = false;  break;
                    }
                }
            }
            if(b && cnt <= 2) {
                for(int i = 0; i < 26; i++) {
                    while(a[i] > 0) {
                        a[i] -= k;
                        out.print((char)(i + 'a'));
                    }
                }
            } else {
                for(int i = 0; i < n; i++) {
                    int j = (int)(Math.random() * i);
                    char c = s[i];  s[i] = s[j];    s[j] = c;
                }
                Arrays.sort(s);
                if(s[n-1] == s[0]) {
                    while(n > 0) {
                        out.print(s[0]);    n -= k;
                    }
                } else if(s[k-1] == s[0]) {
                    for(int i = k-1; i < n; i++)    out.print(s[i]);
                } else {
                    out.print(s[k-1]);
                }
            }
            out.println();
        }
    }

    long gcd(long a, long b) {
        if(b == 0)  return a;
        return gcd(b, a % b);
    }

    long mp(long b, long e) {
        long r = 1;
        while(e > 0) {
            if( (e&1) == 1 )    r = (r * b) % mod;
            b = (b * b) % mod;
            e >>= 1;
        }
        return r;
    }

    // -------- I/O Template -------------

    char nc() {
        return ns().charAt(0);
    }

    String nLine() {
        try {
            return br.readLine();
        } catch(IOException e) {
            return "-1";
        }
    }

    double nd() {
        return Double.parseDouble(ns());
    }

    long nl() {
        return Long.parseLong(ns());
    }

    int ni() {
        return Integer.parseInt(ns());
    }

    StringTokenizer ip;

    String ns() {
        if(ip == null || !ip.hasMoreTokens()) {
            try {
                ip = new StringTokenizer(br.readLine());
            } catch(IOException e) {
                throw new InputMismatchException();
            }
        }
        return ip.nextToken();
    }

    void run() {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.flush();
    }

    public static void main(String[] args) {
        new utkarsh().run();
    }
}


import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException,InterruptedException{
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t-->0) {
			int n=sc.nextInt();
			int k=sc.nextInt();
			char[] arr=sc.next().toCharArray();
			Arrays.sort(arr);
			String s=arr[0]+"";
			if (arr[k-1]!=arr[0]) {
				pw.println(arr[k-1]);
			}else if(k!=n&&arr[k]!=arr[n-1]) {
				for (int i = k; i < n; i++) {
					s+=arr[i];
				}
				pw.println(s);
			}else {
				for (int i = 0; i < (n-1)/k; i++) {
					s+=arr[n-1];
				}
				pw.println(s);
			}
		}
		pw.close();
    }
	static HashSet<Long> primes;
	static PrintWriter pw=new PrintWriter(System.out);
	static long pow(int a,int b) {
		long r=1l;
		for (int i = 0; i < b; i++) {
			r*=a;
		}
		return r;
	}
	static void primes() {
		boolean[] freq=new boolean[1000000];
		for (int i = 0; i < freq.length; i++) {
			freq[i]=true;
		}
		primes=new HashSet<>();
		for (int i = 2; i <= 1e3; i++) {
			if(freq[i-1]) {
				for (int j = i*i; j <= 1e6; j+=i) {
					freq[j-1]=false;
				}
			}
		}
		for (int i = 2; i < freq.length; i++) {
			if(freq[i-1]) primes.add((long)(i));
		}
	}
	static long gcd(long x,long y) {
		while (x!=y) {
			if(Math.max(x,y)/Math.min(x,y)==(double)(Math.max(x,y))/Math.min(x,y)) return Math.min(x,y);
			if(primes.contains(x)) {
				if(y/x==y/(double)x) return x;
				else return 1;
			}else if (primes.contains(y)) {
				if(x/y==x/(double)y) return y;
				else return 1;
			}
			if(x>y) x-=y;
			else y-=x;
		}
		return x;
	}
	static class pair implements Comparable<pair> {
		int x;
		int y;

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

		public String toString() {
			return x + " " + y;
		}
		public boolean equals(Object o) {
            if (o instanceof pair) {
                pair p = (pair)o;
                return p.x == x && p.y == y;
            }
            return false;
        }
        public int hashCode() {
            return new Double(x).hashCode() * 31 + new Double(y).hashCode();
        }
        public int compareTo(pair other) {
        	if(this.x==other.x) {
        		return Long.compare(this.y, other.y);
        	}
			return Long.compare(this.x, other.x);
		}
	}
	static class tuble implements Comparable<tuble> {
		int x;
		int y;
		int z;

		public tuble(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

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

		public int compareTo(tuble other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}
 	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public boolean hasNext() {
			// TODO Auto-generated method stub
			return false;
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}


import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException,InterruptedException{
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t-->0) {
			int n=sc.nextInt();
			int k=sc.nextInt();
			char[] arr=sc.next().toCharArray();
			Arrays.sort(arr);
			StringBuilder s=new StringBuilder();
			s.append(arr[0]+"");
			if (arr[k-1]!=arr[0]) {
				pw.println(arr[k-1]);
			}else if(k!=n&&arr[k]!=arr[n-1]) {
				for (int i = k; i < n; i++) {
					s.append(arr[i]);
				}
				pw.println(s);
			}else {
				for (int i = 0; i < (n-1)/k; i++) {
					s.append(arr[n-1]);
				}
				pw.println(s);
			}
		}
		pw.close();
    }
	static HashSet<Long> primes;
	static PrintWriter pw=new PrintWriter(System.out);
	static long pow(int a,int b) {
		long r=1l;
		for (int i = 0; i < b; i++) {
			r*=a;
		}
		return r;
	}
	static void primes() {
		boolean[] freq=new boolean[1000000];
		for (int i = 0; i < freq.length; i++) {
			freq[i]=true;
		}
		primes=new HashSet<>();
		for (int i = 2; i <= 1e3; i++) {
			if(freq[i-1]) {
				for (int j = i*i; j <= 1e6; j+=i) {
					freq[j-1]=false;
				}
			}
		}
		for (int i = 2; i < freq.length; i++) {
			if(freq[i-1]) primes.add((long)(i));
		}
	}
	static long gcd(long x,long y) {
		while (x!=y) {
			if(Math.max(x,y)/Math.min(x,y)==(double)(Math.max(x,y))/Math.min(x,y)) return Math.min(x,y);
			if(primes.contains(x)) {
				if(y/x==y/(double)x) return x;
				else return 1;
			}else if (primes.contains(y)) {
				if(x/y==x/(double)y) return y;
				else return 1;
			}
			if(x>y) x-=y;
			else y-=x;
		}
		return x;
	}
	static class pair implements Comparable<pair> {
		int x;
		int y;

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

		public String toString() {
			return x + " " + y;
		}
		public boolean equals(Object o) {
            if (o instanceof pair) {
                pair p = (pair)o;
                return p.x == x && p.y == y;
            }
            return false;
        }
        public int hashCode() {
            return new Double(x).hashCode() * 31 + new Double(y).hashCode();
        }
        public int compareTo(pair other) {
        	if(this.x==other.x) {
        		return Long.compare(this.y, other.y);
        	}
			return Long.compare(this.x, other.x);
		}
	}
	static class tuble implements Comparable<tuble> {
		int x;
		int y;
		int z;

		public tuble(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

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

		public int compareTo(tuble other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}
 	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public boolean hasNext() {
			// TODO Auto-generated method stub
			return false;
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}


import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException, InterruptedException {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		for (int i = 0; i < t; i++) {
			int n=sc.nextInt();
			int k=sc.nextInt();
			String s=sc.next();
			String r="";
			PriorityQueue<Character> pq=new PriorityQueue<>();
			char[] arr=new char[n];
			for (int j = 0; j < n; j++) {
				pq.add(s.charAt(j));
			}
			for (int j = 0; j < n; j++) {
				arr[j]=pq.poll();
			}
			if (arr[0]!=arr[k-1]) {
				pw.println(arr[k-1]);
			}else {
				if(arr[n-1]==arr[0]) {
					for (int j = 0; j < n-k; j++) r+=arr[j];
					pw.println(r);
				}else {
					Stack<Character> st=new Stack<>();
					char x=arr[n-1];
					for (int j = 0; j<n-k; j++) {
						if(j==0||arr[n-j-1]!=x) st.add(arr[n-j-1]);
					}
					pw.print(arr[0]);
					int m=st.size();
					for (int j = 0; j<m; j++) {
						pw.print(st.pop());
					}pw.println();
				}
			}
		}

	    pw.close();
	}

	static PrintWriter pw=new PrintWriter(System.out);
	static ArrayList<Integer>[] adjList;
	static boolean[] visited;
	static int max,day;
	static Stack<Integer> stack = new  Stack<>();
	static boolean binarysearch(long[] arr,long x) {
		int start=0,end=arr.length-1;
		while (start<=end) {
			int mid=(start+end)/2;
			if (arr[mid]==x) {
				return true;
			}else if (arr[mid]>x) {
				end=mid-1;
			}else {
				start=mid+1;
			}
		}
		return false;
	}
	static long gcd(int x,int y) {
		while (x!=y) {
			if(x>y) x-=y;
			else if(x<y) y-=x;
		}
		return x;
	}
	static long lcm(int x,int y) {
		return x*y/gcd(x,y);
	}
   	static void dfs(int u){
		visited[u] = true;
		for(int v : adjList[u]){
			if(!visited[v]){
				dfs(v);
			}
		}
		stack.add(u);
	}
   	static void bfs(int s){
		Queue<Integer> q = new LinkedList<>();
		q.add(s);
		visited[s] = true;
		int countday=0;
		while(!q.isEmpty()){
			int c=0;
			int m=q.size();
			for (int i = 0; i < m; i++) {
				int u=q.poll();
				for(int v : adjList[u]){
					if(!visited[v]){
						q.add(v);
						visited[v] = true;
						c++;
					}
				}
			}
//			pw.println(q);
			countday++;
			if(c>max) {
				max=c;
				day=countday;
			}
		}
	}

 	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public boolean hasNext() {
			// TODO Auto-generated method stub
			return false;
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}


import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException,InterruptedException{
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t-->0) {
			int n=sc.nextInt();
			int k=sc.nextInt();
			char[] arr=sc.next().toCharArray();
			Arrays.sort(arr);
			String s=arr[0]+"";
			if (arr[k-1]!=arr[0]) {
				pw.println(arr[k-1]);
			}else if(arr[k]!=arr[n-1]) {
				for (int i = k; i < n; i++) {
					s+=arr[i];
				}
				pw.println(s);
			}else {
				for (int i = 0; i < (n-1)/k; i++) {
					s+=arr[n-1];
				}
				pw.println(s);
			}
		}
		pw.close();
    }
	static HashSet<Long> primes;
	static PrintWriter pw=new PrintWriter(System.out);
	static long pow(int a,int b) {
		long r=1l;
		for (int i = 0; i < b; i++) {
			r*=a;
		}
		return r;
	}
	static void primes() {
		boolean[] freq=new boolean[1000000];
		for (int i = 0; i < freq.length; i++) {
			freq[i]=true;
		}
		primes=new HashSet<>();
		for (int i = 2; i <= 1e3; i++) {
			if(freq[i-1]) {
				for (int j = i*i; j <= 1e6; j+=i) {
					freq[j-1]=false;
				}
			}
		}
		for (int i = 2; i < freq.length; i++) {
			if(freq[i-1]) primes.add((long)(i));
		}
	}
	static long gcd(long x,long y) {
		while (x!=y) {
			if(Math.max(x,y)/Math.min(x,y)==(double)(Math.max(x,y))/Math.min(x,y)) return Math.min(x,y);
			if(primes.contains(x)) {
				if(y/x==y/(double)x) return x;
				else return 1;
			}else if (primes.contains(y)) {
				if(x/y==x/(double)y) return y;
				else return 1;
			}
			if(x>y) x-=y;
			else y-=x;
		}
		return x;
	}
	static class pair implements Comparable<pair> {
		int x;
		int y;

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

		public String toString() {
			return x + " " + y;
		}
		public boolean equals(Object o) {
            if (o instanceof pair) {
                pair p = (pair)o;
                return p.x == x && p.y == y;
            }
            return false;
        }
        public int hashCode() {
            return new Double(x).hashCode() * 31 + new Double(y).hashCode();
        }
        public int compareTo(pair other) {
        	if(this.x==other.x) {
        		return Long.compare(this.y, other.y);
        	}
			return Long.compare(this.x, other.x);
		}
	}
	static class tuble implements Comparable<tuble> {
		int x;
		int y;
		int z;

		public tuble(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

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

		public int compareTo(tuble other) {
			if (this.x == other.x) {
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}
 	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public boolean hasNext() {
			// TODO Auto-generated method stub
			return false;
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}


import java.io.*;
import java.util.*;
import java.math.*;

  public class B {

	InputStream is;
	static PrintWriter out;

	static int kmp(char txt[],char pat[],int k)
	{
		//char pat[]=pattern.toCharArray();

		int n=txt.length,m=pat.length;
		int lps[]=new int[m];
		lpsc(pat,m,lps);
		int i=0,j=0;
		int ans=-1;
		int ctr=0;
		while(i<n)
		{
			if(txt[i]==pat[j])
			{
				i++;
				j++;
			}
			if(j==m)
			{

				if((i-j+m)<=k && (i-j)!=0){
				ans=i-j;
				break;
				}
				j=lps[j-1];

			}
			else if(i<n && txt[i]!=pat[j])
			{
				if(j!=0)
					j=lps[j-1];
				else
					i=i+1;
			}
		}

		return ans;
	}

	static void lpsc(char pat[],int m,int lps[])
	{
		//char pat[]=pattern.toCharArray();
		int i=1,j=0;
		while(i<m)
		{
			if(pat[i]==pat[j])
			{
				j++;
				lps[i]=j;
				i++;
			}
			else
			{
				if(j!=0)
					j=lps[j-1];
				else
					i++;
			}
		}
	}

	void solve()
	{
		int t=ni();
		while(t-->0)
		{
			int n=ni(),k=ni();
			char ch[]=ns().toCharArray();
			Arrays.sort(ch);
			String s=String.valueOf(ch);

			String s1="",s2="";

			int f=0;
			for(int i=1;i<k;i++)
			{
				if(ch[i]!=ch[i-1]){
					f=1;break;}
			}

			if(f==1)
				out.println(ch[k-1]);
			else
			{

				String kk1="",kk2="";
				int st=k-1;
				if(n%k!=0)
					st=n%k-1;
				for(int i=st;i<n;i+=k)
				{
					s1+=ch[i];
				}
				/*for(int i=k-1;i<n;i+=k)
				{
					kk2+=ch[i];
				}
				if(kk1.compareTo(kk2)<=0)
					s1=kk2;
				else
					s1=kk1;*/

				s2=s.substring(k-1,n);
				//out.println(s1+" "+s2);
				if(s1.compareTo(s2)<=0)
					out.println(s1);
				else
					out.println(s2);

			}

		}
	}

    //---------- I/O Template ----------

    public static void main(String[] args) { new B().run(); }
    void run() {
        is = System.in;
        out = new PrintWriter(System.out);
        solve();
        out.flush();
    }

    byte input[] = new byte[1024];
    int len = 0, ptr = 0;

    int readByte() {
        if(ptr >= len) { ptr = 0;
            try { len = is.read(input); }
            catch(IOException e) { throw new InputMismatchException(); }
            if(len <= 0) { return -1; }
        } return input[ptr++];
    }
    boolean isSpaceChar(int c) { return !( c >= 33 && c <= 126 ); }
    int skip() {
        int b = readByte();
        while(b != -1 && isSpaceChar(b)) { b = readByte(); }
        return b;
    }

    char nc() { return (char)skip(); }
    String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while(!isSpaceChar(b)) { sb.appendCodePoint(b); b = readByte(); }
        return sb.toString();
    }
    String nLine() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while( !(isSpaceChar(b) && b != ' ') ) { sb.appendCodePoint(b); b = readByte(); }
        return sb.toString();
    }
    int ni() {
        int n = 0, b = readByte();
        boolean minus = false;
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')) { b = readByte(); }
        if(b == '-') { minus = true; b = readByte(); }
        if(b == -1) { return -1; }  //no input
        while(b >= '0' && b <= '9') { n = n * 10 + (b - '0'); b = readByte(); }
        return minus ? -n : n;
    }
    long nl() {
        long n = 0L;    int b = readByte();
        boolean minus = false;
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')) { b = readByte(); }
        if(b == '-') { minus = true; b = readByte(); }
        while(b >= '0' && b <= '9') { n = n * 10 + (b - '0'); b = readByte(); }
        return minus ? -n : n;
    }

    double nd() { return Double.parseDouble(ns()); }
    float nf() { return Float.parseFloat(ns()); }
    int[] na(int n) {
        int a[] = new int[n];
        for(int i = 0; i < n; i++) { a[i] = ni(); }
        return a;
    }
    char[] ns(int n) {
        char c[] = new char[n];
        int i, b = skip();
        for(i = 0; i < n; i++) {
            if(isSpaceChar(b)) { break; }
            c[i] = (char)b; b = readByte();
        } return i == n ? c : Arrays.copyOf(c,i);
    }
	static void pa(int a[])
	{
		for(int i=0;i<a.length;i++)
		out.print(a[i]+" ");
		out.println();
	}
	 static void pa(long a[])
	{
		for(int i=0;i<a.length;i++)
		out.print(a[i]+" ");
		out.println();
	}

}


import java.io.*;
import java.util.*;
import java.math.*;

  public class B {

	InputStream is;
	static PrintWriter out;

	static int kmp(char txt[],char pat[],int k)
	{
		//char pat[]=pattern.toCharArray();

		int n=txt.length,m=pat.length;
		int lps[]=new int[m];
		lpsc(pat,m,lps);
		int i=0,j=0;
		int ans=-1;
		int ctr=0;
		while(i<n)
		{
			if(txt[i]==pat[j])
			{
				i++;
				j++;
			}
			if(j==m)
			{

				if((i-j+m)<=k && (i-j)!=0){
				ans=i-j;
				break;
				}
				j=lps[j-1];

			}
			else if(i<n && txt[i]!=pat[j])
			{
				if(j!=0)
					j=lps[j-1];
				else
					i=i+1;
			}
		}

		return ans;
	}

	static void lpsc(char pat[],int m,int lps[])
	{
		//char pat[]=pattern.toCharArray();
		int i=1,j=0;
		while(i<m)
		{
			if(pat[i]==pat[j])
			{
				j++;
				lps[i]=j;
				i++;
			}
			else
			{
				if(j!=0)
					j=lps[j-1];
				else
					i++;
			}
		}
	}

	void solve()
	{
		int t=ni();
		while(t-->0)
		{
			int n=ni(),k=ni();
			char ch[]=ns().toCharArray();
			Arrays.sort(ch);
			String s=String.valueOf(ch);

			String s1="",s2="";

			int f=0;
			for(int i=1;i<k;i++)
			{
				if(ch[i]!=ch[i-1]){
					f=1;break;}
			}

			if(f==1)
				out.println(ch[k-1]);
			else
			{

				String kk1="",kk2="";
				int st=k-1;
				if(n%k!=0)
					st=n%k-1;
				for(int i=st;i<n;i+=k)
				{
					kk1+=ch[i];
				}
				for(int i=k-1;i<n;i+=k)
				{
					kk2+=ch[i];
				}
				/*for(int i=k-1;i<n;i+=k)
				{
					kk2+=ch[i];
				}*/
				if(kk1.compareTo(kk2)<=0)
					s1=kk2;
				else
					s1=kk1;

				s2=s.substring(k-1,n);
				//out.println(s1+" "+s2);
				if(s1.compareTo(s2)<=0)
					out.println(s1);
				else
					out.println(s2);

			}

		}
	}

    //---------- I/O Template ----------

    public static void main(String[] args) { new B().run(); }
    void run() {
        is = System.in;
        out = new PrintWriter(System.out);
        solve();
        out.flush();
    }

    byte input[] = new byte[1024];
    int len = 0, ptr = 0;

    int readByte() {
        if(ptr >= len) { ptr = 0;
            try { len = is.read(input); }
            catch(IOException e) { throw new InputMismatchException(); }
            if(len <= 0) { return -1; }
        } return input[ptr++];
    }
    boolean isSpaceChar(int c) { return !( c >= 33 && c <= 126 ); }
    int skip() {
        int b = readByte();
        while(b != -1 && isSpaceChar(b)) { b = readByte(); }
        return b;
    }

    char nc() { return (char)skip(); }
    String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while(!isSpaceChar(b)) { sb.appendCodePoint(b); b = readByte(); }
        return sb.toString();
    }
    String nLine() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while( !(isSpaceChar(b) && b != ' ') ) { sb.appendCodePoint(b); b = readByte(); }
        return sb.toString();
    }
    int ni() {
        int n = 0, b = readByte();
        boolean minus = false;
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')) { b = readByte(); }
        if(b == '-') { minus = true; b = readByte(); }
        if(b == -1) { return -1; }  //no input
        while(b >= '0' && b <= '9') { n = n * 10 + (b - '0'); b = readByte(); }
        return minus ? -n : n;
    }
    long nl() {
        long n = 0L;    int b = readByte();
        boolean minus = false;
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')) { b = readByte(); }
        if(b == '-') { minus = true; b = readByte(); }
        while(b >= '0' && b <= '9') { n = n * 10 + (b - '0'); b = readByte(); }
        return minus ? -n : n;
    }

    double nd() { return Double.parseDouble(ns()); }
    float nf() { return Float.parseFloat(ns()); }
    int[] na(int n) {
        int a[] = new int[n];
        for(int i = 0; i < n; i++) { a[i] = ni(); }
        return a;
    }
    char[] ns(int n) {
        char c[] = new char[n];
        int i, b = skip();
        for(i = 0; i < n; i++) {
            if(isSpaceChar(b)) { break; }
            c[i] = (char)b; b = readByte();
        } return i == n ? c : Arrays.copyOf(c,i);
    }
	static void pa(int a[])
	{
		for(int i=0;i<a.length;i++)
		out.print(a[i]+" ");
		out.println();
	}
	 static void pa(long a[])
	{
		for(int i=0;i<a.length;i++)
		out.print(a[i]+" ");
		out.println();
	}

}


import java.io.*;
import java.util.*;
import java.math.*;

  public class B {

	InputStream is;
	static PrintWriter out;

	static int kmp(char txt[],char pat[],int k)
	{
		//char pat[]=pattern.toCharArray();

		int n=txt.length,m=pat.length;
		int lps[]=new int[m];
		lpsc(pat,m,lps);
		int i=0,j=0;
		int ans=-1;
		int ctr=0;
		while(i<n)
		{
			if(txt[i]==pat[j])
			{
				i++;
				j++;
			}
			if(j==m)
			{

				if((i-j+m)<=k && (i-j)!=0){
				ans=i-j;
				break;
				}
				j=lps[j-1];

			}
			else if(i<n && txt[i]!=pat[j])
			{
				if(j!=0)
					j=lps[j-1];
				else
					i=i+1;
			}
		}

		return ans;
	}

	static void lpsc(char pat[],int m,int lps[])
	{
		//char pat[]=pattern.toCharArray();
		int i=1,j=0;
		while(i<m)
		{
			if(pat[i]==pat[j])
			{
				j++;
				lps[i]=j;
				i++;
			}
			else
			{
				if(j!=0)
					j=lps[j-1];
				else
					i++;
			}
		}
	}

	void solve()
	{
		int t=ni();
		while(t-->0)
		{
			int n=ni(),k=ni();
			char ch[]=ns().toCharArray();
			Arrays.sort(ch);
			String s=String.valueOf(ch);

			String s1="",s2="";

			int f=0;
			for(int i=1;i<k;i++)
			{
				if(ch[i]!=ch[i-1]){
					f=1;break;}
			}

			if(f==1)
				out.println(ch[k-1]);
			else
			{

				String kk1="",kk2="";
				for(int i=0;i<n;i+=k)
				{
					kk1+=ch[i];
				}
				for(int i=k-1;i<n;i+=k)
				{
					kk2+=ch[i];
				}
				if(kk1.compareTo(kk2)<=0)
					s1=kk2;
				else
					s1=kk1;

				s2=s.substring(k-1,n);
				//out.println(s1+" "+s2);
				if(s1.compareTo(s2)<=0)
					out.println(s1);
				else
					out.println(s2);

			}

		}
	}

    //---------- I/O Template ----------

    public static void main(String[] args) { new B().run(); }
    void run() {
        is = System.in;
        out = new PrintWriter(System.out);
        solve();
        out.flush();
    }

    byte input[] = new byte[1024];
    int len = 0, ptr = 0;

    int readByte() {
        if(ptr >= len) { ptr = 0;
            try { len = is.read(input); }
            catch(IOException e) { throw new InputMismatchException(); }
            if(len <= 0) { return -1; }
        } return input[ptr++];
    }
    boolean isSpaceChar(int c) { return !( c >= 33 && c <= 126 ); }
    int skip() {
        int b = readByte();
        while(b != -1 && isSpaceChar(b)) { b = readByte(); }
        return b;
    }

    char nc() { return (char)skip(); }
    String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while(!isSpaceChar(b)) { sb.appendCodePoint(b); b = readByte(); }
        return sb.toString();
    }
    String nLine() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while( !(isSpaceChar(b) && b != ' ') ) { sb.appendCodePoint(b); b = readByte(); }
        return sb.toString();
    }
    int ni() {
        int n = 0, b = readByte();
        boolean minus = false;
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')) { b = readByte(); }
        if(b == '-') { minus = true; b = readByte(); }
        if(b == -1) { return -1; }  //no input
        while(b >= '0' && b <= '9') { n = n * 10 + (b - '0'); b = readByte(); }
        return minus ? -n : n;
    }
    long nl() {
        long n = 0L;    int b = readByte();
        boolean minus = false;
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')) { b = readByte(); }
        if(b == '-') { minus = true; b = readByte(); }
        while(b >= '0' && b <= '9') { n = n * 10 + (b - '0'); b = readByte(); }
        return minus ? -n : n;
    }

    double nd() { return Double.parseDouble(ns()); }
    float nf() { return Float.parseFloat(ns()); }
    int[] na(int n) {
        int a[] = new int[n];
        for(int i = 0; i < n; i++) { a[i] = ni(); }
        return a;
    }
    char[] ns(int n) {
        char c[] = new char[n];
        int i, b = skip();
        for(i = 0; i < n; i++) {
            if(isSpaceChar(b)) { break; }
            c[i] = (char)b; b = readByte();
        } return i == n ? c : Arrays.copyOf(c,i);
    }
	static void pa(int a[])
	{
		for(int i=0;i<a.length;i++)
		out.print(a[i]+" ");
		out.println();
	}
	 static void pa(long a[])
	{
		for(int i=0;i<a.length;i++)
		out.print(a[i]+" ");
		out.println();
	}

}