#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t = 0;
  cin >> t;
  string result[t];
  long long counter = 0;
  while (t > 0) {
    string a;
    cin >> a;
    if (a.size() > 10) {
      result[counter] =
          a.at(0) + to_string(a.size() - 2) + a.at(a.size() - 1) + "";
    } else {
      result[counter] = a;
    }
    t -= 1;
    counter += 1;
  }
  for (long long i = 0; i < counter; i++) {
    cout << "\n" << result[i];
  }
}
