/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
static final int limit = 10; // longの範囲の関係で最大18まで
static final long limitN
= (long) Math.
pow(10, limit
); static final int[] primeList = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61 };
static final long[][] primePowTable = new long[primeList.length][10];
static
{
for (int i = 0; i < primeList.length; i++)
{
primePowTable[i][0] = 1;
for (int j = 1; j < 10; j++)
primePowTable[i][j] = primePowTable[i][j - 1] * primeList[i];
}
}
static void f()
{
for (int i = 1; i < 10; i++)
{
f(i, primePowTable[0][i], 1);
}
}
static void f(long i, long j, int k)
{
if (i
== j
) System.
out.
println(i
); if (j < 0 || j >= limitN || k == limit) return;
i *= 10;
for (int l = 0; l < 10; l++)
{
f(i + l, j * primePowTable[k][l], k + 1);
}
}
public static void main
(String[] args
) {
f();
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKICAgIHN0YXRpYyBmaW5hbCBpbnQgbGltaXQgPSAxMDsgLy8gbG9uZ+OBruevhOWbsuOBrumWouS/guOBp+acgOWkpzE444G+44GnCgogICAgc3RhdGljIGZpbmFsIGxvbmcgbGltaXROID0gKGxvbmcpIE1hdGgucG93KDEwLCBsaW1pdCk7CiAgICBzdGF0aWMgZmluYWwgaW50W10gcHJpbWVMaXN0ID0geyAyLCAzLCA1LCA3LCAxMSwgMTMsIDE3LCAxOSwgMjMsIDI5LCAzMSwgMzcsIDQxLCA0MywgNDcsIDUzLCA1OSwgNjEgfTsKICAgIHN0YXRpYyBmaW5hbCBsb25nW11bXSBwcmltZVBvd1RhYmxlID0gbmV3IGxvbmdbcHJpbWVMaXN0Lmxlbmd0aF1bMTBdOwogICAgc3RhdGljCiAgICB7CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBwcmltZUxpc3QubGVuZ3RoOyBpKyspCiAgICAgICAgewogICAgICAgICAgICBwcmltZVBvd1RhYmxlW2ldWzBdID0gMTsKICAgICAgICAgICAgZm9yIChpbnQgaiA9IDE7IGogPCAxMDsgaisrKQogICAgICAgICAgICAgICAgcHJpbWVQb3dUYWJsZVtpXVtqXSA9IHByaW1lUG93VGFibGVbaV1baiAtIDFdICogcHJpbWVMaXN0W2ldOwogICAgICAgIH0KICAgIH0KCiAgICBzdGF0aWMgdm9pZCBmKCkKICAgIHsKICAgICAgICBmb3IgKGludCBpID0gMTsgaSA8IDEwOyBpKyspCiAgICAgICAgewogICAgICAgICAgICBmKGksIHByaW1lUG93VGFibGVbMF1baV0sIDEpOwogICAgICAgIH0KICAgIH0KCiAgICBzdGF0aWMgdm9pZCBmKGxvbmcgaSwgbG9uZyBqLCBpbnQgaykKICAgIHsKICAgICAgICBpZiAoaSA9PSBqKSBTeXN0ZW0ub3V0LnByaW50bG4oaSk7CiAgICAgICAgaWYgKGogPCAwIHx8IGogPj0gbGltaXROIHx8IGsgPT0gbGltaXQpIHJldHVybjsKCiAgICAgICAgaSAqPSAxMDsKICAgICAgICBmb3IgKGludCBsID0gMDsgbCA8IDEwOyBsKyspCiAgICAgICAgewogICAgICAgICAgICBmKGkgKyBsLCBqICogcHJpbWVQb3dUYWJsZVtrXVtsXSwgayArIDEpOwogICAgICAgIH0KICAgIH0KCiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKQogICAgewogICAgICAgIGYoKTsKICAgIH0KfQ==