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