import java.io.*;
import java.util.*;
import java.net.*;
import java.math.*;
//_____________________________________________________________
public class make2552
{ 
   String[] words = getFile("words.txt").split("\r\n");
   int max = 0;
   HashMap hash = new HashMap();
   int hashpos = 0;
//_____________________________________________________________
public static final void main(String[] args) throws Exception
{
   make2552 bnk = new make2552();
   bnk.start(args);
}
//___________________________________________________________________________
void start(String[] args)
{
   int startnum = 0;
   if (args.length > 0) startnum = Integer.parseInt(args[0]);
   startit("37737337","7001474408553551","4157","37","1818");
   String str1 = "25525225";
   int cnt = 0;
   for (int i = 1000000 * startnum; i < 1000000 * (1 + startnum); i++)
   {
      cnt++;
      if (cnt >= 100000)
      {
         cnt = 0;
         System.out.print(".");
      }
      String str2 = Integer.toString(i);
      String num = startit("25525225", str2,"3007","25","1314");
      if (!num.equals(""))
      {
         String[] words = findword("",num).split("\r\n");
         for (int j = 0; j < words.length; j++)
         {
            if (words[j].trim().equals("")) continue;
            String[] words2 = findword(words[j],num).split("\r\n");
            for (int j2 = 0; j2 < words2.length; j2++)
            {
               if (words2[j2].trim().equals("")) continue;
               String[] words3 = findword(words2[j2],num).split("\r\n");
               for (int j3 = 0; j3 < words3.length; j3++)
               {
                  if (words3[j3].trim().equals("")) continue;
                  String[] words4 = findword(words3[j3],num).split("\r\n");
                  for (int j4 = 0; j4 < words4.length; j4++)
                  {
                     if (words4[j4].trim().equals("")) continue;
                     String[] words5 = findword(words4[j4],num).split("\r\n");
                     for (int j5 = 0; j5 < words5.length; j5++)
                     {
                        if (words5[j5].trim().equals("")) continue;
                        String[] words6 = findword(words5[j5],num).split("\r\n");
                     }
                  } 
              }
            }
         }
      }
   }
}
//___________________________________________________________________________
String findword(String first, String num)
{
   StringBuffer buf = new StringBuffer();
   String alphabet = "abcdefghijklmnopqrstuvwxyz";
   String numbers = "1234567890";
   isall(num);
   int[] lookpos = new int[num.length()];
   int[] looktv = new int[num.length()];
   int posi = 0;
   int cnt = 0;
   for (int i = 0; i < words.length; i++)
   {
      String wordsall2 = first + " " + words[i];
      String wordsall = wordsall2.replace(" ","");
      if (wordsall.length() > num.length()) continue;
      if (wordsall.equals("")) continue;
      boolean ok = true;
      int mx = wordsall.length();
      if (num.length() < mx) mx = num.length();
      for (int j = 0; j < mx; j++)
      {
         String s = wordsall.substring(j,j+1);
         String t = num.substring(j+posi,j+1+posi);
         int tv = numbers.indexOf(t);
         int pos = alphabet.indexOf(s);
         
         if (pos < tv) ok = false;
         if (pos > 26 - (max - tv)) ok = false;
         for (int k = 0; k < j; k++)
         {
            int delta = tv - looktv[k];
            int delta2 = pos - lookpos[k];
            if (delta == 0) { if (delta2 != 0) ok = false; }
            else if (delta > 0) { if (delta2 < delta) ok = false; }
            else if (delta < 0) { if (delta2 > delta) ok = false; }
         }
         if (ok) 
         {
            lookpos[j] = pos;
            looktv[j] = tv;
         }
         else break;
      }
      if (ok) 
      {
         cnt++;
         buf.append(wordsall2 + "\r\n");
         int leng = num.length() - wordsall.length();
         if (leng <= 0) 
         {
            if (hash.get(wordsall2) == null)
            {
               System.out.println(wordsall2);
               saveFile("best25.txt",wordsall2 + "\r\n",true);
               hash.put(wordsall2,hashpos++);
            }
         }
      }
   }
   return(buf.toString());
}
//___________________________________________________________________________
String startit(String str1, String str2, String str3, String str4, String str5)
{
      for (int j = 0; j < Integer.parseInt(str3); j += 23)
      {
         String str3b = str2 + str1;
         BigInteger bga = new BigInteger(str3b);
         BigInteger bg3007 = new BigInteger(str3);
         BigInteger bgz = bga.multiply(bg3007);
         BigInteger bgb = new BigInteger(Integer.toString(j));
         BigInteger bgc =  bgz.add(bgb);
         String str4b = bgc.toString();
         BigInteger bgd = new BigInteger(str2);
         BigInteger bge = bgd.subtract(bgb);
         //BigInteger bg23 = new BigInteger("23");
         BigInteger bg25 = new BigInteger(str4);
         BigInteger bgf = bge.mod(bg25);
         BigInteger bg0 = new BigInteger("0");
         BigInteger bg1314 = new BigInteger(str5);
         if (bgb.equals(bg0)) continue;
         if (bgf.equals(bg0)) 
         {
            BigInteger bgab = bga.mod(bgb);
            if (bgab.equals(bg1314))
            {
               if (isall(str4b))
               {
                  System.out.println("\r\n" + bgf.toString() + " " + bgab.toString() + " " + bgc.toString());
                  return(bgc.toString());
               }
            }
         }
      }
   return("");
}
//___________________________________________________________________________
boolean isall(String str)
{
   String nums = "1234567890";
   int[] posi = new int[10];
   for (int i = 0; i < str.length(); i++)
   {
      String s = str.substring(i,i+1);
      int pos = nums.indexOf(s);
      posi[pos]++;
   }
   max = 0;
   for (int i = 0; i < posi.length; i++)
   {
      if (posi[i] > 0) max = i;
   }
   for (int i = 0; i <= max; i++)
   {
      if (posi[i] == 0) return(false);
   }
   return(true);
}
//___________________________________________________________________________
String getFile(String file) 
{
   StringBuffer buf=new StringBuffer();String str;
  try
  {
   BufferedReader in = new BufferedReader (new FileReader (file));
   while((str=in.readLine())!=null)
   {
      buf.append(str+"\r\n");
   }
   in.close();
  }
  catch (Exception e)
  {
   System.out.println(e);
  }
   return (buf.toString());
}
//___________________________________________________________________________
void saveFile(String file, String str, boolean append) 
{
  try
  {
   BufferedWriter out = new BufferedWriter(new FileWriter(file, append));
   out.write(str);
   out.close();
  }
  catch (Exception e)
  {
   System.out.println(e);
  }
}
}//__________________________________________________________________________
