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