Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.This abbreviation is made like this: we write down the first and the last letter of a word and between them we write the number of letters between the first and the last letters. That number is in decimal system and doesn't contain any leading zeroes.Thus, "localization" will be spelt as "l10n", and "internationalization» will be spelt as "i18n".You are suggested to automatize the process of changing the words with abbreviations. At that all too long words should be replaced by the abbreviation and the words that are not too long should not undergo any changes.

The first line contains an integer n (1 ≤ n ≤ 100). Each of the following n lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters.

Print n lines. The i-th line should contain the result of replacing of the i-th word from the input data.

4
word
localization
internationalization
pneumonoultramicroscopicsilicovolcanoconiosis

import scala.io.StdIn

object Main {
  def main(args: Array[String]) {
    val n = StdIn.readInt()

    for (_ <- 1 to n ) {
      val s = StdIn.readLine()

      if (s.length > 10) {
        println("" + s.charAt(0) + (s.length - 2) + s.charAt(s.length - 1))
      } else {
        println(s)
      }
    }
  }
}

import scala.io.Source

/** A. Way Too Long Words
  * http://codeforces.com/problemset/problem/71/A
  *
  * @author Yuichiroh Matsubayashi
  *         Created on 15/01/19.
  */
object P71A {
  def main(args: Array[String]) {
    val words = Source.stdin.getLines().drop(1)
    abbrs(words).foreach(println)
  }

  def abbrs(words: Iterator[String]) = words.map { w =>
    if (w.length > 10) w.head + (w.length - 2).toString + w.last
    else w
  }
}

object A71 extends App {

  var n: Int = readInt()
  while (n>0){
    val input = readLine()
    val l = input.length
    if (l > 10){
      println(input(0)+(l-2).toString+input(l-1))
    } else {
      println(input)
    }
    n-=1
  }

}

object test
{
    def main(args : Array[String])
    {
        val n = readInt()
        for(i <- 1 to n)
        {
            val s = readLine()
            if(s.length > 10)
                println(s(0)+(s.length-2).toString+s(s.length-1))
            else
                println(s)
        }
    }
}

import scala.io.StdIn

object P71A {
  def main(args : Array[String]) {
    val n = StdIn.readInt()
    for (i <- 1 to n) solveLine(StdIn.readLine())
    Console.out.flush()

    def solveLine(s: String) = {
      if (s.length > 10) {
        Console.out.print(s.head.toString)
        Console.out.print((s.length - 2).toString)
        Console.out.print(s.last.toString)
      }
      else Console.out.print(s)
      Console.out.println()
    }
  }
}

object main extends App{
    val n = readLine().toInt
    for(_ <- 1 to n){
        var s = readLine()
        println(if(s.size > 10) s.head + (s.size-2).toString + s.last else s )
    }
}

import scala.io.StdIn._

object WayToLong {
  def main(args: Array[String]): Unit = {
    val n = readInt()
    for (_ <- 0 until n) {
      val word = readLine
      val ans =
        if (word.length > 10)
          word(0) + (word.length - 2).toString + word.last
        else word
      println(ans)
    }
  }
}

object Main {
    def solve(s: String): String = {
        if (s.length <= 10)
            s
        else
            s(0).toString + (s.length - 2) + s(s.length - 1)
    }

    def main(args: Array[String]) {
        val n = readInt()
        (for (i <- 1 to n) yield solve(readLine())) foreach println
    }
}

import scala.io.StdIn

object WayTooLongWords extends App {

  val n = StdIn.readInt()
  for (i <- Range(0, n - 1)) {
    println(imply(StdIn.readLine()))
  }
  print(imply(StdIn.readLine()))

  def imply(word: String): String = {
    val len = word.length
    if (len <= 10) word
    else {
      word.charAt(0) + (len - 2).toString + word.charAt(len - 1)
    }
  }
}

import java.util.Scanner
import java.io.PrintWriter
import scala.annotation.tailrec
import scala.collection.mutable
import scala.util.Random

object P71A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  val N = sc.nextLine.toInt

  def abbreviate(s: String): String = s.head.toString + (s.length - 2).toString + s.last.toString

  def solve(s: String): String =
    if (s.length <= 10) s
    else abbreviate(s)

  for (i <- 0 until N)
    out.println(solve(sc.nextLine))
  out.close
}

import scala.io.StdIn._

object Solution {

	var n = readInt
	var words = Array.fill[String](n)(null)
	for(i <- 0 until n) {
		words(i) = readLine
	}

	def main(args:Array[String]):Unit = {
		var ret = Array.fill[String](n)(null)
		for(i <- 0 until n) {
			if(words(i).length > 10) {
				var k = 0
				for(j <- 1 until words(i).length-1) k += 1
				ret(i) = words(i)(0).toString + k.toString + words(i)(words(i).length-1).toString
			}
			else ret(i) = words(i)
			println(ret(i))
		}
	}

}

import java.util.Scanner

/**
  * Created by Orhan on 2/23/2017.
  */
object WayTooLongWords extends App{
  val line = new Scanner(System.in)
  var wordCount = line.nextInt()
  var wordList = new Array[String](wordCount)
  for (i <- 0 until wordCount){
    wordList(i) = line.next();
  }

  for (word <- wordList){
    if (word.length > 10) println("" + word.charAt(0) + (word.length - 2) + word.charAt(word.length - 1))
    else println(word)
  }
}

import scala.collection.immutable.StringOps
object Main {
  def res(x: Int) {
    val e = readLine
    println( if( e.size > 10 ) e.head.toString + (e.size-2) + e.last.toString else e)
  }
  def main(args: Array[String]) {
    val N = readInt
    1 to N foreach( res )
  }
}

object Cf71A extends App {
  val n = readInt()
  for (i <- 1 to n) {
    val s = readLine()
    val len = s.length
    println(if (len <= 10) s else s(0) + (len - 2).toString + s(len - 1))
  }
}

object cf extends App{
  val t = readInt()
  for (t <- 0 to t-1) {
    var s = readLine()
    val l = s.length()
    if (l > 10) {
      s = s(0)+(l-2).toString+s(l-1)
      println(s)
    }
    else {
      println(s)
    }
  }
}

/*input
4
word
localization
internationalization
pneumonoultramicroscopicsilicovolcanoconiosis
*/

import java.util.Scanner
import scala.io.StdIn

object Solution {
	def main(args: Array[String]): Unit = {

		val n = StdIn.readInt();
		var i = 1;
		while(i <= n)
		{
			val str = StdIn.readLine();
			if(str.length() <= 10) println(str)
			else{
				print(str(0));
				print(str.length() - 2);
				println(str(str.length() - 1))
			}
			i += 1;
		}
	}
}

object CF0071A extends App {

  val n = readInt()

  (1 to n).foreach(e => {
    val str = readLine()
    if (str.length > 10) {
      println(str.charAt(0).toString + (str.length - 2) + str.charAt(str.length -1 ).toString)
    } else {
      println(str)
    }
  })
}

import scala.io.StdIn

object  Test {
  def main(args1: Array[String]) {
//    val args = Console.readLine().split(" ")
//    val (v: Long, y: Long, z: Long) = (args(0).toLong, args(1).toLong, args(2).toLong)

    val len = 10
    val args = Console.readLine()
    val count = args.toInt

    for (it <- 0 until count) {
      val line = StdIn.readLine
      if (line.length > 10) {
        println(s"${line.substring(0, 1)}${line.length - 2}${line.substring(line.length - 1)}")
      }
      else {
        println (line)
      }
    }
//    val res = balls.size
//    println(res)
  }
}

 object Main extends App {

  def A71={
    def packWord(s:String, i: Int): String ={
      s.length> i match {
        case false => s
        case true => s"${s(0)}${s.length - 2}${s.last}"
      }
    }
    (1 to readInt).map(x => readLine).map(packWord(_,10)).foreach(println(_))
  }

  A71
}

object Main{

    def main(args:Array[String]){
        val n = readLine.toInt
        for(i<- 0 until n){
            val s = readLine
            if(s.length()<=10)
                println(s)
            else{
                print(s(0))
                print(s.length()-2)
                println(s(s.length()-1))
            }
        }

    }
}

object I18n extends App {

