//Michael Calvo
//7/21/08
//Purpose: Takes in ladder length and target heigh and checks if you can reach it.

import java.io.*;
import java.lang.*;
import java.util.*;

public class ladders{
	public static void main (String[] args) throws Exception{
	
		int numLadders;
		double height;
		double target;
		double base;
		
		Scanner fin = new Scanner(new FileReader("ladders.in"));
		
		numLadders = fin.nextInt();
		
		for(int i = 0; i < numLadders; i++){
			
			//Take in values
			height = fin.nextInt();
			target = fin.nextInt();
			
			//Make sure they're positive
			height = Math.abs(height);
			target = Math.abs(target);
			
			//Begin calculations
			height = Math.pow(height, 2);
			target = Math.pow(target, 2);
			base = height - target;
			
			//Print header.
			System.out.print("Ladder "+(i+1)+": ");
			
			//If the number's valid, return the value.
			if(base > 0){
				base = Math.sqrt(base);
				System.out.println("Ladder should be placed "+base+" feet from the wall.");
			}
			
			else
				System.out.println("Ladder isn't long enough.");
			
		}
		
		//Close input file
		fin.close();
	}
}