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