def abreviater(word): if len(word) > 10: word = f"{word[0]}{len(word)-2}{word[-1]}" return word for i in range(int(input())): print(abreviater(input()))