  def replace(s: String) = if (s.length > 10) s"${s(0)}${s.length - 2}${s(s.length - 1)}" else s

  (1 to readInt()).map(line => replace(readLine())).foreach(println)

}

import java.util.Scanner

object _71A extends App {
  def convert(w: String): String =
    w.head + (w.length-2).toString + w.last

  val scanner = new Scanner(System.in)
  val n = scanner.nextInt()
  val words = Array.fill(n)(scanner.next())
  words.foreach(w => println(if (w.length > 10) convert(w) else w))
}

object P71A {
  def main(args : Array[String]) {
    val n = readInt
    for (i <- 1 to n) work(readLine)
    writeCBuf

    def work(line: String) = {
      if (line.length > 10) {
        add(line.head)
        printInt(line.length - 2)
        add(line.last)
      } else add(line)
      add(13.toByte); add(10.toByte)
    }
  }

  ///********************************************************************
  ///                     easy output buffer
  ///
  var cbufCursor = 0;
  val cbuf = new Array[Byte](8192);
  def writeCBuf {
      System.out.write(cbuf, 0, cbufCursor);
  }

  def add(s: String) {
      add(s.getBytes(), 0, s.length());
  }

  def add(c: Array[Byte]) {
      for (i <- 0 until c.length) add(c(i))
  }

  def add(c: Array[Byte], startIndex: Int, endIndex: Int) {
      for (i <- startIndex until endIndex) add(c(i));
  }

  def add(c: Char) { add(c.toByte) }

  def add(c: Byte) {
    cbufCursor += 1
    cbuf(cbufCursor - 1) = c;
    if (cbufCursor == cbuf.length) {
      writeCBuf
      cbufCursor = 0;
    }
  }

  ///********************************************************************
  ///                     easy input buffer
  ///
  val rbuf = new Array[Byte](8192);
  var canReadBufMore = true;
  var rbufCursor = rbuf.length;
  var readSize = 0;
  def readByte: Byte = {
    try {
      if (rbufCursor >= rbuf.length) {
        if (canReadBufMore) {
          readSize = System.in.read(rbuf);
          if (readSize < rbuf.length) {
            canReadBufMore = false;
          }
          rbufCursor = 0;
        }
      }
    } catch { case e: Exception => /* do nothing */}
    if (rbufCursor != readSize) {
      rbufCursor += 1
      rbuf(rbufCursor - 1)
    } else -1;
  }

  ///********************************************************************
  ///                    for read integers
  ///
  def readInt : Int = {
    var result = 0
    var read: Byte = 0
    var sign = false

    do {
      read = readByte
    } while (read != -1 && (read != '-' && read < '0' || read > '9'))

    if (read == -1) return Integer.MIN_VALUE;
    if (read == '-') { sign = true; read = readByte }

    do {
      result = (result << 3) + (result << 1) + read - '0';
      read = readByte;
    } while (read != -1 && read >= '0' && read <= '9');
    if (read == 13) readByte; // skip 10

    if (sign) -result else result
  }

  ///********************************************************************
  ///                    for read line
  ///
  val lBuf = new Array[Byte](100)
  def readLine: String = {
    var read = readByte;
    var lPointer = 0;
    try {
      while (read > 13) {
        lPointer += 1
        lBuf(lPointer - 1) = read;
        read = readByte
      }
      if (read == -1) return null;
      if (read == 13) readByte; // skip 10
    } catch { case e: Exception => /* do nothing */}
    return new String(lBuf, 0, lPointer);
  }

  ///********************************************************************
  ///                    for print long
  ///
  val ibuf = new Array[Byte](20);
  def printInt(i: Int) { printLong(i.toLong) }
  def printLong(l: Long) {
      var i = l
      var q, r = 0L
      var sign = false
      if (i < 0) {
          sign = true;
          i = -i;
      }
      var charPos = ibuf.length;

      // Generate two digits per iteration
      while (i >= 65536) {
          q = i / 100;
      // really: r = i - (q * 100);
          r = i - ((q << 6) + (q << 5) + (q << 2));
          i = q;

          charPos -= 1
          ibuf(charPos) = DigitOnes(r.toInt);
          charPos -= 1
          ibuf(charPos) = DigitTens(r.toInt);
      }

      // Fall thru to fast mode for smaller numbers
      // assert(i <= 65536, i);
      do {
          q = (i * 52429) >>> 19;//(16+3);
          r = i - ((q << 3) + (q << 1));  // r = i-(q*10)
          charPos -= 1
          ibuf(charPos) = DigitOnes(r.toInt);
          i = q;
      } while (i != 0)
      if (sign) {
        charPos -= 1
        ibuf(charPos) = '-';
      }
//      System.out.write(ibuf, charPos, ibuf.length - charPos);
        add(ibuf, charPos, ibuf.length); //if u use manual output buffer
  }

  val DigitTens = Array(
      '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
      '1', '1', '1', '1', '1', '1', '1', '1', '1', '1',
      '2', '2', '2', '2', '2', '2', '2', '2', '2', '2',
      '3', '3', '3', '3', '3', '3', '3', '3', '3', '3',
      '4', '4', '4', '4', '4', '4', '4', '4', '4', '4',
      '5', '5', '5', '5', '5', '5', '5', '5', '5', '5',
      '6', '6', '6', '6', '6', '6', '6', '6', '6', '6',
      '7', '7', '7', '7', '7', '7', '7', '7', '7', '7',
      '8', '8', '8', '8', '8', '8', '8', '8', '8', '8',
      '9', '9', '9', '9', '9', '9', '9', '9', '9', '9').map(_.toByte)

  val DigitOnes = Array(
      '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
      '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
      '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
      '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
      '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
      '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
      '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
      '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
      '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
      '0', '1', '2', '3', '4', '5', '6', '7', '8', '9').map(_.toByte)
}

import scala.io.StdIn.readLine
import scala.io.StdIn.readInt

object LongWords {

  def main(args: Array[String]) {
    val n = readInt
    for (i <- 1 to n) {
      val word = readLine
      if (word.length <= 10) println(word)
      else println("" + word.head + (word.length()-2) + word.last)
    }
  }

}

import scala.io.StdIn._

object WayTooLongWords_71A extends App {
  def abbrv(word: String): String = {
    if (word.length > 10)
      word(0) + (word.length - 2).toString() + word(word.length - 1)
    else
      word
  }

  val n = readInt

  for (i <- 1 to n) yield {
    println(abbrv(readLine))
  }
}

object WayTooLongWords {
  def main(args : Array[String]) {
    val gls = io.Source.stdin.getLines
    gls drop(1)
    gls.map(shorten _) foreach(println)
  }
  def shorten(word : String) : String = {
    val len = word.length() - 2
    if (len > 8)
      return s"${word(0)}$len${word.last}"
    return word
  }
}

import scala.Console
import util.control.Breaks._

object App {

  def main(args : Array[String]) {

    var curCount = 0
    var maxCount = 0
    var line :String = ""

    maxCount = Console.readLine().toInt

       for (i <- 1 to maxCount) {

         line = Console.readLine()

             breakable{
               if(line.length() <= 10){
                 println(line)
                 break
               }else{
                 val value = line.length() - 2
                 println(""+line.charAt(0).toChar + value + line.charAt(line.length() - 1).toChar)
               }
             }
      }

  }

}

/**
 * Created by mikhailvarnavskikh on 04.04.15.
 */
object Main {

  def main(args: Array[String]) {
    val std = scala.io.StdIn
    val Array( n ) = std.readLine().split( " " ).map( _.toInt )
    for ( i <-1 to n ) {
      val word = std.readLine
      val res = if ( word.length > 10 ) {
        word(0) + (word.length - 2).toString + word( word.length -1 )
      } else  {
        word
      }
      println( res )
    }

  }

}

object HelloWorld {
  def main(args: Array[String]): Unit = {
  	var m = readInt()
  	for (i <- 1 to m){
  		var s = readLine()
  		if (s.length() > 10){
  			var t = s(0) + (s.length()-2).toString + s(s.length()-1)
  				println(t)
  			}else{
  				println(s)
  			}
  	}
  	}
}

import scala.io.StdIn._

