object P71A {
  def main(args : Array[String]) {
    val n = readInt
    (1 to n).map(i => work(readLine))

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

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))
		}
	}

}

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)
  }
}

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 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
  }
}

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.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()
    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)
    }
  }
}

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)
  }
}

/*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;
		}
	}
}

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()
}

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)
  }
}

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 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._
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)
  }
}

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 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)
        }
    }
  }
}

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 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 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)
  }

}

// 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)
            }
        }
    }
}

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)
	}
}

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.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
  }
}

/**
 * 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 )
    }

  }

}

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)
    }
  }

}

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)
    }
  }
}

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 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 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)
}

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 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
}

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.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 )
  }
}

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.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 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 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 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 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 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))
  }

}

/**
 * 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 , ""))
}

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)
               }

      }

  }

}

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)
               }
             }
      }

  }

}

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))
}

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)
    }

  }
}

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
  }

}

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()
    }
  }
}

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)
    }
  }
}

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)
}

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 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 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
    }
  }
}

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)
    }
  }
}

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.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 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 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)

}

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 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

/**
  * 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.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 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))
      }
    }
  }
}

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)
  }
}

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(_))
  }

}

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
  }
}


import java.io._
import java.util._

import scala.collection.mutable

object C {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

  def nextInt: Int = return Integer.parseInt(next)

  def nextLong: Long = return java.lang.Long.parseLong(next)

  def nextDouble: Double = return java.lang.Double.parseDouble(next)

  class MultiHashSet[T <% Comparable[T]] {
    val map = new mutable.HashMap[T, Int]()

    def count(x: T): Int = {
      return map.getOrElse(x, 0)
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }

    def removeAll(x: T) = {
      map.remove(x)
    }
  }

  class MultiTreeSet[T <% Comparable[T]] {
    val map = new TreeMap[T, Int]()

    def count(x: T): Int = {
      val res = map.get(x)
      if (res == null)
        return 0
      return res
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def first(): T = return map.firstKey()

    def last(): T = return map.lastKey()

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  /**
   * Segment tree for any commutative function
   * @param values Array of Int
   * @param commutative function like min, max, sum
   * @param zero zero value - e.g. 0 for sum, Inf for min, max
   */
  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {
    private val SIZE = 1e5.toInt
    private val n = values.length
    val t = new Array[Int](2 * n)
    Array.copy(values, 0, t, n, n)

    // build segment tree
    def build = {
      for (i <- n - 1 until 0 by -1) {
        t(i) = commutative(t(2 * i), t(2 * i + 1))
      }
    }

    // change value at position p to x
    // TODO beatify
    def modify(p: Int, x: Int) = {
      var pos = p + n
      t(pos) = x
      while (pos > 1) {
        t(pos / 2) = commutative(t(pos), t(pos ^ 1))
        pos /= 2
      }
    }

    // TODO implement me!
    def modify(p: Int, left: Int, right: Int) = ???

    def query(p: Int) = ???

    // sum [l, r)
    // min l = 0
    // max r = n
    // TODO beatify
    def query(left: Int, right: Int): Int = {
      var res = zero
      var r = right + n
      var l = left + n
      while (l < r) {
        if (l % 2 == 1) {
          res = commutative(res, t(l))
          l += 1
        }
        if (r % 2 == 1) {
          r -= 1
          res = commutative(res, t(r))
        }
        l /= 2
        r /= 2
      }
      res
    }
  }

  def solve: Int = {
    val n = nextInt
    val k = nextInt
    val a = new Array[Int](n)
    var ans = 0L
    val left = new MultiHashSet[Long]
    val right = new MultiHashSet[Long]
    for (i <- 0 until n) {
      a(i) = nextInt
      right.add(a(i))
    }
    for (i <- 0 until n) {
      right.remove(a(i))
      if (a(i) % k == 0)
        ans += 1L * left.count(a(i) / k) * right.count(1L * a(i) * k)
      left.add(a(i))
    }
    out.println(ans)
    return 0
  }
}

import io.StdIn._
import scala.collection.mutable._

object Solution {

  def main(args: Array[String]) {
    val line = readLine().split(" ").map(_.toInt)
    val (n, k) = (line(0), line(1))
    val seq = readLine().split(" ").map(_.toInt)
    val l = Map[Int, Int]().withDefaultValue(0)
    val r = Map[Int, Int]().withDefaultValue(0)
    var res = 0L

    for (i <- seq.tail) { r(i) += 1 }
    l(seq.head) = 1
    for (i <- seq.tail) {
      r(i) = Math.max(0, r(i) - 1)
      if (i % k == 0 && Math.abs(i * k.toLong) < 1000000007) {
          res += l(i/k) * r(i*k).toLong
      }
      l(i) += 1
    }

    println(res)

  }

}

import scala.collection.mutable
import scala.io.StdIn._

object CF567C extends App {
  val Array(n, k) = readLine().split(" ").map(_.toLong)
  val a = readLine().split(" ").map(_.toLong)

  val l = mutable.Map[Long, Long]().withDefaultValue(0)
  // elements to the left of current element
  val r = mutable.Map[Long, Long]().withDefaultValue(0) // elements to the right of current element

  a.foreach { e => r.update(e, r(e) + 1)}
  // all elements are to the right initially

  var res = 0.toLong
  a.foreach { e =>
    // if current element is divisible by k,
    // retrieve number of elements equal to e/k to the left of the current element
    val nl = if (e % k == 0) l(e / k) else 0

    // put current element from right to left
    l.update(e, l(e) + 1)
    r.update(e, r(e) - 1)

    // retrieve number of elements equal to e*k to the right of the current element
    val nr = r(e * k)

    res += nl * nr
  }

