#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>

// Debug stuff
#define beacon cout << "OK" << endl
#define printvec(v) for(auto x : v) cout << x << " "

// Type less stuff
#define forn(n) for(int mute_idx=0; mute_idx<n; mute_idx++)
#define forin(i,n) for(int i=0; i<n; i++)
#define forimn(i,m,n) for(int i=m; i<n; i++)

using namespace std;

int main() {
	int N;
	string word;
	
	cin >> N;
	forn(N) {
		cin >> word;
		if(word.length()>10) cout << word[0] << word.length()-2 << word[word.length()-1] << endl;
		else cout << word << endl;
	}

	return 0;
}