n=int(input())
c=1
while n:
 print("Case %d, N = %d, # of different labelings = %d"%(c,n,n**(n-2)))
 n=int(input())
 c+=1
01010111011001010110110001100011011011110110110101100101001000000110001001101111011011000110111101100100
