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