// Arup Guha
// Solution to 2011 NY Regional Problem C: Programming the EDSAC
// 10/22/2012

import java.util.*;
import java.math.*;

public class c {
	
	public static void main(String[] args) {
		
		Scanner stdin = new Scanner(System.in);
		
		int numCases = stdin.nextInt();

		// Go through each case.		
		for (int loop=1; loop<=numCases; loop++) {
			
			int dummy = stdin.nextInt();
			String a = stdin.next();
			BigDecimal val = new BigDecimal(a);
			
			BigDecimal negOne = BigDecimal.ONE;
			negOne = negOne.negate();
			
			// Filter valid values.
			if (val.compareTo(BigDecimal.ONE) < 0 && val.compareTo(negOne) >= 0) {
			
				// Convert our number to an integer over 2^16.
				int output = convert(val);
			
				// Separate out the three parts.
				int bit = output & 1;
				int middle = (output >> 1) & 0x000007ff;
				int end = (output >> 12);
			
				System.out.print(loop+" ");
			
				// Print out part one and two.
				String s = "PQWERTYUIOJ#SZK*?F@D!HNM&LXGABCV";
				System.out.print(s.charAt(end)+" "+middle+" ");
			
				// Last part.
				if (bit == 1)
					System.out.println("D");
				else
					System.out.println("F");
			}
			
			// Invalid output case.
			else {
				System.out.println(loop+" INVALID VALUE");
			}
		}
	}
	
	// Converts to the appropriate unsigned int value from 0 to 2^17 - 1.
	public static int convert(BigDecimal val) {
		
		// Do conversion for positive values.
		int base = (1 << 16);
		int addVal = 2*base;
		BigInteger b = new BigInteger(""+base);
		BigDecimal num = new BigDecimal(b);
		val = val.multiply(num);
		
		// Correctly does trunction for both positive and negative values.
		int convert = val.intValue();
		
		// Offset for negative values.
		if (convert < 0) 
			convert = convert + (1 << 17);

		return convert;
	}	
}