#include <iostream>
#include <istream>
#include <sstream>
#include <vector>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cmath>
#include <cctype>
#include <string>
#include <cstdio>
#include <iomanip>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <iterator>
using namespace std;
const int maxn = 1e6 + 7;
int n;
char input[maxn];
int fail[maxn];
int main()
{
int kCase = 0;
while (cin >> n && n) {
cin >> (input);
fail[0] = fail[1] = -1;
int i = 0, j = -1;
while (i < n) {
if (j == -1 || input[j] == input[i])fail[++i] = ++j;
else j = fail[j];
}
cout << "Test case #" << ++kCase << endl;
for (int i = 2; i <= n; i++) {
if (fail[i] > 0 && i % (i - fail[i]) == 0) {
cout << i << " " << i / (i - fail[i]) << endl;
}
}
cout << endl;
}
return 0;
}
10-27
679