#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string line;
  getline(cin, line);
  for (int i = (0); i < (n); ++i) {
    getline(cin, line);
    if (line.size() > 10) {
      cout << line[0] << line.size() - 2 << line[line.size() - 1] << endl;
    } else {
      cout << line << endl;
    }
  }
  return 0;
}
