// Arup Guha
// 9/9/2025
// Solution to 2025 CIS 3362 Homework Question #4 (adjusted my solution to 2010 UCF HS Online Contest Problem)

import java.util.*;

public class railfence {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();
		
		// Process cases.
		for (int loop=0; loop<numCases; loop++) {
			
			// Get # of rows and start row.
			int rows = stdin.nextInt();
			int start = stdin.nextInt();

			// Read, solve and output!
			String line = stdin.next();
			String ans = solve(line, rows, start-1);
			System.out.println(ans);
		}
	}

	// Returns the corresponding ciphertext for encoding line with rows # of rows and starting at 0-based row number start.
	public static String solve(String line, int rows, int start) {

		// So you get no array out of bounds!
		if (rows == 1) return line;

		// Will store each row as a String...
		String[] fence = new String[rows];
		for (int i=0; i<rows; i++)
			fence[i] = "";

		int rIndex = 0;
		int dir = 1;

		// Place text in rows. Use dir and rIndex to figure out next row.
		for (int i=0; i<line.length(); i++) {

			// Add to this row.
			fence[rIndex] = fence[rIndex] + line.charAt(i);

			// Update next row and switch directions, if necessary.
			rIndex = rIndex+dir;
			if (rIndex < 0) {
				dir = -dir;
				rIndex = 1;
			}
			else if (rIndex >= rows) {
				dir = -dir;
				rIndex = rows-2;
			}
		}

		// Loop through rows in order desired.
		String ans = "";
		for (int i=start; i<start+rows; i++)
			ans = ans+fence[i%rows];

		// Here it is!
		return ans;
	}
}