import java.io.*;
import java.util.*;

class escape
{
	private static byte P[][][] = new byte[2][51][51];
	private static char M[][] = new char[51][51];

	private static BufferedReader in = new BufferedReader(new InputStreamReader( System.in ) );
	
	
	private static void skipWhitespace(BufferedReader r) throws IOException
	{
		int v;
		do
		{
			r.mark(8);
			v = r.read();
			if(v == -1) return;
		} while(Character.isWhitespace((char)v));
		r.reset();
	}
	
	private static char getChar(BufferedReader r) throws IOException
	{
		skipWhitespace(in);
		return (char) r.read();
	}
	
	public static void main(String[] args) throws Exception
	{
		skipWhitespace(in);
		int N = Integer.parseInt(in.readLine());
		
scenarios:
		for(int scenario = 0; scenario != N; ++scenario)
		{
			System.out.println("Scenario #" + (scenario+1) + ":");
			int R,C;
			int sr=0, sc=0;
			int tr=0, tc=0;
			skipWhitespace(in);
			String[] RC = in.readLine().split("\\s");
			R = Integer.parseInt(RC[0]);
			C = Integer.parseInt(RC[1]);
			byte[][] Pbefore = P[0];
			byte[][] Pcurrent = P[1];
			for(int i=0; i!=R; ++i)
			{
				for(int j=0; j!=C; ++j)
				{
					M[i][j] = getChar(in);
					Pbefore[i][j] = 0;
					if(M[i][j] == 'U')
					{
						sr = i;
						sc = j;
						M[i][j] = '#';
						Pbefore[i][j] = 15;
					}
					else if(M[i][j] == 'X')
					{
						tr = i;
						tc = j;
						M[i][j] = '+';
					}
				}
			}
			int s,d;
			skipWhitespace(in);
			String[] sd = in.readLine().split("\\s");
			s = Integer.parseInt(sd[0]);
			d = Integer.parseInt(sd[1]);
			for(int t=1; t<d+s; ++t)
			{
				for(int i=0; i!=R; ++i)
				{
					for(int j=0; j!=C; ++j)
					{
						Pcurrent[i][j] = 0;
						if(M[i][j] != '+') continue;
						for(int dir = 1; dir <= 8; dir <<= 1)
						{
							switch(dir)
							{
								case 1:
									if(i == 0) break;
									Pcurrent[i][j] |= ((Pbefore[i-1][j] & (15 ^ 4)) != 0) ? dir : 0;
									break;
								case 2:
									if(j+1 == C) break;
									Pcurrent[i][j] |= ((Pbefore[i][j+1] & (15 ^ 8)) != 0) ? dir : 0;
									break;
								case 4:
									if(i+1 == R) break;
									Pcurrent[i][j] |= ((Pbefore[i+1][j] & (15 ^ 1)) != 0) ? dir : 0;
									break;
								case 8:
									if(j == 0) break;
									Pcurrent[i][j] |= ((Pbefore[i][j-1] & (15 ^ 2)) != 0) ? dir : 0;
									break;
							}
						}
					}
				}
				if((t >= s) && (Pcurrent[tr][tc] != 0))
				{
					System.out.println(t + "\n");
					continue scenarios;
				}
				byte[][] tmp = Pbefore;
				Pbefore = Pcurrent;
				Pcurrent = tmp;
			}
			System.out.println("Impossible\n");
		}
	}
}
