#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  if (s.length() <= 10)
    cout << s << "\n";
  else {
    string out(s, 1, s.length() - 2);
    cout << s[0] << out.length() << s[s.size() - 1] << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  while (n--) {
    solve();
  }
}
