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