//#include<bits/stdc++.h>
#include<string>
#include<algorithm>
#include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 1e6+;
char s[maxn];
int next[maxn],n,T;
void cal(){
next[] = ;
for(int i = ,j = ;i <= n; ++i){
while(j> && s[i] != s[j+]) j = next[j];
if(s[i] == s[j+]) j++;
next[i] = j;
}
}
int main(){
while(cin >> n && n){
// memset(next,0,sizeof(next));
scanf("%s",s+);
cal();
printf("Test case #%d\n",++T);
for(int i = ;i <= n; i++){
if(i%(i-next[i])== && i/(i-next[i]) > )
printf("%d %d\n",i , i/(i-next[i]));
}
puts("");
}
// return 0;
}