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