def A(a,b):
  return a+b
def S(a,b):
  return a-b
def M(a,b):
  return a*b
def D(a,b):
  if b==0 or a%b:
    raise Exception
  return a/b

ops = ["A", "S", "M", "D"]
vs = ["a", "b", "c", "d"]
Ss = [
"{2}({1}({0}({3},{4}),{5}),{6})",
"{2}({0}({3},{4}),{1}({5},{6}))",
"{2}({1}({3},{0}({4},{5})),{6})",
"{2}({3},{1}({4},{0}({5},{6})))",
"{2}({3},{1}({0}({4},{5}),{6}))",
"{2}({3},{1}({4},{0}({5},{6})))"]

t = 1
while True:
  a, b, c, d = [int(i) for i in raw_input().split()]
  if not a:
    break
  s = set([])
  for e in ops:
    for f in ops:
      for g in ops:
        for h in vs:
          for j in vs:
            for k in vs:
              for l in vs:
                St = set([h,j,k,l])
                if len(St) < 4:
                  continue
                for Sz in Ss:
                  Sf = Sz.format(e,f,g,h,j,k,l)
                  try:
                    V = eval(Sf)
                  except:
                    pass
                  else:
                    s.add(V)
  s = sorted(list(s))
  mx, mxa, mxb = 0, 0, 0
  for i in xrange(len(s)):
    v, z, b = s[i]-1, 0, s[i]
    j = i
    while j < len(s) and s[j] == v+1:
      v = s[j]
      j += 1
      z += 1
    if z >= mx:
      mx = z
      mxa = b
      mxb = s[j-1]
  print "Case {0}: {1} to {2}".format(t,mxa,mxb)
  t += 1