import java.util.*;

public class Words {

    public String countWords(List<String> lines) {
        StringBuilder result = new StringBuilder();

        HashMap<String, Integer> wordsCount = new HashMap<>();
        for (String line : lines)
        {
            line=line.toLowerCase(Locale.ROOT);
            line = line.replaceAll("[^\\p{L}\\p{Nd}]+", " ");
            String[] words = line.split(" ");
            for (String word: words) {
                    if( wordsCount.containsKey(word)){
                        wordsCount.put(word, wordsCount.get(word)+1 );
                    }else{
                        wordsCount.put(word, 1);
                }
            }
            TreeMap<String, Integer> sortedMap = new TreeMap<>(wordsCount);
            for (Map.Entry<String, Integer> entry :sortedMap.entrySet() ) {
                if ( (entry.getValue()>9) && (entry.getKey().length()>3 ) ){
                    result.append(entry.getKey() + " - " + entry.getValue() + "\r\n");
                }
            }
        }
        return (result.toString());
    }

}