object Main {
  def main(args: Array[String]): Unit = {
    val n = readInt
    (0 until n).foreach { k =>
      val s = readLine
      val result = if (s.length  > 10) s"${s.head}${s.length - 2}${s.last}" else s
      println(result)
    }
  }
}

import java.util.Scanner

/**
  * Created by dr0ff on 22/02/16.
  */
object WayTooLongWords extends App {
  val in = new Scanner(System.in)
  val wnum = in.nextLine().trim.toInt

  for (_ <- 0 until wnum) yield {
    val word = in.nextLine()
    println(compress(word.trim()))
  }

  def compress(word: String): String =
    if (word.length > 10)
      word.take(1) + (word.length - 2).toString + word.drop(word.length - 1)
    else
      word
}

import scala.Math.ceil

object Main {
    def main(args: Array[String]): Unit = {
        val n = readLine.toInt

        for (i <- 0 to n - 1) {
            var s = readLine
            if (s.length > 10) {
                print(s(0))
                print(s.length - 2)
                println(s(s.length - 1))
            } else
                println(s)
        }
    }
}

import scala.io.StdIn._

object WayToLong {
  def main(args: Array[String]): Unit = {
    val n = readInt()
    val words = for (_ <- 0 until n) yield readLine()
    words.map(x => if (x.length > 10) s"${x(0)}${x.length - 2}${x.last}" else x)
      .foreach(println)
  }
}

import scala.io.StdIn

object TooLongWords_71A {
  def main(args: Array[String]): Unit = {
    val numRows = StdIn.readInt()
    (1 to numRows).foreach { i =>
        val row = StdIn.readLine()
        val len = row.length
        if (len > 10) {
          println(row.head + (len - 2).toString + row.last)
        } else {
          println(row)
        }
    }
  }
}

import scala.io.StdIn

object TooLongWords extends App {

  val numberOfWords: Short = StdIn.readShort()

  val words: Seq[String] = for (_ <- 1 to numberOfWords) yield StdIn.readLine()
  val onlyShortWords = words.map {
    case word if word.length > 10 => word.head + (word.length - 2).toString + word.last
    case word => word
  }

  onlyShortWords.foreach(println)
}

import scala.io.StdIn

object P71A {
  def main(args : Array[String]) {
    val n = StdIn.readInt
    for (i <- 1 to n) work(StdIn.readLine)

    def work(line: String) = {
      if (line.length > 10) {
        print(line.head); print(line.length - 2); println(line.last)
      } else println(line)
    }
  }
}

object P71A {
  def main(args : Array[String]) {
    val n = readInt
    for (i <- 1 to n) work(readLine)

    def work(line: String) = {
      if (line.length > 10) {
        print(line.head); print(line.length - 2); println(line.last)
      } else println(line)
    }
  }
}

object Main {
    def solve(s: String): String = {
        if (s.length <= 10)
            s
        else
            s(0).toString + (s.length - 2) + s(s.length - 1)
    }

    def main(args: Array[String]) {
        val n = readInt()
        (for (i <- 1 to n) yield solve(readLine())) foreach println
    }
}

object Hello extends App {

  import scala.io.StdIn._

  val k = readInt()

  def input(n: Int) = (1 to n).map(_ => readLine()).toSeq

  def toSeq(str: String) =
    str.toSeq.map(ch => Integer.parseInt(ch.toString))

  def cut(s: String) = if(s.length > 10) s.head + (s.length - 2).toString + s.reverse.head else s

  input(k).map(cut).map(println)
}

object Main {
	import java.{util=>ju}
	import scala.annotation._
	import scala.collection._
	import scala.collection.{mutable => mu}
	import scala.collection.JavaConverters._
	import scala.math._

	def main(args:Array[String])
	{
		val sc = new ju.Scanner(System.in)
		val n = sc.nextInt();
		val arr = ((1 to n) map (_ => sc.next())).toArray
		solve(0, arr, n);
	}

	def solve(i:Int, arr:Array[String], n:Int)
	{
		if(i==n) return

		val word = arr(i);

		if(word.length <= 10)
			println(word)
		else
		{
			print(word.charAt(0))
			print(word.length-2)
			print(word.charAt(word.length-1))
			println()
		}

		solve(i+1, arr, n)
	}
}

import scala.io.StdIn

object P71A {
  def main(args : Array[String]) {
    val n = StdIn.readInt
    for (i <- 1 to n) println(change(StdIn.readLine))
    def change(line: String): String = {
      if (line.length > 10) line.head.toString + (line.length - 2) + line.last
      else line
    }
  }
}

import scala.collection.mutable._
import scala.math._
import scala.util.control.Breaks.break
import scala.util.control.Breaks.breakable
import java.util._
object Main extends App {
  val sc = new Scanner(System.in)
  val n = readLine.toInt
  for(i <- 0 until n) {
    val s = readLine
    if(s.length <= 10) println(s)
    else println(s.head.toString + (s.length - 2) + s.last.toString)
  }
}

object Program extends App{
  val times = scala.io.StdIn.readInt()
  val input = (1 to times).map(_ => scala.io.StdIn.readLine())
  val refined = input.map(x => if(x.size > 10) x.take(1) + (x.size-2) + x.takeRight(1) else x)
  val res = refined
  res.foreach(x => println(x))
}

import scala.collection.mutable
object WayTooLongWords extends App {

  //println("Enter the number of words")
  val numb = scala.io.StdIn.readInt()

  def askWord(n: Int) = {
      val container = mutable.ArrayBuffer[String]()
    Range(1, n + 1).foreach(x => {

      val word = scala.io.StdIn.readLine()
      container += word
    })
    container
  }

  def abbr(w: String) = {
    if (w.length() > 10) {
      s"${w(0)}${w.length() - 2}${w.last}"
    } else w

  }
    askWord(numb).foreach((x: String) => println(abbr(x)))

  //askWord(numb)

  //println(abbr("nonsapevocosascrivere"))
  //Range(1,10).foreach(println)

}

import scala.io.StdIn

object Source extends App {

  val n = StdIn.readLine().toInt

  (1 to n).map(_ => StdIn.readLine()).map(s => {
    if (s.length <= 10) s
    else s.take(1) + (s.length - 2) + s.takeRight(1)
  }).foreach(println)

}

object Main extends App {
  val size = readLine().toInt
  for (i <- 1 to size) {
    val str = readLine()
    if (str.size > 10) println(str.head + (str.size - 2).toString + str.last)
    else println(str)
  }
}

import scala.io.StdIn._

object WayTooLongWords_71A extends App {
  def abbrv(word: String): String = {
    if (word.length > 10)
      word(0) + (word.length - 2).toString() + word(word.length - 1)
    else
      word
  }

  val n = readInt

  for (i <- 1 to n) yield {
    println(abbrv(readLine))
  }
}

object cf extends App{
  val t = readInt()
  for (t <- 0 to t-1) {
    var s = readLine()
    val l = s.length()
    if (l > 10) {
      s = s(0)+(l-2).toString+s(l-1)
      println(s)
    }
    else {
      println(s)
    }
  }
}

object Cf71A extends App {
  val n = readInt()
  for (i <- 1 to n) {
    val s = readLine()
    val len = s.length
    println(if (len <= 10) s else s(0) + (len - 2).toString + s(len - 1))
  }
}

import scala.collection.mutable.ArrayBuffer

/**
  * Created by mid-s on 11.09.16.
  */
object Demo {
  def main(args: Array[String]) {
    val count = readLine().toString().toInt

    var resp = new ArrayBuffer[String]
    for (i <- 1 to count) {
      var ln = readLine().toString()
      if (ln.length > 10) {
        resp += (ln(0).toString + (ln.length -2).toString + ln(ln.length -1).toString)
        //println(ln(0).toString + (ln.length -2).toString + ln(ln.length -1).toString)
      } else {
        resp += (ln)
        //println(ln)
      }
    }
    for (x <- resp) {
      println(x)
    }

  }
}

import scala.io.StdIn
object solution extends App{

   val tests = StdIn.readInt

   for(test <- 1 to tests){
        val text = StdIn.readLine
       if(text.length > 10){
        val output = text.head.toString + (text.length-2) + text.last.toString
        println(output)
       } else{
            println(text)
       }

   }

}

