#include <cstdio> 
#include <string>
#include <cstring>
#include <cstdlib>
#include <map>
#include <iostream>
using namespace std;

map<string,string> ans1;
map<string,string> ans2;

char code[100] = "PQWERTYUIOJ#SZK*?F@D!HNM&LXGABCV";

string gao(int k) {
	int fd = k & 0x1;
	int oprand = (k >> 1) & 0x7ff;
	int opcode = (k >> 12) & 0x1f;
	char str[100];
	sprintf(str, "%c %d %c", code[opcode], oprand, fd?'D':'F');
	string ret = str;
	return ret;
}

string fraction(int k) {
	int it; float f;
	it = ((k >> 16) & 0x1) << 31;
	it += (k&0xFFFF) << 7;
	it += 127 << 23;
//	cout << it << endl;
	memcpy(&f, &it, sizeof(int));
//	cout << f << endl;
	if ((k >> 16) & 0x1) f = -(1+(f+1)); else f -= 1;

	char str[100];
	sprintf(str, "%.17lf", f);
	//cout << k << ' ' << str << endl;
	string ret = "";
	int i;
	for (i = strlen(str)-1; i >= 0; --i) {
		if (str[i] != '0') break;
	}
	for (int j = 0; j <= i; ++j) ret += str[j];
	return ret;
}

#include <cstring>

char sin[10000];

int main() {
	ans1.clear(); ans2.clear();
	float f;
	for (int k = 0; k < (1 << 17); ++k) {
		string s1 = gao(k);
		string s2 = fraction(k);
		//cout << k << ' ' << s1 << ' ' << s2 << endl;
		if (k == 0) s2 = "0.0", f = 0;
		if (k == (1<<16)) s2 = "-1.0", f = -1;
		ans1.insert(make_pair(s1, s2));
		ans2.insert(make_pair(s2, s1));
	}
	int ts, ti;
	scanf("%d", &ts);
	while (ts--) {
		scanf("%d", &ti);
		printf("%d ", ti);
		long double dou;
		float dd; int ii;
		scanf("%Lf", &dou);
//		printf("input%.17Lf\n",dou);
		if (dou < -1.0 || dou >=1.0) {
			printf("INVALID VALUE\n");continue;
		}
		/*
		dd = dou;
		printf("input = %.17f\n", dd);
		if (dou > 0) dd = dou + 1; else dd = dou-1;
		memcpy(&ii,&dd,sizeof(int));
		//if ((ii>>6) & 0x1) ii += (1<<7);
		printf("%x\n", ii);
		ii = (ii >> 7) << 7;
		memcpy(&dd,&ii,sizeof(int));
		if (dd > 0) dd = dd - 1; else dd = dd + 1;
		sprintf(sin,"%.17f",dd);
		printf("%x\n", ii);
		*/

		double z = 0;
		double add = 0.0000152587890625;
		if (dou > 0) {
			while (z+add <= dou) z += add;
		}
		else {
			while (z - add >= dou) z -= add;
		}
		sprintf(sin,"%.17lf",z);

		//scanf("%s", sin);
		int slen = strlen(sin);
		while (sin[slen-1]=='0') {
			sin[--slen]=0;
		}
		if (sin[slen-1] == '.') sin[slen++] = '0';
		string str = sin;
		//cout << '*' << str << '*' << endl;
		

		map<string,string>::iterator it = ans2.find(str);
		if (it != ans2.end())
			cout << it->second << endl;
		else cout << "INVALID VALUE" << endl;
	}
	return 0;
}

