def fun(a)
    l = a.size
    c = a[0]
    x = 0
    i = 0
    b = ""
    while i < l
        while a[i] == c
            x+=1
            i+=1
        end
        b += x.to_s+c
        c = a[i]
        x = 0
    end
    b
end

n = gets.to_i

while n!=0
  a = gets.chomp()
  n.times{a = fun(a)}
  puts a
  n = gets.to_i
end