#include <bits/stdc++.h>
int main() {
  char s[120];
  int n;
  scanf("%d", &n);
  for (int a = 0; a < n; ++a) {
    scanf(" %s", s);
    int siz = strlen(s);
    if (siz > 10) {
      if (siz == 11)
        printf("%c9%c\n", s[0], s[10]);
      else
        printf("%c%d%c\n", s[0], siz - 2, s[siz - 1]);
    } else
      printf("%s\n", s);
  }
  return 0;
}
