static int process(String line) {
		int cases = Integer.parseInt(line.trim());
		for(int c = 1; c <= cases; c++) {
			line = readLine().trim();
			StringBuffer temp = new StringBuffer();
			for(char ch : line.trim().toCharArray()) {
				if(Character.isAlphabetic(ch)){
					temp.append(ch);
				}
			}
			String a = temp.toString();
			String rev = new StringBuffer(a).reverse().toString();
			int len = a.length();
			int k = (int) Math.sqrt(len);
			String out = "No magic :(";
			if(k*k == len && rev.compareTo(a) == 0) {
				char[] arr = a.toCharArray();
				char[] n = new char[arr.length];
				for(int i = 0; i < k; i++) {
					for(int j = 0; j < k; j++) {
						n[(j*k) + i] = arr[(i*k) + j];
					}
				}
				
				String t = new String(n);
				if(t.compareTo(a) == 0) {
					out = Integer.toString(k);
				}
			}
			System.out.println("Case #"+c+":");
			System.out.println(out);			
		}
		
		return 0;
	}