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