import java.io.*;
import java.util.*;

class STGContactNumberAndNameExtract
{
	public static void main(String[] s) throws Exception
	{
		BufferedReader fis1 = new BufferedReader (new InputStreamReader(new FileInputStream(s[0]), "UTF-16LE"));
		PrintStream ps = new PrintStream (new FileOutputStream(s[1]));
		ps.println("\"Name\",\"Mobile Phone\"");
		int c;
		Hashtable h = new Hashtable ();
		try{
 		 while ((c = fis1.read()) != -1) 
		 {
			StringBuffer tmpstringb = new StringBuffer();
			StringBuffer tmpNameStrB = new StringBuffer();
			if (Character.isDigit(c) || c == '+')
			{
				tmpstringb.append((char)c);
				while ((c = fis1.read()) != 0) // rest of number
					tmpstringb.append((char)c);
				String tmpstring = new String (tmpstringb);
				if (tmpstring.length()>15 || tmpstring.length()<7) continue; // not valid number
				try 
				{
					Long.parseLong(tmpstring.substring(1)); // chop off the leading + 
				}
				catch (Exception e) {continue;} // not valid number
				//ps.print(tmpstring + "\t");
				while ((c = fis1.read()) != 0) 
					tmpNameStrB.append((char)c);
					//ps.write((char)c); // name (next record field)
				//ps.println();
				String tmpNameStr = new String (tmpNameStrB);
				for (int i = 1; i<32; i++)
				 tmpNameStr = tmpNameStr.replace((char)i,' '); // eliminating all the problematic below-space chars
				h.put(tmpstring, tmpNameStr);
			}
		 }
		}
		catch (Exception e) {}
		//Enumeration e = h.elements();
		Enumeration e = h.keys();
		while (e.hasMoreElements())
		{
		 String number = (String)e.nextElement();
		 String name = (String)h.get(number);
		 ps.println("\""+name+"\",\""+number+"\"");
		 }
		ps.close();
}
}


