2014/9/11
水到自己都不知道自己会不会了。
// ʧ°ÜÕßÓÃʧ°ÜËß˵Õæʵ£¬³É¹¦ÕßÓóɹ¦ÑÚÊÎÊÂʵ¡£
//Ñô¹â´ÌÍ´Ë«íø
//
#include<stdio.h>
#include<string.h>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<queue>
#include<stack>
#include<map>
#include<climits>
#include<vector>
using namespace std;
typedef long long ll;
#define f(x,y,i) for(int i = x;i < y; i++)
#define ff(x,y,i) for(int i = x;i <= y; i++)
#define F(x,y,i) for(int i = x; i >= y; i--)
#define FF(x,y,i) for(int i = x; i > y; i++)
#define lson pos<<1,l,mid
#define rson pos<<1|1,mid+1,r
#define Min(x,y) x<y?x:y
#define Max(x,y) x>y?x:y
#define sc(n) scanf("%d",&n)
#define pr(n) printf("%d\n",n)
#define met(n,m) memset(n, m, sizeof(n))
const int N=1005000;
int n, m , len;
char s[N];
int next[N];
void Next()
{
int p = 0;
for(int i = 2; i <= len; ++i)
{
while(p > 0&&s[p+1] != s[i])
{
p = next[p];
}
if(s[p+1] == s[i])
{
p++;
}
next[i] = p;
}
}
int main()
{
int cnt = 0;
while(~scanf("%d",&n))
{
if(!n)break;
getchar();
scanf("%s",s+1);
len = strlen(s+1);
printf("Test case #%d\n",++cnt);
Next();
for(int i = 2;i <= len; ++i)
{
if(i%(i-next[i])==0 && (i/(i-next[i])>1))
{
printf("%d %d\n",i,i/(i-next[i]));
}
}
printf("\n");
}
return 0;
}