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