## main

n = gets.strip.to_i

n.times do
  bits = sprintf("%032b", gets.strip.to_i(16))
  #p bits

  s = (bits[0] == '1' ? '-' : '')
  i = bits[1, 24].to_i(2)
  f = bits[25, 7].to_i(2).to_f / 128
  puts "#{s}#{i + f}"
end