text: #include <iostream>
  #include <algorithm>
  #include <string>
  #include <vector>
  #include <set>
  #include <unordered_set>
  #include <map>
  #include <unordered_map>
  #include <queue>
  #include <math.h>
  #include <stdlib.h>
  #include <deque>
  using namespace std;
  
  int main()
  {
      int t = 1;
      cin >> t;
      while (t--)
      {
          string s;
          cin >> s;
          if (s.length() > 10)
          {
              cout << s[0] << s.length() - 2 << s[s.length() - 1] << endl;
          }
          else
          {
              cout << s << endl;
          }
      }
      return 0;
  }