import sys
sys.setrecursionlimit(10000)
f=lambda n,k=2,m=1,s='':-~s.find(`n`)or f(n,k+1,m*k*k,s+m%k*`k`)
for n in 13, 997, 999, 314:
print '%3u -> %4u' % (n, f(n))
aW1wb3J0IHN5cwpzeXMuc2V0cmVjdXJzaW9ubGltaXQoMTAwMDApCgpmPWxhbWJkYSBuLGs9MixtPTEscz0nJzotfnMuZmluZChgbmApb3IgZihuLGsrMSxtKmsqayxzK20laypga2ApCgpmb3IgbiBpbiAxMywgOTk3LCA5OTksIDMxNDoKCXByaW50ICclM3UgLT4gJTR1JyAlIChuLCBmKG4pKQ==