#include <bits/stdc++.h>
int main() {
  int n, len;
  char x[100];
  scanf("%d", &n);
  while (n--) {
    scanf("%s", &x);
    len = strlen(x);
    if (len <= 10)
      printf("%s\n", x);
    else
      printf("%c%d%c\n", x[0], len - 2, x[len - 1]);
  }
}