  println(res)
}

import scala.annotation.tailrec
import scala.io.StdIn.readLine

// case class R(c: Map[Long,Long], g: Map[Long,Long], r: Long)
// object Main {
//   // Document: http://www.scala-lang.org/api/current/#package
//   // -----------------------------------------------------------------------------
//   def main(args: Array[String]) : Unit = {
//     val (n,k) = {
//       val nk = readLine().split(" ").map(_.toLong)
//       (nk(0), nk(1))
//     }
//     val a = readLine().split(" ").map(_.toLong)
//     val l = a.foldLeft(R(Map[Long,Long](),Map[Long,Long](),0l))((r,i) => r match {
//                                                    case R(c,g,r) => {
//                                                      val new_r = r + g.getOrElse(i,0l)
//                                                      val new_c = c + (i->(c.getOrElse(i,0l)+1l))
//                                                      val new_g =
//                                                        if(i % k == 0)
//                                                          g + (i*k->(g.getOrElse(i*k,0l)+c.getOrElse(i/k,0l)))
//                                                        else
//                                                          g
//                                                      R(new_c,new_g,new_r)
//                                                    }
//                                                  })
//     println(l.r)
//   }
// }

object Main {
  import scala.collection.mutable.Map
  case class R(c: Map[Long,Long], g: Map[Long,Long], r: Long)
  // Document: http://www.scala-lang.org/api/current/#package
  // -----------------------------------------------------------------------------
  def main(args: Array[String]) : Unit = {
    val (n,k) = {
      val nk = readLine().split(" ").map(_.toLong)
      (nk(0), nk(1))
    }
    val a = readLine().split(" ").map(_.toLong)
    val l = a.foldLeft(R(Map[Long,Long](),Map[Long,Long](),0l))(
        (r,i) => r match {
          case R(c,g,r) => {
            val new_r = r + g.getOrElse(i,0l)
            val t = c.getOrElse(i,0l)+1l
            val j = g.getOrElse(i*k,0l)+c.getOrElse(i/k,0l)
            c += (i->t)
            if(i % k == 0)
              g += (i*k->j)
            R(c,g,new_r)
          }
        })
    println(l.r)
  }
}

import scala.annotation.tailrec
import scala.io.StdIn.readLine
import scala.collection.immutable.HashMap

// ----------------------------------------------------------------------------0
// ----------------------------------------------------------------------------0
object Main {
  import java.io.{BufferedReader, PrintWriter, PrintStream, PushbackReader}
  import scala.annotation.tailrec
  class MyConsole(val in: BufferedReader, val _out: PrintStream,
                  val err: PrintStream) {
    // PrintWriter do not flush automatically
    val out = new PrintWriter(_out,false)
    // If argument is null, there are ambiguous which function will be called
    def print(obj: Any)                  = out.print(if(obj == null) "null" else obj.toString)
    def println()                        = out.println()
    def println(obj: Any)                = out.println(obj)
    def printf(text: String, args: Any*) = out.printf(text.format(args : _*))
    // NOTE: YOU MUST FLUSH BEFORE END OF MAIN
    def flush()                          = out.flush()
    def debugln(obj: Any)                = err.println(obj)

    def readIntVector()    : Vector[Int]    = parseLineToVector(() => nextInt)
    def readLongVector()   : Vector[Long]   = parseLineToVector(() => nextLong)
    def readStringVector() : Vector[String] = parseLineToVector(() => nextString)
    def nextInt()          : Int            = nextLong().toInt
    def nextBigInt()       : BigInt         = BigInt(nextString())
    def nextBigDecimal(  ) : BigDecimal     = BigDecimal(nextString())
    def nextDouble()       : Double         = nextString().toDouble
    def nextLong() : Long = {
      if(!goNextValuable())
        throw new NoSuchElementException("Reading long failed")
      val sgn = if(peek == '-') -1l else 1
      if(sgn == -1l) read()
      if(peek < '0' || '9' < peek)
        throw new NumberFormatException(s"readLong found only '-' or no number")
      @tailrec
      def readLong(next: Int, cur: Long) : Long =
        if('0' <= next && next <= '9'){
          val _ = read() // is equal to next
          readLong(peek, cur*10 + next-'0')
        }
        else if(isEnd(next) || isSpaceOrControl(next))
          sgn*cur
        else
          throw new NumberFormatException(s"readLong found strange byte $next")
      val res = readLong(peek,0)
      skipTrailingSpaces()
      res
    }
    def nextString() : String = {
      if(!goNextValuable())
        throw new NoSuchElementException("Reading String failed")
      val builder = new StringBuilder
      @tailrec
      def appendCode(next: Int) : String = {
        if(isEnd(next) || isSpaceOrControl(next)){
          builder.toString
        }else{
          builder.append(read().toChar) // here we skip.
          appendCode(peek)
        }
      }
      val res = appendCode(peek)
      skipTrailingSpaces()
      res
    }
    // TODO: refactoring to marge nextString
    def readLine() : String = {
      if(isEnd(peek))
        throw new NoSuchElementException("Reading Line failed")
      skipNewline()
      val builder = new StringBuilder
      @tailrec
      def appendCode(next: Int) : String = {
        if(isEnd(next) || isNewLine(next)){
          builder.toString
        }else{
          builder.append(next.toChar)
          appendCode(read())
        }
      }
      appendCode(read())
    }
    // helpers
    private[this] var peeked: Option[Int] = None
    private[this] var is_first = true
    private def read() = {
      val res = peeked match {
        case None    => in.read()
        case Some(a) => { peeked = None; a }
      }
      is_first = false
      res
    }
    private def peek() =
      peeked match {
        case None    => {
          val res = in.read()
          peeked  = Some(res)
          res
        }
        case Some(a) => a
      }
    private def isEnd(c: Int)     = c == -1
    private def isCR(c: Int)      = c == 13
    private def isLF(c: Int)      = c == 10
    private def isNewLine(c: Int) = isLF(c) || isCR(c)
    private def isThereReadable() = !isEnd(peek)
    // XXX: this limits c is ASCII?
    private def isSpaceOrControl(c: Int) = (0 <= c && c <= 32) || c == 127
    @tailrec
    final private def goNextNotSpaceNorControl() : Unit =
      if(isSpaceOrControl(peek)){
        read()
        goNextNotSpaceNorControl()
      }
    final private def skipTrailingSpaces() : Unit = {
      @tailrec
      def skipTrailingSpacesAux() : Unit = {
        if(!isNewLine(peek) && isSpaceOrControl(peek)){
          read()
          skipTrailingSpacesAux()
        }
      }
      skipTrailingSpacesAux()
    }
    final private def skipNewline() : Unit = {
      if(is_first){
      }else if(isCR(peek)){
        read()
        if(isLF(peek)) read()
      }else if(isLF(peek)){
        read()
      }
    }
    private def goNextValuable() = {
      goNextNotSpaceNorControl()
      isThereReadable()
    }
    private def parseLineToVector[X](parser: () => X) : Vector[X] = {
      import scala.collection.immutable.VectorBuilder
      val vb = new VectorBuilder[X]()
      skipNewline()
      @tailrec
      def parseLineToVectorAux(first: Boolean=false) : Vector[X] =
        if(isNewLine(peek) || isEnd(peek)) {
          vb.result
        }else{
          vb += parser()
          parseLineToVectorAux()
        }
      parseLineToVectorAux(true)
    }
  }

