xs = []
for i in xrange(0,16):
    for j in xrange(0,16):
        if i + j > 15: continue
        for k in xrange(0,16):
            if i + j + k > 15: continue
            for l in xrange(0,16):
                if i + j + k + l > 15: continue
                for m in xrange(0,16):
                    n = 15 - i - j - k - l - m
                    if n >= 0:
                        xs.append((i, j, k, l, m, n))
xs.sort()

ys = {}
for x, y in enumerate(xs): ys[y] = x

t = 0
while True:
    t = t + 1
    l = raw_input().split(' ')
    if l[0] == 'e': break
    if l[0] == 'm':
        y = tuple(map(int, l[1:]))
        print "Case {}: {}".format(t, ys[y])
    else:
        print "Case {}: {}".format(t, ' '.join(map(str, xs[int(l[1])])))