#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, aux;
  cin >> x;
  for (int i = 0; i < x; i++) {
    string word;
    cin >> word;
    if (word.length() > 10) {
      aux = word.length() - 2;
      cout << word[0] << aux << word[word.length() - 1] << endl;
    } else {
      cout << word << endl;
    }
  }
}
