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