HOGE = 2 ** 52
loop do
  n = gets.to_i
  break if n==0
  b = gets.chomp
  e = 0
  a = HOGE + b.to_i(2)
  m = a
  while n>0 and a!=0 do
    ct = (HOGE * 2 - 1 - m) / a
    ct = n if ct>n
    m += ct * a
    n -= ct
    break if n==0
    e += 1
    m = (m + a) / 2
    a /= 2
    n -= 1
  end
  puts e.to_s(2).rjust(12, ?0) + m.to_s(2)[1..52]
end