import scala.io.StdIn._

object Main {

  def main(args: Array[String]) {
    val n = readInt()
    (1 to n).foreach { i =>
      val s = readLine()
      val ans = if (s.length > 10) "" + s(0) + (s.length - 2) + s(s.length - 1) else s
      println(ans)
    }
  }

}

object A71 extends App {

  var n: Int = readInt()
  while (n>0){
    val input = readLine()
    val l = input.length
    if (l > 10){
      println(input(0)+(l-2).toString+input(l-1))
    } else {
      println(input)
    }
    n-=1
  }

}

object CF0071A extends App {

  val n = readInt()

  (1 to n).foreach(e => {
    val str = readLine()
    if (str.length > 10) {
      println(str.charAt(0).toString + (str.length - 2) + str.charAt(str.length -1 ).toString)
    } else {
      println(str)
    }
  })
}

import scala.io.StdIn

object Solution extends App {
  val N = StdIn.readInt()
  for (i <- 1 to N) {
    val str = StdIn.readLine()
    if (str.length <= 10) {
      println(str)
    } else {
      println(s"${str.head}${str.length - 2}${str.last}")
    }
  }
}

object P71A {
  def main(args : Array[String]) {
    val n = readInt
    for (i <- 1 to n) work(readLine)

    def work(line: String) = {
      if (line.length > 10) {
        print(line.head); print(line.length - 2); println(line.last)
      } else println(line)
    }
  }

  ///********************************************************************
  ///                     easy input buffer
  ///
  val rbuf = new Array[Byte](8192);
  var canReadBufMore = true;
  var rbufCursor = rbuf.length;
  var readSize = 0;
  def readByte: Byte = {
    try {
      if (rbufCursor >= rbuf.length) {
        if (canReadBufMore) {
          readSize = System.in.read(rbuf);
          if (readSize < rbuf.length) {
            canReadBufMore = false;
          }
          rbufCursor = 0;
        }
      }
    } catch { case e: Exception => /* do nothing */}
    if (rbufCursor != readSize) {
      rbufCursor += 1
      rbuf(rbufCursor - 1)
    } else -1;
  }

  ///********************************************************************
  ///                    for read integers
  ///
  def readInt : Int = {
    var result = 0
    var read: Byte = 0
    var sign = false

    do {
      read = readByte
    } while (read != -1 && (read != '-' && read < '0' || read > '9'))

    if (read == -1) return Integer.MIN_VALUE;
    if (read == '-') { sign = true; read = readByte }

    do {
      result = (result << 3) + (result << 1) + read - '0';
      read = readByte;
    } while (read != -1 && read >= '0' && read <= '9');
    if (read == 13) readByte; // skip 10

    if (sign) -result else result
  }

  ///********************************************************************
  ///                    for read line
  ///
  val lBuf = new Array[Byte](100)
  def readLine: String = {
    var read = readByte;
    var lPointer = 0;
    try {
      while (read > 13) {
        lPointer += 1
        lBuf(lPointer - 1) = read;
        read = readByte
      }
      if (read == -1) return null;
      if (read == 13) readByte; // skip 10
    } catch { case e: Exception => /* do nothing */}
    return new String(lBuf, 0, lPointer);
  }
}

import java.util.Scanner

object R71_A extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt()
  sc.nextLine()
  val words = for(i <- 0 until n) yield sc.nextLine()

  words.foreach(w => {println(shorten(w,10))})

  def shorten(w:String, k:Int):String = {
    if(w.length > k){
      "" + w.charAt(0) + (w.length()-2) + w.charAt(w.length-1)
    }else{
      w
    }
  }
}

object Abrev {

  import scala.io.StdIn.{readLine,readInt}

  def readStdIn: List[String] = {
    val num = readLine.toInt
    def inner(lst: List[String], cnt: Int): List[String] = {
      if (num == cnt) lst.reverse
      else inner(readLine :: lst, cnt+1)
    }
    inner(List(), 0)
  }

  def abbreviateWord(str: String): String = {
    if (str.length > 10) {
      str(0)+(str.length-2).toString+str.last
    }else str
  }

  def abbreviateAll(lst: List[String]): List[String] = {
    lst.map(abbreviateWord)
  }

  def main(args: Array[String]): Unit = {
    val inp = readStdIn
    abbreviateAll(inp).foreach(println)
  }
}

import scala.collection.mutable
object WayTooLongWords extends App {

  val numb = scala.io.StdIn.readInt()

  for (x <- 1 to numb){
      val word = scala.io.StdIn.readLine()
      val s = word.length()
      println(if (s > 10) word(0) + s"${s - 2}" + word.last else word)
  }

}

import scala.io.StdIn

object Main {
  def main(args: Array[String]) {
    val n = StdIn.readInt()

    for (_ <- 1 to n ) {
      val s = StdIn.readLine()

      if (s.length > 10) {
        println("" + s.charAt(0) + (s.length - 2) + s.charAt(s.length - 1))
      } else {
        println(s)
      }
    }
  }
}

object test
{
    def main(args : Array[String])
    {
        val n = readInt()
        for(i <- 1 to n)
        {
            val s = readLine()
            if(s.length > 10)
                println(s(0)+(s.length-2).toString+s(s.length-1))
            else
                println(s)
        }
    }
}

import java.util.Scanner

object A00071 extends App {
  def shorten(word: String): String = {
    def trim = word(0).toString + (word.size - 2) + word(word.size - 1)
    val isLonger = word.size > 10
    if (isLonger) trim else word
  }

  def execute(fn: String => String)(scanner: Scanner, n: Int) = {
    for (i <- 1 to n) {
      val str = scanner.nextLine();
      println(fn(str));
    }
  }

  val scanner = new Scanner(System.in)
  val n = scanner.nextInt();
  scanner.nextLine();
  execute(shorten)(scanner, n)
  scanner.close()
}

import scala.io.StdIn

object P71A {
  def main(args : Array[String]) {
    val n = StdIn.readInt
    for (i <- 1 to n) work(StdIn.readLine)

    def work(line: String) = {
      if (line.length > 10) {
        print(line.head); print(line.length - 2); println(line.last)
      } else println(line)
    }
  }
}

import java.io._

object P71A {
  def main(args : Array[String]) {
    val br = new BufferedReader(new InputStreamReader(System.in))
    val bw = new BufferedWriter(new OutputStreamWriter(System.out))
    val n = br.readLine.toInt
    (1 to n).map(i => solveLine(br.readLine))
    bw.close

    def solveLine(line: String) {
      if (line.length > 10) {
        bw.write(line.head)
        bw.write((line.length - 2).toString)
        bw.write(line.last)
      }
      else bw.write(line)
      bw.write(13); bw.write(10)
    }
  }
}

import java.util.Scanner

object Main {

  def fix(s: String) = {
    if (s.length > 10)
      "" + s(0) + (s.length() - 2) + s(s.length - 1)
    else
      s
  }

  def main(args: Array[String]): Unit = {
    val in = new Scanner(System.in)
    val n = in.nextInt
    val s = for (i <- 0 until n) yield fix(in.next)
    println(s.mkString("\n"))
  }

}

import scala.Console
import util.control.Breaks._

object App {

  def main(args : Array[String]) {

    var maxCount = 0
    var line :String = ""

    maxCount = Console.readLine().toInt

       for (i <- 1 to maxCount) {

         line = Console.readLine()

               if(line.length() <= 10){
                 println(line)
               }else{
                 val value = line.length() - 2
                 println(""+line.charAt(0).toChar + value + line.charAt(line.length() - 1).toChar)
               }

      }

  }

}

object P71A {
  def main(args : Array[String]) {
    val n = readInt
    for (i <- 1 to n) work(readLine)

    def work(line: String) = {
      if (line.length > 10) {
        print(line.head); print(line.length - 2); println(line.last)
      } else println(line)
    }
  }
}

/**
 * Created by vol on 9/15/14.
 */
object A71 extends App{
  val n = readInt()

