CN = io.stdin:read("*n")
for C=1, CN, 1 do
	io.stdout:write( string.format("Case #%d: ", C) )

	N = io.stdin:read("*n")
	M = io.stdin:read("*n")

	fav = {}
	for i=1, M, 1 do
		T = io.stdin:read("*n")
		fav[i] = {}
		for j=1, T, 1 do
			X, Y = io.stdin:read("*n", "*n")
			fav[i][j] = {X, Y}
		end
	end

	io.stdout:write( string.format("%d %d\n", N, M) )
end
