res = list()

for i in range(1000,10000):
    digits = (None, (i//1000)%10, (i//100)%10, (i//10)%10, i%10)

    for j in range(5):
        for k in range(j+1, 5):
            left = [digits[j], digits[k], None]
            right = [digits[l] if l!=j and l!=k else None for l in range(5)]

            left = [str(x) for x in left if x!=None]
            right = [str(x) for x in right if x!=None]

            if len(left) == 1:
                if int(left[0]) * int(right[0]+ right[1] + right[2]) == i:
                    if i not in res:
                        res.append(i)
                if int(left[0]) * int(right[0]+ right[2] + right[1]) == i:
                    if i not in res:
                        res.append(i)
                if int(left[0]) * int(right[1]+ right[0] + right[2]) == i:
                    if i not in res:
                        res.append(i)
                if int(left[0]) * int(right[1]+ right[2] + right[0]) == i:
                    if i not in res:
                        res.append(i)
                if int(left[0]) * int(right[2]+ right[0] + right[1]) == i:
                    if i not in res:
                        res.append(i)
                if int(left[0]) * int(right[2]+ right[1] + right[0]) == i:
                    if i not in res:
                        res.append(i)

            if len(left) == 2:
                if int(left[0]+left[1]) * int(right[0]+ right[1]) == i:
                    if i not in res:
                        res.append(i)
                if int(left[0]+left[1]) * int(right[1]+ right[0]) == i:
                    if i not in res:
                        res.append(i)
                if int(left[1]+left[0]) * int(right[0]+ right[1]) == i:
                    if i not in res:
                        res.append(i)
                if int(left[1]+left[0]) * int(right[1]+ right[0]) == i:
                    if i not in res:
                        res.append(i)

for i in res:
    print("{:04d}".format(i), end=", ")
