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