import java.util.*;
import java.io.*;
public class steve {
	int R, C;
	int[][] world;
	final int[] dr = { 0, 0,-1, 1};
	final int[] dc = {-1, 1, 0, 0};
	final int AIR = 0;
	final int WOOD = 1;
	final int IRON = 2;
	final int SOLID = 3;

	//Flood fill to mark every space reachable if it is not solid (based on minSolid).
	void floodFill(int r, int c, int minSolid, boolean[][] reachable) {
		if (r<0 || c<0 || r>=R || c>=C || reachable[r][c] || world[r][c] >= minSolid)
			return;
		reachable[r][c] = true;
		for (int i=0; i<dr.length; i++)
			floodFill(r+dr[i],c+dc[i],minSolid,reachable);
	}

	//Run flood fill for all border spaces.
	boolean[][] zombieFill(int minSolid) {
		boolean[][] reachable = new boolean[R][C];
		for (int r=0; r<R; r++) {
			floodFill(r,0,minSolid,reachable);
			floodFill(r,C-1,minSolid,reachable);
		}
		for (int c=0; c<C; c++) {
			floodFill(0,c,minSolid,reachable);
			floodFill(R-1,c,minSolid,reachable);
		}
		return reachable;
	}

	steve(Scanner in) {
		int T = in.nextInt();
		for (int t=0; t<T; t++) {

			//Input
			R = in.nextInt();
			C = in.nextInt();
			world = new int[R][C];
			int steveR=-1, steveC=-1;
			for (int r=0; r<R; r++) {
				String line = in.next();
				for (int c=0; c<C; c++) {
					switch (line.charAt(c)) {
						case 'S':
							steveR = r;
							steveC = c;
						case '.':
							world[r][c] = AIR;
							break;
						case 'W':
							world[r][c] = WOOD;
							break;
						case 'I':
							world[r][c] = IRON;
							break;
						case '#':
							world[r][c] = SOLID;
							break;

					}
				}
			}

			//Use flood fill to calculate where hardcore zombies, normal zombies, and steve can reach from their positions.
			boolean[][] normalZombies = zombieFill(WOOD);
			boolean[][] hardcoreZombies = zombieFill(IRON);
			boolean[][] steve = new boolean[R][C];
			floodFill(steveR,steveC,SOLID,steve);

			//Look for spaces satisfying each possible condition, and save the best.
			int answer = 0; //0=no safe exists, 1=can't reach safe, 2=can reach safe from normal, 3=can reach safe from all
			for (int r=0; r<R; r++)
				for (int c=0; c<C; c++) {
					if (world[r][c] == SOLID)
						continue;
					if (!steve[r][c])
						answer = Math.max(answer,1); //A place exists that no one can reach.
					else if (!hardcoreZombies[r][c])
						answer = Math.max(answer,3); //There is a place no zombies can reach but steve can.
					else if (!normalZombies[r][c])
						answer = Math.max(answer,2); //There is a place only normal zombies can't reach.
				}

			//Output answer.
			System.out.printf("World #%d: ",t+1);
			switch(answer) {
				case 3:
					System.out.println("Sleep for the night, you are safe.");
					break;
				case 2:
					System.out.println("I hope you're not in hardcore.");
					break;
				case 1:
					System.out.println("I see you didn't think this one through. Good luck tonight.");
					break;
				case 0:
					System.out.println("It's been nice knowing you.");
					break;
			}

		}
	}

	public static void main(String[] args) throws Exception {
		new steve(new Scanner(new File("steve.in")));
	}
}
