/**
*
* https://c...content-available-to-author-only...s.com/blog/entry/75011#comment-591464
*
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define deb(x) cout<<#x<<" : "<<x<<"\n";
#define debug(x, y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define all(a) (a).begin(),(a).end()
#define bs binary_search
#define sz size()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define clr fflush(stdout);
//#define clr cout.flush();
#define N 100001
#define fpr(i, a, b) for(int i=a;i<b;i++)
#define fdr(i, a, b) for(int i=a;i>b;i--)
#define repp(i, a, b, d) for(int i=a;i<b;i+=d)
#define repd(i, a, b, d) for(int i=a;i>b;i-=d)
#define LLMIN LLONG_MIN
#define LLMAX LLONG_MAX
#define AKASH_PATEL ios_base::sync_with_stdio(false);
#define SVNIT_SURAT cin.tie(NULL);cout.tie(NULL);
#define mset(x, a) memset(x,a,sizeof(x));
#define nl cout<<'\n';
#define print(c) cout<<c<<'\n';
#define setp(n) cout << fixed << setprecision(n)
#define take_arr(a, n) fpr(i,0,n) cin>>a[i];
#define print_arr(a, n) for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';
#define take_mat(mat, n, m) fpr(i,0,n) fpr(j,0,m) cin>>mat[i][j];
#define set_mat(mat, n, m, k) fpr(i,0,n) fpr(j,0,m) mat[i][j]=k;
#define print_mat(dist, n, m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}
template<class T>
bool inside(T a, T b, T c) { return a <= b && b <= c; }
ll ans=0;
ll n,k;
struct trie
{
trie *a[26];
int weight;
int depth;
trie()
{
for(int i=0;i<26;i++)
{
a[i]=NULL;
}
weight=0;
}
};
void *insert(string s,int wt,trie *root)
{
// if(!root->a[curr])
// {
// root->a[curr]=new trie();
// }
// (root->a[curr]->weight)++;
// if(idx+1!=s.size())
// {
// root->a[curr]=insert(s,wt,idx+1,root->a[curr]);
// }
// return root;
int curr,d=1;
fpr(i,0,s.sz)
{
curr=s[i]-'A';
if(!root->a[curr])
{
root->a[curr]=new trie();
}
root=root->a[curr];
root->weight++;
root->depth=d++;
}
}
int searchBest(string s,trie *root)
{
int idx=0,curr,max=-1,n=s.size();
while(idx<n)
{
curr=s[idx]-'A';
if(!root->a[curr])
return -1;
max=root->a[curr]->weight;
root=root->a[curr];
idx++;
}
return max;
}
void print1(trie *root) // change here
{
for(long i=0;i<26;i++)
{
if(root->a[i])
{
print1(root->a[i]);
}
}
ans+=root->weight/k;
// cout<<s<<'\n';
// cout<<root->weight<<'\n';
}
int main() {
AKASH_PATEL;
SVNIT_SURAT;
int t;
cin >> t;
fpr(tas, 1, t + 1) {
ans=0;
cin>>n>>k;
trie *node=new trie();
string s[n];
take_arr(s,n)
fpr(i,0,n)
{
insert(s[i],1,node);
}
print1(node); // changed here
cout << "Case #" << tas << ": " << ans << '\n';
}
return 0;
}
LyoqCiAqIAogKiBodHRwczovL2MuLi5jb250ZW50LWF2YWlsYWJsZS10by1hdXRob3Itb25seS4uLnMuY29tL2Jsb2cvZW50cnkvNzUwMTEjY29tbWVudC01OTE0NjQKICogCioqLwoKCiNpbmNsdWRlPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgbW9kIDEwMDAwMDAwMDcKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBtcCBtYWtlX3BhaXIKI2RlZmluZSBkZWIoeCkgY291dDw8I3g8PCIgOiAiPDx4PDwiXG4iOwojZGVmaW5lIGRlYnVnKHgsIHkpIGNvdXQ8PCN4PDwiIDogIjw8eDw8Ilx0Ijw8I3k8PCIgOiAiPDx5PDwiXG4iOwojZGVmaW5lIGZmIGZpcnN0CiNkZWZpbmUgc3Mgc2Vjb25kCiNk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nByKGksMCxzLnN6KQogICAgewogICAgICAgIGN1cnI9c1tpXS0nQSc7CiAgICAgICAgaWYoIXJvb3QtPmFbY3Vycl0pCiAgICAgICAgewogICAgICAgICAgICByb290LT5hW2N1cnJdPW5ldyB0cmllKCk7CiAgICAgICAgfQogICAgICAgIHJvb3Q9cm9vdC0+YVtjdXJyXTsKICAgICAgICByb290LT53ZWlnaHQrKzsKICAgICAgICByb290LT5kZXB0aD1kKys7CiAgICB9Cn0KaW50IHNlYXJjaEJlc3Qoc3RyaW5nIHMsdHJpZSAqcm9vdCkKewoJaW50IGlkeD0wLGN1cnIsbWF4PS0xLG49cy5zaXplKCk7Cgl3aGlsZShpZHg8bikKCXsKCQljdXJyPXNbaWR4XS0nQSc7CgkJaWYoIXJvb3QtPmFbY3Vycl0pCgkJCXJldHVybiAtMTsKCQltYXg9cm9vdC0+YVtjdXJyXS0+d2VpZ2h0OwoJCXJvb3Q9cm9vdC0+YVtjdXJyXTsKCQlpZHgrKzsKCX0KCXJldHVybiBtYXg7Cn0Kdm9pZCBwcmludDEodHJpZSAqcm9vdCkgLy8gY2hhbmdlIGhlcmUKewoJZm9yKGxvbmcgaT0wO2k8MjY7aSsrKQoJewoJCWlmKHJvb3QtPmFbaV0pCgkJewoJCQlwcmludDEocm9vdC0+YVtpXSk7CgkJfQoJfQoJYW5zKz1yb290LT53ZWlnaHQvazsKLy8JY291dDw8czw8J1xuJzsKLy8JY291dDw8cm9vdC0+d2VpZ2h0PDwnXG4nOwp9CmludCBtYWluKCkgewogICAgQUtBU0hfUEFURUw7CiAgICBTVk5JVF9TVVJBVDsKICAgIGludCB0OwogICAgY2luID4+IHQ7CiAgICBmcHIodGFzLCAxLCB0ICsgMSkgewogICAgICAgIGFucz0wOwogICAgICAgIGNpbj4+bj4+azsKICAgICAgICB0cmllICpub2RlPW5ldyB0cmllKCk7CiAgICAgICAgc3RyaW5nIHNbbl07CiAgICAgICAgdGFrZV9hcnIocyxuKQogICAgICAgIGZwcihpLDAsb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