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