#include <bits/stdc++.h>
using namespace std;
int main() {
  int test;
  cin >> test;
  while (test--) {
    string str;
    cin >> str;
    if (str.length() > 10) {
      int length = str.length();
      cout << str[0] + to_string(length - 2) + str[length - 1] << endl;
    } else
      cout << str << endl;
  }
  return 0;
}
