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