#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;

	}
}
			