  //println(if (str.length > 10) str(0) + (str.length - 2) + str(str.length)  else str)
  def loop(n:Int, i:Int, value:String):String = {
    val str = readLine()
    if (n == i)
      if (str.length > 10)
        value + "\n" + str(0) + (str.length - 2).toString + str(str.length - 1)
      else value + "\n" + str

    else
      if (str.length > 10)
        loop(n, i + 1, value + "\n" + str(0) + (str.length - 2).toString + str(str.length - 1))
      else {
        loop(n, i + 1, value + "\n" + str) }
  }

  println(loop(n , 1 , ""))
}

object Main {
  def main(args: Array[String]) {
    val times = readLine().toInt
    for (_ <- 1 to times) {
      val str = readLine()
      if (str.length <= 10) {
        println(str)
      }
      else {
        print(str(0))
        print(str.length - 2)
        println(str(str.length - 1))
      }
    }
  }
}

object Program extends App{
  val times = scala.io.StdIn.readInt()
  val input = (1 to times).map(_ => scala.io.StdIn.readLine())
  val refined = input.map(x => if(x.size > 10) x.take(1) + (x.size-2) + x.takeRight(1) else x)
  val res = refined
  res.foreach(x => println(x))
}

object Main extends App {
val n = readInt()

val l = (for ( i <- 0 until n) yield{readLine})

for ( i <- 0.to(n-1) ) {
if (l(i).length<=10)
println(l(i))
else {
print(l(i).head)
print(l(i).length-2)
println(l(i).last)
}
}
}

object Main{

    def main(args:Array[String]){
        val n = readLine.toInt
        for(i<- 0 until n){
            val s = readLine
            if(s.length()<=10)
                println(s)
            else{
                print(s(0))
                print(s.length()-2)
                println(s(s.length()-1))
            }
        }

    }
}

// http://codeforces.com/problemset/problem/71/A

import scala.io.StdIn.readInt
import scala.io.StdIn.readLine

object WayTooLongWords {
    def main(args: Array[String]): Unit = {
        val n: Int = readInt()
        for(i <- 1 to n) {
            var word = readLine()
            var len = word.length
            if(len > 10) {
                println(f"${word.substring(0, 1)}%s${len-2}%d${word.takeRight(1)}%s")
            } else {
                println(word)
            }
        }
    }
}

import scala.io.StdIn

object Solution extends App {
  val N = StdIn.readInt()
  for (i <- 1 to N) {
    val str = StdIn.readLine()
    if (str.length <= 10) {
      println(str)
    } else {
      println(s"${str.head}${str.length - 2}${str.last}")
    }
  }
}

object HelloWorld {
  def main(args: Array[String]): Unit = {
  	var m = readInt()
  	for (i <- 1 to m){
  		var s = readLine()
  		if (s.length() > 10){
  			var t = s(0) + (s.length()-2).toString + s(s.length()-1)
  				println(t)
  			}else{
  				println(s)
  			}
  	}
  	}
}

object Codeforces71A extends App{

  def Approx(rec:Double):Long={
    if (rec-rec.toInt>0) {
      return rec.toInt+1
    }
    else{
      return rec.toInt
    }
  }

  var ans:Array[String]=Array()
  val s:Int=scala.io.StdIn.readInt
  for (i <- 1 to s){
    val k:String=scala.io.StdIn.readLine
    val wordlength=k.length
    if (wordlength>10){
      var temp:String=""
      temp+=k(0)
      temp+=wordlength-2
      temp+=k(wordlength-1)
      ans = ans:+temp
    }
    else{
      ans = ans:+k
    }
  }
  for (i <- 0 to s-1){
    println(ans(i))
  }

}

object CF0071A extends App {

  val n = readInt()

  (1 to n).foreach(e => {
    val str = readLine()
    if (str.length > 10) {
      println(str.charAt(0).toString + (str.length - 2) + str.charAt(str.length -1 ).toString)
    } else {
      println(str)
    }
  })
}

object t71a extends App {

  import java.io.{BufferedReader, InputStreamReader}
  import java.util.StringTokenizer

    val br = new BufferedReader(new InputStreamReader(System.in))
    val input = br.readLine()
    val st = new StringTokenizer(input)
    val wordCount = Integer.parseInt(st.nextToken(" "))
    val maxLength = 10
    val wordList = for(i <- 1 to wordCount) yield br.readLine()
    wordList.foreach { word =>
      if(word.length <= 10) println(word)
      else {
        val firstLetter = word(0)
        val lastLetter = word(word.length - 1)
        println(s"$firstLetter${word.length-2}$lastLetter")
      }
    }

}

 object Main extends App {

  def A71={
    def packWord(s:String, i: Int): String ={
      s.length> i match {
        case false => s
        case true => s"${s(0)}${s.length - 2}${s.last}"
      }
    }
    (1 to readInt).map(x => readLine).map(packWord(_,10)).foreach(println(_))
  }

  A71
}

object Main {
  def main(args: Array[String]) = {
    val num = readLine.toInt

    def wtlw(n:Int):Unit = n match {
      case 0 => print("")
      case m => {
        val line = readLine
        val lline = line.length
        if(lline < 11) println(line) else println(line.head + (lline-2).toString + line.substring(lline - 1))
        wtlw(n-1)
      }

    }
    wtlw(num)
  }
}

object Main extends App {

  def A71={
    def packWord(s:String, i: Int): String ={
      s.length> i match {
        case false => s
        case true => s"${s(0)}${s.length - 2}${s.last}"
      }
    }
    (1 to readInt).map(x => readLine).map(packWord(_,10)).foreach(println(_))
  }

}

object Solution71A extends Application {

  def solution() {
    val n = _int
    val lines = 1.to(n).map(_ => _string)
    val result = lines.map(l => l match {
      case a if (a.length <= 11) => a
      case b => {
        val len = b.length
        b.charAt(0) + (len - 2).toString + b.charAt(len - 1)
      }
    })
    result.foreach(println(_))
  }

  //////////////////////////////////////////////////
  import java.util.Scanner
  val SC: Scanner = new Scanner(System.in)
  def _line: String = SC.nextLine
  def _int: Int = SC.nextInt
  def _long: Long = SC.nextLong
  def _string: String = SC.next
  solution()
}

import scala.collection.mutable._
import scala.math._
import scala.util.control.Breaks.break
import scala.util.control.Breaks.breakable
import java.util._
object Main extends App {
  val sc = new Scanner(System.in)
  val n = readLine.toInt
  for(i <- 0 until n) {
    val s = readLine
    if(s.length < 10) println(s)
    else println(s.head.toString + (s.length - 2) + s.last.toString)
  }
}

object Main {
	import java.{util=>ju}
	import scala.annotation._
	import scala.collection._
	import scala.collection.{mutable => mu}
	import scala.collection.JavaConverters._
	import scala.math._

	def main(args:Array[String])
	{
		val sc = new ju.Scanner(System.in)
		val n = sc.nextInt();
		val arr = ((1 to n) map (_ => sc.next())).toArray
		solve(0, arr, n);
	}

	def solve(i:Int, arr:Array[String], n:Int)
	{
		if(i==n) return

		val word = arr(i);

		if(word.length < 10)
			println(word)
		else
		{
			print(word.charAt(0))
			print(word.length-2)
			print(word.charAt(word.length-1))
			println()
		}

		solve(i+1, arr, n)
	}
}

import scala.io.StdIn

object WayTooLongWords extends App {

  val n = StdIn.readInt()
  for (i <- Range(0, n - 1)) {
    println(imply(StdIn.readLine()))
  }
  print(imply(StdIn.readLine()))

  def imply(word: String): String = {
    val len = word.length
    if (len < 10) word
    else {
      word.charAt(0) + (len - 2).toString + word.charAt(len - 1)
    }
  }
}

import scala.io.StdIn

object WayTooLongWords extends App {

  val n = StdIn.readInt()
  for (i <- Range(0, n)) {
    print(imply(StdIn.readLine()))
  }

  def imply(word: String): String = {
    val len = word.length
    if (len < 10) word
    else {
      word.charAt(0) + (len - 2).toString + word.charAt(len - 1)
    }
  }
}

import scala.io.StdIn

object WayTooLongWords extends App {

  val n = StdIn.readInt()
  for (i <- Range(0, n)) {
    println(imply(StdIn.readLine()))
  }