  // Document: http://www.scala-lang.org/api/current/#package
  // -----------------------------------------------------------------------------
  class Solver(val stdio: MyConsole){
    import stdio._ // shadow Console.~
    case class R(c: HashMap[Long,Long], g: HashMap[Long,Long], r: Long)
    def main() : Unit = {
      val n,k = nextLong()
      val a = readLongVector()
      val l = a.foldLeft(R(HashMap[Long,Long](),HashMap[Long,Long](),0l))((r,i) => r match {
                                                                            case R(c,g,r) => {
                                                                              val new_r = r + g.getOrElse(i,0l)
                                                                              val new_c = c + (i->(c.getOrElse(i,0l)+1l))
                                                                              val new_g =
                                                                                if(i % k == 0 && (c contains i/k))
                                                                                g + (i*k->(g.getOrElse(i*k,0l)+c.get(i/k).get))
                                                                                else
                                                                                g
                                                                              R(new_c,new_g,new_r)
                                                                            }
                                                                          })
      println(l.r)
    }
  }

  def main(args: Array[String]) : Unit = {
    val console = new MyConsole(Console.in, Console.out, Console.err)
    val solver  = new Solver(console)
    solver.main()
    console.flush()
  }
}

// object Main {
//   import scala.collection.mutable.Map
//   case class R(c: Map[Long,Long], g: Map[Long,Long], r: Long)
//   // Document: http://www.scala-lang.org/api/current/#package
//   // -----------------------------------------------------------------------------
//   def main(args: Array[String]) : Unit = {
//     val (n,k) = {
//       val nk = readLine().split(" ").map(_.toLong)
//       (nk(0), nk(1))
//     }
//     val a = readLine().split(" ").map(_.toLong)
//     val l = a.foldLeft(R(Map[Long,Long](),Map[Long,Long](),0l))(
//         (r,i) => r match {
//           case R(c,g,r) => {
//             val new_r = r + g.getOrElse(i,0l)
//             val t = c.getOrElse(i,0l)+1l
//             val j = g.getOrElse(i*k,0l)+c.getOrElse(i/k,0l)
//             c += (i->t)
//             if(i % k == 0)
//               g += (i*k->j)
//             R(c,g,new_r)
//           }
//         })
//     println(l.r)
//   }
// }

import scala.annotation.tailrec
import scala.io.StdIn.readLine

// case class R(c: Map[Long,Long], g: Map[Long,Long], r: Long)
// object Main {
//   // Document: http://www.scala-lang.org/api/current/#package
//   // -----------------------------------------------------------------------------
//   def main(args: Array[String]) : Unit = {
//     val (n,k) = {
//       val nk = readLine().split(" ").map(_.toLong)
//       (nk(0), nk(1))
//     }
//     val a = readLine().split(" ").map(_.toLong)
//     val l = a.foldLeft(R(Map[Long,Long](),Map[Long,Long](),0l))((r,i) => r match {
//                                                    case R(c,g,r) => {
//                                                      val new_r = r + g.getOrElse(i,0l)
//                                                      val new_c = c + (i->(c.getOrElse(i,0l)+1l))
//                                                      val new_g =
//                                                        if(i % k == 0)
//                                                          g + (i*k->(g.getOrElse(i*k,0l)+c.getOrElse(i/k,0l)))
//                                                        else
//                                                          g
//                                                      R(new_c,new_g,new_r)
//                                                    }
//                                                  })
//     println(l.r)
//   }
// }

