using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
public class Solution {
static void Main(String[] args) {
int t = Convert.ToInt32(Console.ReadLine());
for(int a0 = 0; a0 < t; a0++){
string[] tokens_n = Console.ReadLine().Split(' ');
int n = Convert.ToInt32(tokens_n[0]);
int k = Convert.ToInt32(tokens_n[1]);
string num = Console.ReadLine();
Console.WriteLine(StringToList(num,n,k));
}
}
static long StringToList(string n, int len , int subLen)
{
long max=long.MinValue;
for(var i=0; i<len-subLen; i++)
{
long p = ProdcutOfDigit(n.Substring(i,subLen));
if(p>max)
{
max =p;
}
}
return max;
}
static long ProdcutOfDigit(string n)
{
long m =1;
var arr = n.ToCharArray().ToList().Select(s=>Convert.ToInt64(s.ToString())).ToList();
foreach(var i in arr)
{
m*=i;
}
return m;
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKdXNpbmcgU3lzdGVtLklPOwp1c2luZyBTeXN0ZW0uTGlucTsKcHVibGljIGNsYXNzIFNvbHV0aW9uIHsKICAgIHN0YXRpYyB2b2lkIE1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIGludCB0ID0gQ29udmVydC5Ub0ludDMyKENvbnNvbGUuUmVhZExpbmUoKSk7CiAgICAgICAgZm9yKGludCBhMCA9IDA7IGEwIDwgdDsgYTArKyl7CiAgICAgICAgICAgIHN0cmluZ1tdIHRva2Vuc19uID0gQ29uc29sZS5SZWFkTGluZSgpLlNwbGl0KCcgJyk7CiAgICAgICAgICAgIGludCBuID0gQ29udmVydC5Ub0ludDMyKHRva2Vuc19uWzBdKTsKICAgICAgICAgICAgaW50IGsgPSBDb252ZXJ0LlRvSW50MzIodG9rZW5zX25bMV0pOwogICAgICAgICAgICBzdHJpbmcgbnVtID0gQ29uc29sZS5SZWFkTGluZSgpOwogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZShTdHJpbmdUb0xpc3QobnVtLG4saykpOwogICAgICAgIH0KICAgIH0KICA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1000 13
7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450