fact = [1] 
for n in range(1, 12):
    fact.append(fact[n-1] * n)

for b in range(9, 12+1):
    print(f)
    for i in range(1, 1500000):
        fact_sum = 0
        j = i
        while j > 0:
            d = j% b
            fact_sum += fact[d]
            j = j
        if fact_sum == i:
            print(i, end=)
    print()