object Main {
  import scala.collection.mutable.Map
  case class R(c: Map[Long,Long], g: Map[Long,Long], r: Long)
  // Document: http://www.scala-lang.org/api/current/#package
  // -----------------------------------------------------------------------------
  def main(args: Array[String]) : Unit = {
    val (n,k) = {
      val nk = readLine().split(" ").map(_.toLong)
      (nk(0), nk(1))
    }
    val a = readLine().split(" ").map(_.toLong)
    var r = 0l
    val c = Map[Long,Long]()
    val g = Map[Long,Long]()
    for(i <- a){
      val new_r = r + g.getOrElse(i,0l)
      val t = c.getOrElse(i,0l)+1l
      val j = g.getOrElse(i*k,0l)+c.getOrElse(i/k,0l)
      c += (i->t)
      if(i % k == 0)
        g += (i*k->j)
      r = new_r
    }
    println(r)
  }
}

import scala.io.StdIn._

object CF567C extends App {
  val Array(n, k) = readLine().split(" ").map(_.toLong)
  val a = readLine().split(" ").map(_.toLong)

  val square = k * k

  var result = 0
  val len = a.length - 1
  for (i <- 0 to len) {
    for (j <- (i + 1) to len) {
      for (m <- (j + 1) to len) {
        val a1 = a(i)
        val a2 = a(j)
        val a3 = a(m)
        if ((a1 == a2 / k) && (a1 == a3 / square)) {
          result += 1
        }
      }
    }
  }

  println(result)
}

import scala.annotation.tailrec
import scala.io.StdIn.readLine
import scala.collection.immutable.HashMap

// ----------------------------------------------------------------------------0
// ----------------------------------------------------------------------------0
object Main {
  import java.io.{BufferedReader, PrintWriter, PrintStream, PushbackReader}
  import scala.annotation.tailrec
  class MyConsole(val in: BufferedReader, val _out: PrintStream,
                  val err: PrintStream) {
    // PrintWriter do not flush automatically
    val out = new PrintWriter(_out,false)
    // If argument is null, there are ambiguous which function will be called
    def print(obj: Any)                  = out.print(if(obj == null) "null" else obj.toString)
    def println()                        = out.println()
    def println(obj: Any)                = out.println(obj)
    def printf(text: String, args: Any*) = out.printf(text.format(args : _*))
    // NOTE: YOU MUST FLUSH BEFORE END OF MAIN
    def flush()                          = out.flush()
    def debugln(obj: Any)                = err.println(obj)

    def readIntVector()    : Vector[Int]    = parseLineToVector(() => nextInt)
    def readLongVector()   : Vector[Long]   = parseLineToVector(() => nextLong)
    def readStringVector() : Vector[String] = parseLineToVector(() => nextString)
    def nextInt()          : Int            = nextLong().toInt
    def nextBigInt()       : BigInt         = BigInt(nextString())
    def nextBigDecimal(  ) : BigDecimal     = BigDecimal(nextString())
    def nextDouble()       : Double         = nextString().toDouble
    def nextLong() : Long = {
      if(!goNextValuable())
        throw new NoSuchElementException("Reading long failed")
      val sgn = if(peek == '-') -1l else 1
      if(sgn == -1l) read()
      if(peek < '0' || '9' < peek)
        throw new NumberFormatException(s"readLong found only '-' or no number")
      @tailrec
      def readLong(next: Int, cur: Long) : Long =
        if('0' <= next && next <= '9')
          readLong(readWithoutCheckingPeeked(), cur*10 + next-'0')
        else if(isEnd(next) || isSpaceOrControl(next))
          sgn*cur
        else
          throw new NumberFormatException(s"readLong found strange byte $next")
      val res = readLong(read(),0)
      skipTrailingSpaces()
      res
    }
    def nextString() : String = {
      if(!goNextValuable())
        throw new NoSuchElementException("Reading String failed")
      val builder = new StringBuilder
      @tailrec
      def appendCode(next: Int) : String = {
        if(isEnd(next) || isSpaceOrControl(next)){
          builder.toString
        }else{
          builder.append(next.toChar)
          appendCode(readWithoutCheckingPeeked())
        }
      }
      val res = appendCode(read())
      skipTrailingSpaces()
      res
    }
    // TODO: refactoring to marge nextString
    def readLine() : String = {
      if(isEnd(peek))
        throw new NoSuchElementException("Reading Line failed")
      val builder = new StringBuilder
      @tailrec
      def appendCode(next: Int) : String = {
        if(isEnd(next) || isNewLine(next)){
          builder.toString
        }else{
          builder.append(next.toChar)
          appendCode(read())
        }
      }
      appendCode(read())
    }
    // helpers
    private[this] var peeked: Option[Int] = None
    private[this] var last = -1
    private def read() = {
      val res = peeked match {
          case None    => in.read()
          case Some(a) => { peeked = None; a }
        }
      last = res
      res
    }
    @inline private def readWithoutCheckingPeeked() = {
      val res = in.read()
      last = res
      res
    }
    @inline private def peek() =
      peeked match {
        case None    => {
          val res = in.read()
          peeked  = Some(res)
          res
        }
        case Some(a) => a
      }
    @inline private def isEnd(c: Int)    = c == -1
    @inline private def isNewLine(c: Int) = c == 10 || c == 13     // LF and CR
    @inline private def isThereReadable() = !isEnd(peek)
    // XXX: this limits c is ASCII?
    @inline private def isSpaceOrControl(c: Int) = (0 <= c && c <= 32) || c == 127
    @tailrec
    final private def goNextNotSpaceNorControl() : Unit =
      if(isSpaceOrControl(peek)){
        read()
        goNextNotSpaceNorControl()
      }
    final private def skipTrailingSpaces() : Unit = {
      @tailrec
      def skipTrailingSpacesAux() : Unit = {
        if(!isNewLine(last) && !isNewLine(peek) && isSpaceOrControl(peek)){
          read()
          skipTrailingSpacesAux()
        }
      }
      skipTrailingSpacesAux
      if(!isNewLine(last) && isNewLine(peek)) read()
    }
    @tailrec
    final private def skipTrailingSpacesAndNewline() : Unit =
      if(isNewLine(peek)){
        val _ = read() // windows causes error. maybe.
      }else if(isSpaceOrControl(peek)){
        read()
        skipTrailingSpacesAndNewline()
      }
    @inline private def goNextValuable() = {
      goNextNotSpaceNorControl()
      isThereReadable()
    }
    @inline private def parseLineToVector[X](parser: () => X) : Vector[X] = {
      import scala.collection.immutable.VectorBuilder
      val vb = new VectorBuilder[X]()
      @tailrec
      def parseLineToVectorAux(first: Boolean=false) : Vector[X] =
        if((!first && isNewLine(last)) || isNewLine(peek) || isEnd(peek)) {
          vb.result
        }else{
          vb += parser()
          parseLineToVectorAux()
        }
      parseLineToVectorAux(true)
    }
  }

