using System;
namespace Product_of_Digits
{
class Program
{
static void Main(string[] args)
{
ulong n = Convert.ToUInt64(Console.ReadLine());
ulong[] primos = { 2, 3, 5, 7 };
ulong[] pr = new ulong[4];
ulong suma = 0;
if (n >= 10)
{
for (ulong i = 0; i < 4; i++)
{
while (n % primos[i] == 0)
{
pr[i]++;
n /= primos[i];
}
}
if (n / 7 != 0)
Console.WriteLine("-1");
else
{
for (ulong i = 0; i < 4; i++)
suma += pr[i];
ulong[] print = new ulong[suma];
ulong[] printlargo = new ulong[suma];
ulong j = 0;
for (ulong i = 0; i <= 3; i++)
{
while (pr[i] > 0)
{
printlargo[j] = primos[i];
pr[i]--;
j++;
}
}
ulong k = suma - 1;
while (k >=0&&k<suma)
{
print[k] = printlargo[k];
j = 1;
if (j > k)
break;
while (print[k] * printlargo[k - j] < 10)
{
print[k] *= printlargo[k - j];
j++;
if (j >k)
break;
}
k -= j;
}
Array.Sort(print);
for (ulong i = 0; i < suma; i++)
{
if (print[i] != 0)
{
Console.Write("{0}", print[i]);
}
}
}
}
else if (n > 0 && n < 10)
Console.WriteLine("{0}", n);
else
Console.WriteLine("1{0}", n);
}
}
}
dXNpbmcgU3lzdGVtOwoKbmFtZXNwYWNlIFByb2R1Y3Rfb2ZfRGlnaXRzCnsKICAgIGNsYXNzIFByb2dyYW0KICAgIHsKICAgICAgICBzdGF0aWMgdm9pZCBNYWluKHN0cmluZ1tdIGFyZ3MpCiAgICAgICAgewogICAgICAgICAgICB1bG9uZyBuID0gQ29udmVydC5Ub1VJbnQ2NChDb25zb2xlLlJlYWRMaW5lKCkpOwogICAgICAgICAgICB1bG9uZ1tdIHByaW1vcyA9IHsgMiwgMywgNSwgNyB9OwogICAgICAgICAgICB1bG9uZ1tdIHByID0gbmV3IHVsb25nWzRdOwogICAgICAgICAgICB1bG9uZyBzdW1hID0gMDsKCiAgICAgICAgICAgIGlmIChuID49IDEwKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBmb3IgKHVsb25nIGkgPSAwOyBpIDwgNDsgaSsrKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHdoaWxlIChuICUgcHJpbW9zW2ldID09IDApCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBwcltpXSsrOwogICAgICAgICAgICAgICAgICAgICAgICBuIC89IHByaW1vc1tpXTsKICAgICAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKG4gLyA3ICE9IDApCiAgICAgICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIi0xIik7CiAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgZm9yICh1bG9uZyBpID0gMDsgaSA8IDQ7IGkrKykKICAgICAgICAgICAgICAgICAgICAgICAgc3VtYSArPSBwcltpXTsKICAgICAgICAgICAgICAgICAgICB1bG9uZ1tdIHByaW50ID0gbmV3IHVsb25nW3N1bWFdOwogICAgICAgICAgICAgICAgICAgIHVsb25nW10gcHJpbnRsYXJnbyA9IG5ldyB1bG9uZ1tzdW1hXTsKICAgICAgICAgICAgICAgICAgICB1bG9uZyBqID0gMDsKICAgICAgICAgICAgICAgICAgICBmb3IgKHVsb25nIGkgPSAwOyBpIDw9IDM7IGkrKykKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChwcltpXSA+IDApCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50bGFyZ29bal0gPSBwcmltb3NbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcltpXS0tOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaisrOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVsb25nIGsgPSBzdW1hIC0gMTsKICAgICAgICAgICAgICAgICAgICB3aGlsZSAoayA+PTAmJms8c3VtYSkKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIHByaW50W2tdID0gcHJpbnRsYXJnb1trXTsKICAgICAgICAgICAgICAgICAgICAgICAgaiA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChqID4gaykKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAocHJpbnRba10gKiBwcmludGxhcmdvW2sgLSBqXSA8IDEwKQogICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmludFtrXSAqPSBwcmludGxhcmdvW2sgLSBqXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGorKzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChqID5rKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGsgLT0gajsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgQXJyYXkuU29ydChwcmludCk7CiAgICAgICAgICAgICAgICAgICAgZm9yICh1bG9uZyBpID0gMDsgaSA8IHN1bWE7IGkrKykKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwcmludFtpXSAhPSAwKQogICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlKCJ7MH0iLCBwcmludFtpXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSBpZiAobiA+IDAgJiYgbiA8IDEwKQogICAgICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoInswfSIsIG4pOwogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiMXswfSIsIG4pOwogICAgICAgIH0KICAgIH0KfQ==