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