/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>
typedef long long LL;
using namespace std;
int n;
char s[1000005];
int fail[1000005], len;
void getfail(){
int x = -1;
fail[0] = -1;
for (int i = 1; i < len; i++){
while(x >= 0 && s[i] != s[x + 1]){
x = fail[x];
}
if(s[i] == s[x + 1]) x++;
fail[i] = x;
}
}
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
int cas = 1;
while(scanf("%d", &n) == 1){
if(!n) break;
scanf("%s", s);
len = strlen(s);
getfail();
printf("Test case #%d\n", cas++);
for (int i = 1; i < len; i++){
if((i + 1) % (i - fail[i]) == 0 && (i + 1) / (i - fail[i]) != 1){
printf("%d %d\n", i + 1, (i + 1) / (i - fail[i]));
}
}
printf("\n");
}
return 0;
}
/**/