#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string longWord;
  while (n--) {
    cin >> longWord;
    if (longWord.length() <= 10)
      cout << longWord << "\n";
    else
      cout << longWord.front() << longWord.length() - 2 << longWord.back()
           << "\n";
  }
  return 0;
}