  def imply(word: String): String = {
    val len = word.length
    if (len < 10) word
    else {
      word.charAt(0) + (len - 2).toString + word.charAt(len - 1)
    }
  }
}

object Main extends App {
val n = readInt()

val l = (for ( i <- 0 until n) yield{readLine})

for ( i <- 0.to(n-1) ) {
if (l(i).length<10)
println(l(i))
else {
print(l(i).head)
print(l(i).length-2)
println(l(i).last)
}
}

}

import scala.io.StdIn
object solution extends App{

   val tests = StdIn.readInt

   for(test <- 1 to tests){
        val text = StdIn.readLine

        val output = text.head.toString + (text.length-2) + text.last.toString
        println(output)

   }

}

import scala.collection.immutable.StringOps
object Main {
  def res(x: Int) {
    val e = readLine
    if( e.size < 10 )
      println(e)
    else
      println(e.head.toString + (e.size-2) + e.last.toString)
  }
  def main(args: Array[String]) {
    val N = readInt
    1 to N foreach( res )
  }
}

import scala.io.StdIn

object CodeForces extends App {

  val n = StdIn.readLine().toInt

  for {
    _ <- 0 until n
    word = StdIn.readLine()
    replaced = if (word.length >= 10) s"${word.charAt(0)}${word.length - 2}${word.charAt(word.length - 1)}" else word
  } {
    println(replaced)
  }
}

object Main extends App {
    val n = readInt()

    val l = (for ( i <- 0 until n)  yield{readLine})

    for ( i <- 0.to(n-1) ) {
        if (l(i).length<10)
            println(l(i))
        else {
            print(l(i).head)
            print(l(i).length-2)
            println(l(i).last)
        }
    }

}

object Main extends App {
    val n = readInt()

    val l = (for ( i <- 0 until n)  yield{readLine})

    for ( i <- 0.to(n-1) ) {
        if (l(i).length<10)
            println(l(i))
        else {
            print(l(i).head)
            print(l(i).length-2)
            println(l(i).last)
        }
    }
}

import java.util.Scanner

object R71_A extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt()

  val words = for(i <- 0 until n) yield sc.nextLine()

  words.foreach(w => {println(shorten(w,10))})

  def shorten(w:String, k:Int):String = {
    if(w.length > k){
      "" + w.charAt(0) + (w.length()-2) + w.charAt(w.length-1)
    }else{
      w
    }
  }
}

object WayTooLongWords {
	def main (args: Array[String]) {
		val scanner = new java.util.Scanner(System.in)
				val number = scanner.nextLine().toInt
				for (i <- 1 to number) {
					val line = scanner.nextLine
							if (line.length >= 10)
								println(line.charAt(0) + (line.length-2).toString() + line.charAt(line.length-1))
								else
									println(line)
				}
	}
}

/**
 * Created by vol on 9/15/14.
 */
object A71 extends App{
  val n = readInt()

  //println(if (str.length > 10) str(0) + (str.length - 2) + str(str.length)  else str)
  def loop(n:Int, i:Int, value:String):String = {
    val str = readLine()
    if (n == i)
      if (str.length > 10)
        value + "\n" + str(0) + (str.length - 2).toString + str(str.length - 1)
      else str

    else
      if (str.length > 10)
        loop(n, i + 1, value + "\n" + str(0) + (str.length - 2).toString + str(str.length - 1))
      else {
        loop(n, i + 1, value + "\n" + str) }
  }

  println(loop(n , 1 , ""))
}

/**
 * Created by vol on 9/15/14.
 */
object A71 extends App{
  val str = readLine()

  println(if (str.length > 10) str(0) + (str.length - 2) + str(str.length)  else str)
}

object Main {
  def main(args: Array[String]) {
    val n = readInt()
    for (i <- 1 to n) {
      val str = readLine
      if (str.size < 10) println(str)
      else println(str.head.toString + (str.size - 2) + str.last.toString)
    }
  }
}

import java.io._
import scala.io.Source
import scala.util.control._
import scala.Console
import util.control.Breaks._

object App {

  def main(args : Array[String]) {

    var curCount = 0
    var maxCount = 0
    var line :String = ""

    maxCount = Console.readLine().toInt

    breakable{
       for (i <- 1 to maxCount) {

         line = Console.readLine()

             breakable{
               if(line.length() < 10){
                 break
               }else{
                 val value = line.length() - 2
                 println(line + " : " + line.charAt(0) + value + line.charAt(line.length() - 1))
               }
             }
      }
    }
  }

}

import java.io._
import scala.io.Source
import scala.util.control._
import scala.Console
import util.control.Breaks._

object App {

  def main(args : Array[String]) {

    var curCount = 0
    var maxCount = 0
    var line :String = ""

    maxCount = Console.readLine().toInt

    breakable{
       for (i <- 1 to maxCount) {

         line = Console.readLine()

             breakable{
               if(line.length() < 10){
                 println(line)
                 break
               }else{
                 val value = line.length() - 2
                 println(line.charAt(0).toChar + value + line.charAt(line.length() - 1).toChar)
               }
             }
      }
    }
  }

}

import java.io._
import scala.io.Source
import scala.util.control._
import scala.Console
import util.control.Breaks._

object App {

  def main(args : Array[String]) {

    var curCount = 0
    var maxCount = 0
    var line :String = ""

    maxCount = Console.readLine().toInt

    breakable{
       for (i <- 1 to maxCount) {

         line = Console.readLine()

             breakable{
               if(line.length() < 10){
                 println(line)
                 break
               }else{
                 val value = line.length() - 2
                 println(""+line.charAt(0).toChar + value + line.charAt(line.length() - 1).toChar)
               }
             }
      }
    }
  }

}

object Main extends App {
  val n = readInt
  var a = 0
  for(a <- 1 to n) {
    val s = readLine
    val l = s.length()
    println( if (l < 10) s else s.substring(0, 1) + l.toString() + s.substring(l-1,l) )
  }
}

import scala.collection.mutable.ArrayBuffer

/**
  * Created by mid-s on 11.09.16.
  */
object Demo {
  def main(args: Array[String]) {
    val count = io.Source.stdin.getLines().take(1).mkString.toInt
    var resp = new ArrayBuffer[String]
    for (ln <- io.Source.stdin.getLines) {
      if (ln.length > count) {
        resp += (ln(0).toString + (ln.length -2).toString + ln(ln.length -1).toString)
        //println(ln(0).toString + (ln.length -2).toString + ln(ln.length -1).toString)
      } else {
        resp += (ln)
        //println(ln)
      }
    }
    for (el <- resp) {
      //println(el)
    }

  }
}

import scala.collection.mutable.ArrayBuffer

/**
  * Created by mid-s on 11.09.16.
  */
object Demo {
  def main(args: Array[String]) {
    val count = io.Source.stdin.getLines().take(1).mkString.toInt

    var resp = new ArrayBuffer[String]
    for (i <- 1 to count) {
      var ln = io.Source.stdin.getLines().take(1).mkString
      if (ln.length > 10) {
        resp += (ln(0).toString + (ln.length -2).toString + ln(ln.length -1).toString)
       } else {
        resp += (ln)
      }
    }
    for (el <- resp) {
      println(el)
    }

  }
}

import scala.collection.mutable.ArrayBuffer

/**
  * Created by mid-s on 11.09.16.
  */
object Demo {
  def main(args: Array[String]) {
    val count = io.Source.stdin.getLines().take(1).mkString.toInt
    var resp = new ArrayBuffer[String]
    for (ln <- io.Source.stdin.getLines) {
      if (ln.length > count) {
        resp += (ln(0).toString + (ln.length -2).toString + ln(ln.length -1).toString)
        //println(ln(0).toString + (ln.length -2).toString + ln(ln.length -1).toString)
      } else {
        resp += (ln)
        //println(ln)
      }
    }
    for (el <- resp) {
      println(el)
    }

  }
}

import scala.collection.mutable.ArrayBuffer

/**
  * Created by mid-s on 11.09.16.
  */
