#include <bits/stdc++.h>
int main() {
  int n;
  std::string s[100];
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    std::cin >> s[i];
  }
  for (int i = 0; i < n; i++) {
    if (s[i].length() > 10)
      std::cout << s[i][0] << s[i].length() - 2 << s[i][s[i].length() - 1]
                << "\n";
    else
      std::cout << s[i] << "\n";
  }
  return 0;
}
