def func str
    a = str[0]
    b = str[1..24]
    c = str[25..31]
    sign = (-1) ** (a.to_i)
    sum1, k = 0, 1
    b.reverse.each_char{|x|
        sum1 += k if x == '1'
        k *= 2
    }
    sum2, k = 0.0, 0.5
    c.each_char{|x|
        sum2 += k if x == '1'
        k /= 2
    }
    sign * (sum1 + sum2)
end

q = gets.to_i
q.times{
    puts func(sprintf("%032b", gets.chomp.to_i(16)))
}
