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