  // Document: http://www.scala-lang.org/api/current/#package
  // -----------------------------------------------------------------------------
  class Solver(val stdio: MyConsole){
    import stdio._ // shadow Console.~
    case class R(c: HashMap[Long,Long], g: HashMap[Long,Long], r: Long)
    def main() : Unit = {
      val n,k = nextLong()
      val a = readLongVector()
      val l = a.foldLeft(R(HashMap[Long,Long](),HashMap[Long,Long](),0l))((r,i) => r match {
                                                                            case R(c,g,r) => {
                                                                              val new_r = r + g.getOrElse(i,0l)
                                                                              val new_c = c + (i->(c.getOrElse(i,0l)+1l))
                                                                              val new_g =
                                                                                if(i % k == 0)
                                                                                g + (i*k->(g.getOrElse(i*k,0l)+c.getOrElse(i/k,0l)))
                                                                                else
                                                                                g
                                                                              R(new_c,new_g,new_r)
                                                                            }
                                                                          })
      println(l.r)
    }
  }

  def main(args: Array[String]) : Unit = {
    val console = new MyConsole(Console.in, Console.out, Console.err)
    val solver  = new Solver(console)
    solver.main()
    console.flush()
  }
}

// object Main {
//   import scala.collection.mutable.Map
//   case class R(c: Map[Long,Long], g: Map[Long,Long], r: Long)
//   // Document: http://www.scala-lang.org/api/current/#package
//   // -----------------------------------------------------------------------------
//   def main(args: Array[String]) : Unit = {
//     val (n,k) = {
//       val nk = readLine().split(" ").map(_.toLong)
//       (nk(0), nk(1))
//     }
//     val a = readLine().split(" ").map(_.toLong)
//     val l = a.foldLeft(R(Map[Long,Long](),Map[Long,Long](),0l))(
//         (r,i) => r match {
//           case R(c,g,r) => {
//             val new_r = r + g.getOrElse(i,0l)
//             val t = c.getOrElse(i,0l)+1l
//             val j = g.getOrElse(i*k,0l)+c.getOrElse(i/k,0l)
//             c += (i->t)
//             if(i % k == 0)
//               g += (i*k->j)
//             R(c,g,new_r)
//           }
//         })
//     println(l.r)
//   }
// }

import java.io._
import java.util._

import scala.collection.mutable

object C {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

  def nextInt: Int = return Integer.parseInt(next)

  def nextLong: Long = return java.lang.Long.parseLong(next)

  def nextDouble: Double = return java.lang.Double.parseDouble(next)

  class MultiHashSet[T <% Comparable[T]] {
    val map = new mutable.HashMap[T, Int]()

    def count(x: T): Int = {
      return map.getOrElse(x, 0)
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }

    def removeAll(x: T) = {
      map.remove(x)
    }
  }

  class MultiTreeSet[T <% Comparable[T]] {
    val map = new TreeMap[T, Int]()

    def count(x: T): Int = {
      val res = map.get(x)
      if (res == null)
        return 0
      return res
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def first(): T = return map.firstKey()

    def last(): T = return map.lastKey()

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  /**
   * Segment tree for any commutative function
   * @param values Array of Int
   * @param commutative function like min, max, sum
   * @param zero zero value - e.g. 0 for sum, Inf for min, max
   */
  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {
    private val SIZE = 1e5.toInt
    private val n = values.length
    val t = new Array[Int](2 * n)
    Array.copy(values, 0, t, n, n)

    // build segment tree
    def build = {
      for (i <- n - 1 until 0 by -1) {
        t(i) = commutative(t(2 * i), t(2 * i + 1))
      }
    }

    // change value at position p to x
    // TODO beatify
    def modify(p: Int, x: Int) = {
      var pos = p + n
      t(pos) = x
      while (pos > 1) {
        t(pos / 2) = commutative(t(pos), t(pos ^ 1))
        pos /= 2
      }
    }

    // TODO implement me!
    def modify(p: Int, left: Int, right: Int) = ???

    def query(p: Int) = ???

    // sum [l, r)
    // min l = 0
    // max r = n
    // TODO beatify
    def query(left: Int, right: Int): Int = {
      var res = zero
      var r = right + n
      var l = left + n
      while (l < r) {
        if (l % 2 == 1) {
          res = commutative(res, t(l))
          l += 1
        }
        if (r % 2 == 1) {
          r -= 1
          res = commutative(res, t(r))
        }
        l /= 2
        r /= 2
      }
      res
    }
  }

  def solve: Int = {
    val n = nextInt
    val k = nextInt
    val a = new Array[Int](n)
    var ans = 0L
    val left = new MultiHashSet[Int]
    val right = new MultiHashSet[Int]
    for (i <- 0 until n) {
      a(i) = nextInt
      right.add(a(i))
    }
    for (i <- 0 until n) {
      right.remove(a(i))
      if (a(i) % k == 0)
        ans += 1L * left.count(a(i) / k) * right.count(a(i) * k)
      left.add(a(i))
    }
    out.println(ans)
    return 0
  }
}

import java.io._
import java.util._

import scala.collection.mutable

object C {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