object Demo {
  def main(args: Array[String]) {
    val count = io.Source.stdin.getLines().take(1).mkString.toInt
    var resp = new ArrayBuffer[String]
    for (ln <- io.Source.stdin.getLines) {
      if (ln.length > count) {
        resp += (ln(0).toString + (ln.length -2).toString + ln(ln.length -1).toString)
        println(ln(0).toString + (ln.length -2).toString + ln(ln.length -1).toString)
      } else {
        resp += (ln)
        println(ln)
      }
    }
//    for (el <- resp) {
//      println(el)
//    }

  }
}

import io.Source.stdin
object Demo {
  def main(args: Array[String]) {
    val count = stdin.getLines().take(1).mkString.toInt
    for (ln <- stdin.getLines) {
      if (ln.length > count) {
        println(ln(0).toString + (ln.length -2).toString + ln(ln.length -1).toString)
      } else {
        println(ln)
      }
    }

  }
}

object LongWords {
    def main(args: Array[String]) = {
        val input = Iterator.continually(scala.io.StdIn.readLine()).takeWhile(_ != null)

        val compressed = input.map(str => if(str.size > 10) s"${str.charAt(0)}${str.size - 2}${str.charAt(str.size - 1)}")
        compressed.foreach(println)
    }

}

import scala.io.Source
import java.io._

object P71A {
  def main(args : Array[String]) {
    val bw = new BufferedWriter(new OutputStreamWriter(System.out))
    Source.stdin.getLines.drop(1).map(solveLine)
    bw.close()

    def print(s: String) = bw.write(s)
    def newLine = { bw.write(13); bw.write(10) }
    def solveLine(s: String) = {
      if (s.length > 10) {
        print(s.head.toString)
        print((s.length - 2).toString)
        print(s.last.toString)
      }
      else print(s)
      newLine
    }
  }
}

object Main {
  def main(args: Array[String]) = {
    val num = readLine.toInt

    def wtlw(n:Int):Unit = n match {
      case 0 => print("")
      case m => {
        val line = readLine
        val lline = line.length
        if(lline < 10) println(line) else println(line.head + (lline-2).toString + line.substring(lline - 1))
        wtlw(n-1)
      }

    }
    wtlw(num)
  }
}

object SevenOneA {
	def main(args: Array[String]) {
		var n=readInt
		for(i<-0 until n){
			var s=readLine
			var z=s.charAt(0)+""+(s.length-2)+""+s.charAt(s.length-1)
			println(z)
		}
	}
}

import scala.collection.mutable
object WayTooLongWords extends App {

  val numb = scala.io.StdIn.readInt()

  for (x <- 1 to numb){
      val word = scala.io.StdIn.readLine()
      val s = word.length()
      println(s"${if (s > 10) word(0)+ word.length() - 2 + word.last else word}")
  }

}

import scala.collection.mutable
object WayTooLongWords extends App {

  val numb = scala.io.StdIn.readInt()

  for (x <- 1 to numb){
      val word = scala.io.StdIn.readLine()
      val s = word.length()
      println(if (s > 10) word(0) + s - 2 + word.last else word)
  }

}

object Main extends App {
  val size = readLine().toInt
  for (i <- 1 to size) {
    val str = readLine()
    if (str.size > 4) println(str.head + (str.size - 2).toString + str.last)
    else println(str)
  }
}

object TaskA {
  def main(args: Array[String]): Unit = {
    val wordsNumber = scala.io.StdIn.readInt()
    for (i <- 0 until wordsNumber) {
      val word = scala.io.StdIn.readLine()
      word.length match {
        case j if (j < 10) => println(word)
        case _ => println(s"${word(0)}${word.length - 2}${word(word.length - 1)}")
      }
    }
  }
}

object CF0071A extends App {

  val n = readInt()

  (1 to n).foreach(e => {
    val str = readLine()
    if (str.length > 4) {
      println(str.charAt(0).toString + (str.length - 2) + str.charAt(str.length -1 ).toString)
    } else {
      println(str)
    }
  })
}

object cf extends App{
  val t = readInt()
  for (t <- 0 to t-1) {
    var s = readLine()
    val l = s.length()
    if (l > 10) {
      s = s(0)+l.toString+s(l-1)
      println(s)
    }
    else {
      println(s)
    }
  }
}

object P71A {
  def main(args : Array[String]) {
    val n = readInt
    for (i <- 1 to n) work(readLine)

    def work(line: String) = {
      if (line.length > 10) {
        print(line.head); print(line.length - 2); println(line.last)
      } else println(line)
    }
  }

  ///********************************************************************
  ///                     easy input buffer
  ///
  val rbuf = new Array[Byte](8192);
  var canReadBufMore = true;
  var rbufCursor = rbuf.length;
  var readSize = 0;
  def readByte: Byte = {
    try {
      if (rbufCursor >= rbuf.length) {
        if (canReadBufMore) {
          readSize = System.in.read(rbuf);
          if (readSize < rbuf.length) {
            canReadBufMore = false;
          }
          rbufCursor = 0;
        }
      }
    } catch { case e: Exception => /* do nothing */}
    if (rbufCursor != readSize) {
      rbufCursor += 1
      rbuf(rbufCursor)
    } else -1;
  }

  ///********************************************************************
  ///                    for read integers
  ///
  def readInt : Int = {
    var result = 0
    var read: Byte = 0
    var sign = false

    do {
      read = readByte
    } while (read != -1 && (read != '-' && read < '0' || read > '9'))

    if (read == -1) return Integer.MIN_VALUE;
    if (read == '-') { sign = true; read = readByte }

    do {
      result = (result << 3) + (result << 1) + read - '0';
      read = readByte;
    } while (read != -1 && read >= '0' && read <= '9');
    if (read == 13) readByte; // skip 10

    if (sign) -result else result
  }

  ///********************************************************************
  ///                    for read line
  ///
  val lBuf = new Array[Byte](50)
  def readLine: String = {
    var read = readByte;
    var lPointer = 0;
    try {
      while (read > 13) {
        lPointer += 1
        lBuf(lPointer) = read;
        read = readByte
      }
      if (read == -1) return null;
      if (read == 13) readByte; // skip 10
    } catch { case e: Exception => /* do nothing */}
    return new String(lBuf, 0, lPointer);
  }
}

object Main{

    def main(args:Array[String]){
        val n = readLine.toInt
        for(i<- 0 until n){
            val s = readLine
            if(s.length()<10)
                println(s)
            else{
                print(s(0))
                print(s.length()-2)
                println(s(s.length()-1))
            }
        }

    }
}

import java.util.Scanner

/**
  * Created by zhmyh on 22/02/16.
  */
object WayTooLongWords extends App {
  val in = new Scanner(System.in)
  val wnum = in.nextLine().trim.toInt
  println(wnum)
  for (_ <- 0 until wnum) yield {
    val word = in.nextLine()
    println(compress(word.trim()))
  }

  def compress(word: String): String =
    if (word.length > 10)
      word.take(1) + (word.length - 2).toString + word.drop(word.length - 1)
    else
      word
}

object Main {
  def main(args: Array[String]) {
    val times = readLine().toInt
    for (_ <- 1 to times) {
      val str = readLine()
      if (str.length < 10) {
        println(str)
      }
      else {
        print(str(0))
        print(str.length - 2)
        println(str(str.length - 1))
      }
    }
  }
}

object codeforces {
  def main(args: Array[String]): Unit = {
    val n: Int = scala.io.StdIn.readLine().toInt
    for (_ <- 0 until n){
      val word: String = scala.io.StdIn.readLine()
      if (word.length <= 10){
        println(word)
      }else{
        println(word.head + word.length-2 + word(word.length-1))
      }
    }
  }
}

object codeforces {
  def main(args: Array[String]): Unit = {
    val n: Int = scala.io.StdIn.readLine().toInt
    for (_ <- 0 until n){
      val word: String = scala.io.StdIn.readLine()
      val l: Int = word.length
      if (l <= 10){
        println(word)
      }else{
        val result: String = word.head + l.toString + word(l-1)
        println(result)
      }
    }
  }
}

object codeforces {
  def main(args: Array[String]): Unit = {
    val n: Int = scala.io.StdIn.readLine().toInt
    for (_ <- 0 until n){
      val word: String = scala.io.StdIn.readLine()
      if (word.length <= 10){
        println(word)
      }else{
        println(word)
      }
    }
  }
}

