import sys

CN = int(sys.stdin.next())
for C in range(1, CN+1):
	print "Case #%d:"%(C),
	N = int(sys.stdin.next())
	M = int(sys.stdin.next())
	for i in range(0, M):
		a = map(int, sys.stdin.next().split(" "))
		print a
	print N, M
