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

object Main extends App {
  def genStr(s:String) = {
    def scan(prev:Char,cnt:Int,r:String,i:Int):String = {
      if(i==s.length) r+cnt.toString+prev
      else {
        val c = s(i)
        if(prev==c) scan(prev,cnt+1,r,i+1)
        else scan(c,1,r+cnt.toString+prev,i+1)
      }
    }
    scan(s(0),1,"",1)
  }
  Iterator.continually(readInt).takeWhile(_!=0).foreach { n =>
    println( (0 until n).foldLeft(readLine) {  (x,_) => genStr(x) } )
  }
}