object codeforces {
  def main(args: Array[String]): Unit = {
    val n: Int = scala.io.StdIn.readLine().toInt
    val word: String = scala.io.StdIn.readLine()
    println(word)
  }
}

object WayTooLongWords {
  def main(args : Array[String]) {
    val gls = io.Source.stdin.getLines
    gls drop(1)
    gls.map(shorten _) foreach(println)
  }
  def shorten(word : String) : String = {
    val len = word.length() - 2
    if (len > 2)
      return s"${word(1)}$len${word.last}"
    return word
  }
}

object WayTooLongWords {
  def main(args : Array[String]) {
    val gls = io.Source.stdin.getLines
    gls drop(1)
    gls.map(shorten _) foreach(println)
  }
  def shorten(word : String) : String = {
    val len = word.length() - 2
    if (len > 2)
      return s"${word(0)}$len${word.last}"
    return word
  }
}

object WayTooLongWords {
  def main(args : Array[String]) {
    val gls = io.Source.stdin.getLines
    gls.map(shorten _) foreach(println)
  }
  def shorten(word : String) : String = {
    val len = word.length() - 2
    if (len > 2)
      return s"${word(1)}$len${word.last}"
    return word
  }
}


On the well-known testing system MathForces, a draw of $$$n$$$ rating units is arranged. The rating will be distributed according to the following algorithm: if $$$k$$$ participants take part in this event, then the $$$n$$$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.For example, if $$$n = 5$$$ and $$$k = 3$$$, then each participant will recieve an $$$1$$$ rating unit, and also $$$2$$$ rating units will remain unused. If $$$n = 5$$$, and $$$k = 6$$$, then none of the participants will increase their rating.Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.For example, if $$$n=5$$$, then the answer is equal to the sequence $$$0, 1, 2, 5$$$. Each of the sequence values (and only them) can be obtained as $$$\lfloor n/k \rfloor$$$ for some positive integer $$$k$$$ (where $$$\lfloor x \rfloor$$$ is the value of $$$x$$$ rounded down): $$$0 = \lfloor 5/7 \rfloor$$$, $$$1 = \lfloor 5/5 \rfloor$$$, $$$2 = \lfloor 5/2 \rfloor$$$, $$$5 = \lfloor 5/1 \rfloor$$$.Write a program that, for a given $$$n$$$, finds a sequence of all possible rating increments.

The first line contains integer number $$$t$$$ ($$$1 \le t \le 10$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each line contains an integer $$$n$$$ ($$$1 \le n \le 10^9$$$) — the total number of the rating units being drawn.

Output the answers for each of $$$t$$$ test cases. Each answer should be contained in two lines. In the first line print a single integer $$$m$$$ — the number of different rating increment values that Vasya can get. In the following line print $$$m$$$ integers in ascending order — the values of possible rating increments.

import java.util

import scala.collection.mutable

object C {
  import InOut._
  def main(args: Array[String]): Unit = {}

  val LIMIT = 31650
  val isPrime = Array.fill(LIMIT)(true)
  isPrime(0) = false
  isPrime(1) = false

//  var i = 2
//  while (i * i < LIMIT) {
//    var j = i * i
//    if (isPrime(j)) {
//      while (j < LIMIT) {
//        isPrime(j) = false
//        j += i
//      }
//    }
//    i += 1
//  }
//  isPrime(1) = true
//  val primes = isPrime.indices.toArray.filter(isPrime(_))

  val t = nextInt
  for (_ <- 1 to t) {
    val n = nextInt
    var x = 1
    val q = new mutable.ArrayBuilder.ofInt
    q += 0
    while (x * x <= n) {
      q += x
      val p2 = n / x
      if (p2 != x) q += p2
      x += 1
    }
//    var i = 0
//    while (primes(i) * primes(i) <= n) {
//      val p = primes(i)
//      if (p > x) q += p
//      if (p2 > x && p != p2) q += p2
//      i += 1
//    }
    val res = q.result.sorted
    println(res.size)
    println(res.mkString(" "))
  }

  out.println()
  out.flush()

  final object InOut {
    val in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
    val out = new java.io.PrintWriter(System.out, false)
    private[this] var tokenizer: java.util.StringTokenizer = _
    def nextToken: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new java.util.StringTokenizer(in.readLine)
      tokenizer.nextToken
    }
    def nextInt = Integer.parseInt(nextToken)
    def nextLong = java.lang.Long.parseLong(nextToken)
    def nextBig = BigInt(nextToken)
    def nextInts(n: Int) = Array.fill(n) { nextInt }
    def nextLongs(n: Int) = Array.fill(n) { nextLong }
    def nextBigs(n: Int) = Array.fill(n) { nextBig }
    def nextLine = in.readLine
  }
}

import java.util

import scala.collection.mutable

object C {
  import InOut._
  def main(args: Array[String]): Unit = {}

  val LIMIT = 31650
  val isPrime = Array.fill(LIMIT)(true)
  isPrime(0) = false
  isPrime(1) = false

  var i = 2
  while (i * i < LIMIT) {
    var j = i * i
    if (isPrime(j)) {
      while (j < LIMIT) {
        isPrime(j) = false
        j += i
      }
    }
    i += 1
  }
  isPrime(1) = true
  val primes = isPrime.indices.toArray.filter(isPrime(_))

  val t = nextInt
  for (_ <- 1 to t) {
    val n = nextInt
    var i = 0
    val q = new mutable.ArrayBuilder.ofInt
    q += 0
    while (primes(i) * primes(i) <= n) {
      val p = primes(i)
      val p2 = n / p
      q += p
      if (p != p2) q += p2
      i += 1
    }
    val res = q.result.sorted
    println(res.size)
    println(res.mkString(" "))
  }

  out.println()
  out.flush()

  final object InOut {
    val in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
    val out = new java.io.PrintWriter(System.out, false)
    private[this] var tokenizer: java.util.StringTokenizer = _
    def nextToken: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new java.util.StringTokenizer(in.readLine)
      tokenizer.nextToken
    }
    def nextInt = Integer.parseInt(nextToken)
    def nextLong = java.lang.Long.parseLong(nextToken)
    def nextBig = BigInt(nextToken)
    def nextInts(n: Int) = Array.fill(n) { nextInt }
    def nextLongs(n: Int) = Array.fill(n) { nextLong }
    def nextBigs(n: Int) = Array.fill(n) { nextBig }
    def nextLine = in.readLine
  }
}

import java.util

import scala.collection.mutable

object C {
  import InOut._
  def main(args: Array[String]): Unit = {}

  val LIMIT = 31650
  val isPrime = Array.fill(LIMIT)(true)
  isPrime(0) = false
  isPrime(1) = false

  var i = 2
  while (i * i < LIMIT) {
    var j = i * i
    if (isPrime(j)) {
      while (j < LIMIT) {
        isPrime(j) = false
        j += i
      }
    }
    i += 1
  }
  isPrime(1) = true
  val primes = isPrime.indices.toArray.filter(isPrime(_))

  val t = nextInt
  for (_ <- 1 to t) {
    val n = nextInt
    var x = 0
    val q = new mutable.ArrayBuilder.ofInt
    while (x * x <= n) {
      q += x
      x += 1
    }
    var i = 0
    while (primes(i) * primes(i) <= n) {
      val p = primes(i)
      val p2 = n / p
      if (p > x) q += p
      if (p2 > x && p != p2) q += p2
      i += 1
    }
    val res = q.result.sorted
    println(res.size)
    println(res.mkString(" "))
  }

  out.println()
  out.flush()

  final object InOut {
    val in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
    val out = new java.io.PrintWriter(System.out, false)
    private[this] var tokenizer: java.util.StringTokenizer = _
    def nextToken: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new java.util.StringTokenizer(in.readLine)
      tokenizer.nextToken
    }
    def nextInt = Integer.parseInt(nextToken)
    def nextLong = java.lang.Long.parseLong(nextToken)
    def nextBig = BigInt(nextToken)
    def nextInts(n: Int) = Array.fill(n) { nextInt }
    def nextLongs(n: Int) = Array.fill(n) { nextLong }
    def nextBigs(n: Int) = Array.fill(n) { nextBig }
    def nextLine = in.readLine
  }
}