until (n = gets.to_i) == 0
  puts n.times.reduce(gets.chomp) {|s|
    a = r = nil
    res = ''
    (s << 0).each_char {|c|
      if c == a
        r += 1
      else
        res << (r || '').to_s << (a || '')
        a = c
        r = 1
      end
    }
    res
  }
end