#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string arr[n];
  if (n >= 1 && n <= 100) {
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
    }
    for (int i = 0; i < n; i++) {
      int l = arr[i].length();
      if (arr[i].length() <= 10) {
        cout << arr[i];
        cout << endl;
      } else if (l <= 100 && l > 10) {
        cout << (arr[i])[0] + to_string(l - 2) + (arr[i])[l - 1];
        cout << endl;
      }
    }
  }
  return 0;
}
