public static void main(String args[]) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

		for (int circle = 1; ; circle++) {
			int number = Integer.parseInt(reader.readLine());

			if (number != 0) {
				String currentStr = reader.readLine();

				System.out.println("Test case #" + circle);
				int repeatIndex = -1;	//重复串的尾部位置
				for (int currentIndex = 1; currentIndex<number ; currentIndex++) {
					if (repeatIndex == -1) {
						if (currentIndex%2==1
								&& currentStr.substring(0, (currentIndex+1)/2).equals(currentStr.substring((currentIndex+1)/2, currentIndex+1))) {
							System.out.println(currentIndex+1 + " " + 2);
							repeatIndex = (currentIndex-1)/2;
						}
					} else {
						if ((currentIndex+1)%(repeatIndex+1) == 0) {
							if (currentStr.substring(0, repeatIndex+1).equals(currentStr.substring(currentIndex-repeatIndex, currentIndex+1))) {
								System.out.println(currentIndex+1 + " " + (currentIndex+1)/(repeatIndex+1));
							} else {
								repeatIndex = currentIndex;
							}
						}
					}
				}
				System.out.println();
			} else {
				break;
			}
		}
	}