#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define nl cout<<endl
#define pii pair<ll,ll>
#define vi vector<ll>
#define vii vector<pii>
#define mi map<ll,ll>
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define ff first
#define ss second
#define hell 1000000007
#define test4(x,y,z,a) cout<<"x is "<<x<<" y is "<<y<<" z is "<<z<<" a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<" y is "<<y<<" z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<" y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009
ll power(ll a,ll b,ll m)
{
ll ans=1;
while(b)
{
if(b&1)
ans=(ans*a)%m;
b/=2;
a=(a*a)%m;
}
return ans;
}
map<ll,vi> mp;
typedef struct node
{
node* val[27];
ll cnt=0;
ll depth=0;
}trie;
void insert(trie *head,string s)
{
trie* curr = head;
ll lol=1;
rep(i,0,s.length())
{
ll haha=s[i]-'A';
if(!curr -> val[haha])
curr->val[haha]= new trie();
curr=curr-> val[haha];
(curr->cnt)++;
curr->depth=lol++;
}
}
void traverse(trie *head)
{
if(head == NULL)
return;
trie* curr=head;
rep(i,0,26)
{
trie* curr1=curr->val[i];
if(curr1!=NULL)
{
if(curr1->cnt)
mp[curr1->depth].pb(curr1->cnt);
}
traverse(curr1);
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll t;cin>>t;
rep(ppp,1,t+1)
{
cout<<"Case #"<<ppp<<": ";
ll n,k;cin>>n>>k;
mp.clear();
trie* head = new trie();
rep(i,1,n+1)
{
string s;cin>>s;
insert(head,s);
}
traverse(head);
ll ans=0;
for(auto it=mp.begin();it!=mp.end();it++)
{
vi vv=it->ss;
rep(i,0,vv.size())
{
ans+=vv[i]/k;
}
}
cout<<ans<<endl;
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbm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