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