#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
while (n--) {
string s;
cin >> s;
if (s.length() > 10) {
cout << s[0] << s.length() - 2 << s[s.length() - 1] << endl;
} else {
cout << s << endl;
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgICBpbnQgbjsKICAgIGNpbiA+PiBuOwogICAgd2hpbGUgKG4tLSkgewogICAgICAgIHN0cmluZyBzOwogICAgICAgIGNpbiA+PiBzOwogICAgICAgIGlmIChzLmxlbmd0aCgpID4gMTApIHsKICAgICAgICAgICAgY291dCA8PCBzWzBdIDw8IHMubGVuZ3RoKCkgLSAyIDw8IHNbcy5sZW5ndGgoKSAtIDFdIDw8IGVuZGw7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY291dCA8PCBzIDw8IGVuZGw7CiAgICAgICAgfQogICAgfQogICAgcmV0dXJuIDA7Cn0K