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