n=int(input())
for p in range(n):
    t=int(input())
    for i in range(t,0,-1):
        a=[j for j in str(i)]
        if a==sorted(a):
            b="".join(a)
            print(" Case #{}: {}".format(p+1,b))
            break

0f127283d2f4b47bea1aceb10583e4c89d0075c2
<mask token>

<mask token>
for p in range(n):
    t = int(input())
    for i in range(t, 0, -1):
        a = [j for j in str(i)]
        if a == sorted(a):
            b = ''.join(a)
            print(' Case #{}: {}'.format(p + 1, b))
            break

n = int(input())
for p in range(n):
    t = int(input())
    for i in range(t, 0, -1):
        a = [j for j in str(i)]
        if a == sorted(a):
            b = ''.join(a)
            print(' Case #{}: {}'.format(p + 1, b))
            break

n=int(input())
for p in range(n):
    t=int(input())
    for i in range(t,0,-1):
        a=[j for j in str(i)]
        if a==sorted(a):
            b="".join(a)
            print(" Case #{}: {}".format(p+1,b))
            break
