# https://pythonhosted.org/eulerlib/eulerlib.html

import eulerlib

# https://projecteuler.net/problem=32

total=0
x=1
while True:
    #print x
    y=1
    while True:
        z=x*y

        s=str(x)+str(y)+str(z) 
        if len(s)==9 and '0' not in s:
            if eulerlib.etc.is_pandigital (int (s), 1, 9):
                print (x, y, z)
                total=total+z

        y=y+1
        if y>10000:
            break

    if x>10000:
        break
    x=x+1

print (total)

"""
correct answer:

4396+
5346+
5796+
6952+
7254+
7632+
7852
"""