  def nextInt: Int = return Integer.parseInt(next)

  def nextLong: Long = return java.lang.Long.parseLong(next)

  def nextDouble: Double = return java.lang.Double.parseDouble(next)

  class MultiHashSet[T <% Comparable[T]] {
    val map = new mutable.HashMap[T, Int]()

    def count(x: T): Int = {
      return map.getOrElse(x, 0)
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }

    def removeAll(x: T) = {
      map.remove(x)
    }
  }

  class MultiTreeSet[T <% Comparable[T]] {
    val map = new TreeMap[T, Int]()

    def count(x: T): Int = {
      val res = map.get(x)
      if (res == null)
        return 0
      return res
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def first(): T = return map.firstKey()

    def last(): T = return map.lastKey()

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  /**
   * Segment tree for any commutative function
   * @param values Array of Int
   * @param commutative function like min, max, sum
   * @param zero zero value - e.g. 0 for sum, Inf for min, max
   */
  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {
    private val SIZE = 1e5.toInt
    private val n = values.length
    val t = new Array[Int](2 * n)
    Array.copy(values, 0, t, n, n)

    // build segment tree
    def build = {
      for (i <- n - 1 until 0 by -1) {
        t(i) = commutative(t(2 * i), t(2 * i + 1))
      }
    }

    // change value at position p to x
    // TODO beatify
    def modify(p: Int, x: Int) = {
      var pos = p + n
      t(pos) = x
      while (pos > 1) {
        t(pos / 2) = commutative(t(pos), t(pos ^ 1))
        pos /= 2
      }
    }

    // TODO implement me!
    def modify(p: Int, left: Int, right: Int) = ???

    def query(p: Int) = ???

    // sum [l, r)
    // min l = 0
    // max r = n
    // TODO beatify
    def query(left: Int, right: Int): Int = {
      var res = zero
      var r = right + n
      var l = left + n
      while (l < r) {
        if (l % 2 == 1) {
          res = commutative(res, t(l))
          l += 1
        }
        if (r % 2 == 1) {
          r -= 1
          res = commutative(res, t(r))
        }
        l /= 2
        r /= 2
      }
      res
    }
  }

  def solve: Int = {
    val n = nextInt
    val k = nextInt
    val a = new Array[Int](n)
    var ans = 0L
    val left = new MultiHashSet[Int]
    val right = new MultiHashSet[Int]
    for (i <- 0 until n) {
      a(i) = nextInt
      right.add(a(i))
    }
    for (i <- 0 until n) {
      right.remove(a(i))
      if (a(i) % k == 0)
        ans += left.count(a(i) / k) * right.count(a(i) * k)
      left.add(a(i))
    }
    out.println(ans)
    return 0
  }
}

import io.StdIn._
import scala.collection.mutable._

object Solution {

  def main(args: Array[String]) {
    val line = readLine().split(" ").map(_.toInt)
    val (n, k) = (line(0), line(1))
    val seq = readLine().split(" ").map(_.toInt)
    val l = Map[Int, Int]().withDefaultValue(0)
    val r = Map[Int, Int]().withDefaultValue(0)
    var res = 0

    for (i <- seq.tail) { r(i) += 1 }
    l(seq.head) = 1
    for (i <- seq.tail) {
      r(i) = Math.max(0, r(i) - 1)
      if (i % k == 0 && i * k.toLong < 1000000007) {
          res += l(i/k) * r(i*k)
      }
      l(i) += 1
    }

    println(res)

  }

}

import io.StdIn._
import scala.collection.mutable._

object Solution {

  def main(args: Array[String]) {
    val line = readLine().split(" ").map(_.toInt)
    val (n, k) = (line(0), line(1))
    val seq = readLine().split(" ").map(_.toInt)
    val l = Map[Int, Int]().withDefaultValue(0)
    val r = Map[Int, Int]().withDefaultValue(0)
    var res = 0L

    for (i <- seq.tail) { r(i) += 1 }
    l(seq.head) = 1
    for (i <- seq.tail) {
      r(i) = Math.max(0, r(i) - 1)
      if (i % k == 0 && i * k.toLong < 1000000007) {
          res += l(i/k) * r(i*k).toLong
      }
      l(i) += 1
    }

    println(res)

  }

}


object Main extends App{
  val n = readInt()
  for (i <- 0 until n){
    val arr = readLine().split(" ").map(_.toInt)
    var x = 0
    for (j <- arr){
      if (j > 0) x = x | j
    }
    print (x)
    print (if(i == n-1) "\n" else " ")
  }
}

import scala.collection.mutable._

object Main extends App {
  val sc = new java.util.Scanner(System.in)

  val n = sc.nextInt()

  val m = Array.tabulate(n, n)((_, _) => sc.nextInt())

  val ans = (0 until n) map { i =>
    (0 until n) map (j => if (i != j) (m(i)(j) | m(j)(i)) else 0) reduce (_ | _)
  }

