#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

char buf[100];
int main() {
	int q; cin >> q;
	rep(i, q) {
		ll s; scanf("%llx", &s);
		string t = bitset<32>(s).to_string();
		string a = t.substr(1, 24);
		int b = 0, p = 1;
		for (int i = a.size() - 1; i >= 0; i--) {
			b += p*(a[i] - '0'); p *= 2;
		}
		double d = 0, y = 0.5;
		string c = t.substr(25);
		rep(i, c.size()) {
			d += y*(c[i] - '0'); y /= 2;
		}
		double ans = b + d;
		if (t.front() == '1')ans = -ans;
		sprintf(buf, "%.10lf", ans);
		string u = buf;
		while (u.back() == '0')u.pop_back();
		if (u.back() == '.')u.pop_back();
		if ((int)u.find('.') == -1)u += ".0";
		cout << u << endl;
	}
}