#include <iostream>
#include <string>
using namespace std;
//英语 看博友分析 抄博友程序 KMP next数组 背
string s;
int nex[1000008];
void get_next()
{
int i=0;
nex[i]=-1;
int j=-1;
while(i<s.size())
{
if(j==-1||s[j]==s[i])
{
i++;
j++;
nex[i]=j;
}else
{
j=nex[j];
}
}
}
int main()
{
int n;
int tag=0;
while(cin>>n)
{
if(n==0)
{
break;
}
cin>>s;
get_next();
tag++;
cout<<"Test case #"<<tag<<endl;
for(int i=2;i<=n;i++)
{
if(nex[i]!=-1)
{
int l=i-nex[i];
if(i%l==0&&i!=l)
{
cout<<i<<" "<<i/l<<endl;
}
}
}
cout<<endl;
}
return 0;
}