  println(ans.mkString("\n"))
}


object Solution {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn
    val t = StdIn.readLine().toInt
    for (_ <- 0 until t){
      val input = StdIn.readLine.trim.split(" ").map(_.toInt)
      val (n, m, x, y) = (input(0), input(1), input(2), input(3))
      val board = Array.fill(n)("")
      var b1, b2 = 0
      for (row <- 0 until n) {
        board(row) = StdIn.readLine
        val (bc1, bc2) = board(row).split("\\*").foldLeft((0,0))((acc, str) => {
          (acc._1 + str.length % 2, acc._2 + str.length / 2)
        })
        b1 += bc1
        b2 += bc2
      }
      val res = (b1+b2*2)*x min (b1*x+b2*y)
      println(res)
    }
  }
}

//package codeforces.contests._1359

object _2 {

  def main(args: Array[String]): Unit = {
    for (_ <- 1 to io.StdIn.readInt) {
      val Array(n, _, t1, t2) = io.StdIn.readLine.split(" ").map(_.toInt)

      val ans = (1 to n).foldLeft(0) { (acc, _) =>

        val chars = io.StdIn.readLine.toList

        @scala.annotation.tailrec
        def loop(input: List[Char], result: Int = 0): Int = {
          if (input.isEmpty) result
          else {
            val (dots, tail) = input.span(_ == '.')

            val size = dots.length

            val current = if (t1 * 2 <= t2) size * t1 else (size / 2) * t2 + (if ((size & 1) == 1) t1 else 0)

            loop(tail.dropWhile(_ == '*'), result + current)
          }

        }

        acc + loop(chars)
      }

      println {
        ans
      }
    }
  }
}

object B extends App {
  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val Array(n, m, x, y) = scala.io.StdIn.readLine().split(" ").map(_.toInt)
    val z                 = y min (2 * x)

    val ans = (0 until n).foldLeft(0) { (sum, _) =>
      val am = scala.io.StdIn.readLine().split("").map(c => if (c == ".") 1 else 0)

      val (s, t) = am.foldLeft((sum, 0)) {
        case ((s, l), r) =>
          if (l == 0) (s, r)
          else if (l == r) (s + z, 0)
          else (s + x, 0)
      }

      s + t * x
    }

    println(ans)

  }
}

object B extends App {
  val t = scala.io.StdIn.readInt()

  (0 until t).foreach { _ =>
    val Array(n, m, x, y) = scala.io.StdIn.readLine().split(" ").map(_.toInt)
    val z                 = y min (2 * x)

    val ans = (0 until n).foldLeft(0) { (sum, _) =>
      val am = scala.io.StdIn.readLine().split("").map(c => if (c == ".") 1 else 0)

      var a = 0
      val r = am.reduce { (l, r) =>
        if (l == 0) r
        else if (l == r) { a += z; 0 }
        else { a += x; 0 }
      }

      sum + a + r * x
    }

    println(ans)

  }
}

object ProblemB extends App {

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

  val in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)))
  val out = new PrintWriter(System.out)

  class FastScanner(val in: BufferedReader) {
    var st: StringTokenizer = _;

    def nextToken(): String = {
      while (st == null || !st.hasMoreTokens) {
        st = new StringTokenizer(in.readLine);
      }
      return st.nextToken();
    }

    def nextInt(): Integer = {
      Integer.parseInt(nextToken());
    }

    def nextLong(): Long = {
      nextToken().toLong;
    }

    def nextDouble(): Double = {
      nextToken().toDouble;
    }
  }

  val t = in.nextInt()
  for (_ <- 1 to t) {
    val n =  in.nextInt()
    val m = in.nextInt()
    val x = in.nextInt()
    val y = in.nextInt()

    var whiteCount = 0
    var res = 0

    def incRes(): Unit = {
      if (x * 2 <= y) {
        res = res + whiteCount * x
      } else {
        res = res + whiteCount / 2 * y + whiteCount % 2 * x
      }
      whiteCount = 0
    }

    for (i <- 0 until n) {
      val s = in.nextToken()
      s.foreach(c => if (c == '.') whiteCount = whiteCount + 1 else incRes())
      incRes()
    }

    println(res)

  }

}


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

    for (_ <- 1 to nextInt) {
      val n, m = nextInt
      val as = Array.fill(n)(nextInts(m))
      val sln = Array.fill(n, m)(4)
      for (i <- 1 to (m - 2)) {
        sln(0)(i) = 3
        sln(n - 1)(i) = 3
      }
      for (j <- 1 to (n - 2)) {
        sln(j)(0) = 3
        sln(j)(m - 1) = 3
      }
      sln(0)(0) = 2
      sln(0)(m - 1) = 2
      sln(n - 1)(0) = 2
      sln(n - 1)(m - 1) = 2

      var ok = true
      for (i <- 0 until n) {
        for (j <- 0 until m) {
          if (as(i)(j) > sln(i)(j)) ok = false
        }
      }

      if (ok) {
        out.println("YES")
        sln.foreach(row => out.println(row.mkString(" ")))
      } else {
        out.println("NO")
      }
    }

    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
  }
}

object B extends App {
  import scala.io.StdIn._

  val t = readInt()

  (0 until t).foreach { _ =>
    val Array(n, m) = readLine().split(" ").map(_.toInt)
    val base        = if (n == 1 || m == 1) 3 else 4

    var check = true
    val b = (0 until n).map { i =>
      val input = readLine().split(" ").map(_.toInt)

      val row = (0 until m).map(j => base - (if (i == 0 || i == n - 1) 1 else 0) - (if (j == 0 || j == m - 1) 1 else 0))

      check &&= input.zip(row).forall { case (x, y) => x <= y }

      row
    }

    if (check) {
      println("YES")
      println(b.map(_.mkString(" ")).mkString("\n"))
    } else println("NO")
  }
}


