test_case = int(input())

for i in range(test_case):
    sentence = input()
    length = len(sentence)
    if length > 10:
        output = f"{sentence[0]}{len(sentence[1:-1])}{sentence[-1]}"
    else:
        output = sentence
    print(output)

024d75aa1f2225f1c7a182c5b0cda91a722be791
<mask token>

<mask token>
for i in range(test_case):
    sentence = input()
    length = len(sentence)
    if length > 10:
        output = f'{sentence[0]}{len(sentence[1:-1])}{sentence[-1]}'
    else:
        output = sentence
    print(output)

test_case = int(input())
for i in range(test_case):
    sentence = input()
    length = len(sentence)
    if length > 10:
        output = f'{sentence[0]}{len(sentence[1:-1])}{sentence[-1]}'
    else:
        output = sentence
    print(output)

test_case = int(input())

for i in range(test_case):
    sentence = input()
    length = len(sentence)
    if length > 10:
        output = f"{sentence[0]}{len(sentence[1:-1])}{sentence[-1]}"
    else:
        output = sentence
    print(output)
