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