#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  bool flag;
  long long int n, m, i, j, k, temp;
  vector<long long int> nums;
  string s;
  while (t--) {
    cin >> s;
    n = s.size();
    string x = "";
    if (n > 10)
      x += s[0] + to_string(n - 2) + s[n - 1], cout << x << endl;
    else
      cout << s << endl;
  }
  return 0;
}