//package codeforces.contests._1363

object GameOnLeaves {

  def main(args: Array[String]): Unit = {
    for (_ <- 1 to io.StdIn.readInt) {

      val Array(n, x) = io.StdIn.readLine.split(" ").map(_.toInt)

      val degree: Array[Int] = {
        val a = new Array[Int](n + 1)
        (1 until n).foreach { _ =>
          val Array(x, y) = io.StdIn.readLine.split(" ").map(_.toInt)
          a(x) += 1
          a(y) += 1
        }
        a
      }
      val first = "Ayush"
      val second = "Ashish"

      println {
        if (degree(x) <= 1) first else {
          val maxMoves = n - 2

          if (maxMoves % 2 == 0) first else second
        }
      }
    }
  }

}

import scala.io.StdIn.readLine

object Solution {
  val mod: Int = Math.pow(10, 9).toInt + 7

  def main(args: Array[String]): Unit = {
    val t = readLine().toInt
    for (i <- 1 to t) {
      val nx = readIntLine()
      val n = nx.head
      val x = nx.last
      val xKids = (1 until n).count(_ => {
        val l = readIntLine()
        l.head == x || l.last == x
      })

      println(if (n == 1 || xKids == 1 || n % 2 == 0) "Ayush" else "Ashish")
    }
//          println(minNum(List[Boolean](false, false, true)))
  }

  def readIntLine(): List[Int] = {
    readLine().split(" ").map(_.toInt).toList
  }

  def readLongLine(): List[Long] = {
    readLine().split(" ").map(_.toLong).toList
  }

  def printArray[T](arr: Array[T]) {
    print(arr(0))
    for (i <- 1 until arr.length) {
      print(" " + arr(i))
    }
    println()
  }

}

import scala.io.StdIn.readLine

object Solution {
  val mod: Int = Math.pow(10, 9).toInt + 7

  def main(args: Array[String]): Unit = {
    val t = readLine().toInt
    for (i <- 1 to t) {
      val nx = readIntLine()
      val n = nx.head
      val x = nx.last
      val xKids = (1 until n).count(_ => {
        val l = readIntLine()
        l.head == x || l.last == x
      })

      println(if (xKids == 1 || n % 2 == 0) "Ayush" else "Ashish")
    }
//          println(minNum(List[Boolean](false, false, true)))
  }

  def readIntLine(): List[Int] = {
    readLine().split(" ").map(_.toInt).toList
  }

  def readLongLine(): List[Long] = {
    readLine().split(" ").map(_.toLong).toList
  }

  def printArray[T](arr: Array[T]) {
    print(arr(0))
    for (i <- 1 until arr.length) {
      print(" " + arr(i))
    }
    println()
  }

}

import scala.io.StdIn.readLine

object Solution {
  val mod: Int = Math.pow(10, 9).toInt + 7

  def main(args: Array[String]): Unit = {
    val t = readLine().toInt
    for (i <- 1 to t) {
      val nx = readIntLine()
      val xKids = (1 until nx.head).count(_ => {
        val l = readIntLine()
        l.head == nx.last || l.last == nx.last
      })

      println(if (xKids == 1 || nx.head - xKids % 2 == 0) "Ayush" else "Ashish")
    }
//          println(minNum(List[Boolean](false, false, true)))
  }

  def readIntLine(): List[Int] = {
    readLine().split(" ").map(_.toInt).toList
  }

  def readLongLine(): List[Long] = {
    readLine().split(" ").map(_.toLong).toList
  }

  def printArray[T](arr: Array[T]) {
    print(arr(0))
    for (i <- 1 until arr.length) {
      print(" " + arr(i))
    }
    println()
  }

}

import scala.io.StdIn.readLine

object Solution {
  val mod: Int = Math.pow(10, 9).toInt + 7

  def main(args: Array[String]): Unit = {
    val t = readLine().toInt
    for (i <- 1 to t) {
      val nx = readIntLine()
      val xKids = (1 until nx.head).count(_ => {
        val l = readIntLine()
        l.head == nx.last || l.last == nx.last
      })

      println(if (xKids == 1 || (nx.head - xKids) % 2 == 0) "Ayush" else "Ashish")
    }
//          println(minNum(List[Boolean](false, false, true)))
  }

  def readIntLine(): List[Int] = {
    readLine().split(" ").map(_.toInt).toList
  }

  def readLongLine(): List[Long] = {
    readLine().split(" ").map(_.toLong).toList
  }

  def printArray[T](arr: Array[T]) {
    print(arr(0))
    for (i <- 1 until arr.length) {
      print(" " + arr(i))
    }
    println()
  }

}

import scala.io.StdIn.readLine

object Solution {
  val mod: Int = Math.pow(10, 9).toInt + 7

  def main(args: Array[String]): Unit = {
    val t = readLine().toInt
    for (i <- 1 to t) {
      val nx = readIntLine()
      val n = nx.head
      val x = nx.last
      val xKids = (1 until n).count(_ => {
        val l = readIntLine()
        l.head == x || l.last == x
      })

      println(if (xKids == 1 || (n - xKids) % 2 == 0) "Ayush" else "Ashish")
    }
//          println(minNum(List[Boolean](false, false, true)))
  }

  def readIntLine(): List[Int] = {
    readLine().split(" ").map(_.toInt).toList
  }

  def readLongLine(): List[Long] = {
    readLine().split(" ").map(_.toLong).toList
  }

  def printArray[T](arr: Array[T]) {
    print(arr(0))
    for (i <- 1 until arr.length) {
      print(" " + arr(i))
    }
    println()
  }

}