#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int Q;
  cin >> Q;
  while (Q--) {
    string S;
    cin >> S;
    long long int n = S.size();
    if (n > 10)
      cout << S[0] << n - 2 << S[n - 1] << "\n";
    else
      cout << S << "\n";
  }
  return 0;
}
