round = input()
count = 0
weight = 0
num = 0
for r in xrange(1,round+1):
	case = raw_input().split()
	for i in xrange(len(case)): 
		case[i] = int(case[i])
	n = raw_input().split()
	n.sort()
	for m in xrange(len(n)):
		 n[m] = int(n[m])
	for l in n:
		if weight < case[2]  and weight + l < case[2] and count < case[1]:
					weight += l
					count += 1
		num += 1
	print "Case %d: %d" % (r, count)
	count,case,n,weight,num = 0,'','',0,0
