// Arup Guha
// 2/23/2012
// Solution to 2011 Mercer Problem 6: Crazy Rectangular Sea
import java.util.*;

public class prob6 {
	
	public static void main(String[] args) {
		
		Scanner stdin = new Scanner(System.in);
		
		// Go through all cases.
		int numCases = stdin.nextInt();
		for (int loop = 0; loop<numCases; loop++) {
			
			int N = stdin.nextInt();
			int M = stdin.nextInt();
			int startX = stdin.nextInt();
			int startY = stdin.nextInt();
			int destX = stdin.nextInt();
			int destY = stdin.nextInt();
			int numSteps = stdin.nextInt();
			
			// Set up DP: prob[i][j][k] = prob of being in (i,j) in k steps.
			double[][][] prob = new double[N][M][numSteps+1];
			
			// Initialize.
			for (int i=0; i<N; i++)
				for (int j=0; j<M; j++)
					for (int k=0; k<numSteps+1; k++)
						prob[i][j][k] = 0;
						
			// This is where we start.
			prob[startX][startY][0] = 1;
			
			// We're here!
			if (startX == destX && startY == destY) {
				System.out.printf("%.6f\n",1.0);
			}
			
			// Solve regular cases.
			else {
				
				double ans = 0;
				
				// Just simulate.
				for (int step=0; step<numSteps; step++) {
					
					for (int i=0; i<N; i++) {
						for (int j=0; j<M; j++) {
							
							// Update for this step.
							
							// See how many places we can go from here.
							int numchoices = getChoice(i,j,N,M);
							
							// Update each probability accordingly.
							if (i > 0) {
								prob[i-1][j][step+1] += (1.0/numchoices*prob[i][j][step]);
							}
							if (i < N-1) {
								prob[i+1][j][step+1] += (1.0/numchoices*prob[i][j][step]);
							}
							if (j > 0) {
								prob[i][j-1][step+1] += (1.0/numchoices*prob[i][j][step]);
							}
							if (j < M-1) {
								prob[i][j+1][step+1] += (1.0/numchoices*prob[i][j][step]);
							}					
							
							
						}
					}
					
					// Finished update for this round, add into total prob.
					ans += prob[destX][destY][step+1];
					
					// Need to zero this out; it's like removing the people from the spot
					// who arrive here at step, since we don't want to recount them if the
					// come back later in the simulation.
					prob[destX][destY][step+1] = 0;
				}
				
				System.out.printf("%.6f\n", ans+1e-10);
				
			}
		}
	}
	
	// Returns the number of places we can move.
	public static int getChoice(int x, int y, int len, int wid) {
		
		// Grid is big enough to assume it has four corners.
		if (len >=2 && wid >=2) {
			int score=0;
			if (x == 0 || x == len-1) score++;
			if (y == 0 || y == wid-1) score++;
			return 4 - score;
		}
		
		// Special case to handle len == 1.
		else if (len == 1) {
			int score = 0;
			if (y ==0 || y == wid-1) score++;
			return 2-score;
		}
		
		// Special case to handle wid == 1.
		else {
			int score = 0;
			if (x ==0 || x == len-1) score++;
			return 2-score;				
		}
			
		
	}
}