import java.util.*;
import java.util.regex.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		List<String> strs = Arrays.asList("Фамилия Имя Отчество", "Фамилия Имя", "Фамилия");
		Pattern p = Pattern.compile("\\s*(\\S{0,20})\\S*\\s*(\\S)?.*");
		for (String str : strs) {
			Matcher m = p.matcher(str);
			System.out.println(m.replaceAll(x -> x.group(1) + (x.group(2) == null ? "" : " " + x.group(2) + ".")) );
		}
	}
}