#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <exception>
#include <cstring>
#include <stdlib.h>
using namespace std;
const int Len=1000000;
int next[Len+5];
void getNext(int next[],char str[])
{
int len=strlen(str);
int i=0,j=-1;
while(i<len)
{
if((j==-1)||(str[i]==str[j]))
{
j++;
i++;
next[i]=j;
}
else j=next[j];
}
return;
}
void print(int next[],int len)
{
for(int i=0;i<len;i++)
printf("%d ",next[i]);
}
int cmp(char s1[],char s2[])
{
int i=0,j=0;//i->s1,j->s2
int len1=strlen(s1),len2=strlen(s2);
int times=0;
while(i<len1)
{
if((j==-1)||(s1[i]==s2[j]))
{
i++;
j++;
if(j>=len2)
{
j=0;
times++;
}
}
else j=next[j];
}
return times;
}
int main(int argc, char **argv)
{
int n,id=0;
char str1[Len+5];
memset(next,0,sizeof(next));
next[0]=-1;
while(scanf("%d",&n)==1)
{
if(n==0) break;
id++;
scanf("%s",str1);
int len1=strlen(str1);
str1[len1]='.';
str1[len1+1]='\0';
getNext(next,str1);
len1=strlen(str1);
//print(next,len1);
//cout<<endl;
printf("Test case #%d\n",id);
for(int i=2;i<len1;i++)
{
if(i%(i-next[i])==0)
{
if(i/(i-next[i])>1)
printf("%d %d\n",i,i/(i-next[i]));
}
}
cout<<endl;
}
return 0;
}