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