// Arup Guha
// 6/24/2012
// Solution to 2009 Southeast Regional Problem G: Pool

import java.util.*;

public class g {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		// Get all the data.
		int[] cue = new int[2];
		int[] target = new int[2];
		int L = stdin.nextInt();
		int W = stdin.nextInt();
		cue[0] = stdin.nextInt();
		cue[1] = stdin.nextInt();
		target[0] = stdin.nextInt();
		target[1] = stdin.nextInt();
		int N = stdin.nextInt();

		// Process each case.
		while (L != 0) {

			System.out.printf("%.3f\n",solve(L,W,cue,target,N));

			L = stdin.nextInt();
			W = stdin.nextInt();
			cue[0] = stdin.nextInt();
			cue[1] = stdin.nextInt();
			target[0] = stdin.nextInt();
			target[1] = stdin.nextInt();
			N = stdin.nextInt();
		}
	}

	// The key is that we are folding the original table N times left, right, up and
	// down. Each table represents where the target ball could go after hitting a
	// cushion a certain number of times.
	public static double solve(int L, int W, int[] cue, int[] target, int N) {

		// Create an array of target balls all at or before the distance to hit.
		pt[] allT = new pt[(2*N+1)*(2*N+1)];
		int s = 2*N+1;

		// First fill in the first row of targets.
		allT[s*N+N] = new pt(target[0], target[1], cue[0], cue[1], 0);

		for (int i=N+1; i<=2*N; i++) {
			int tempx, tempy;
			if ((i-N)%2 == 1)
				tempx = (i-N)*L + L - target[0];
			else
				tempx = (i-N)*L + target[0];
			tempy = target[1];
			allT[s*i+N] = new pt(tempx, tempy, cue[0], cue[1], i-N);
		}

		for (int i=N-1; i>=0; i--) {
			int tempx, tempy;
			if ((N-i)%2 == 1)
				tempx = (i-N)*L + L - target[0];
			else
				tempx = (i-N)*L + target[0];
			tempy = target[1];
			allT[i*s+N] = new pt(tempx, tempy, cue[0], cue[1], N-i);
		}

		// Now, run all columns.
		for (int i=0; i<=2*N; i++) {
			for (int j=N+1; j<=2*N; j++) {
				int tempx, tempy;
				tempx = allT[s*i+j-1].x;
				if ((j-N)%2 == 1)
					tempy = (j-N)*W + W - target[1];
				else
					tempy = (j-N)*W + target[1];
				allT[i*s+j] = new pt(tempx, tempy, cue[0], cue[1], (j-N) + Math.abs(N-i));
			}

			for (int j=N-1; j>=0; j--) {
				int tempx, tempy;
				tempx = allT[s*i+j+1].x;
				if ((N-j)%2 == 1)
					tempy = (j-N)*W + W - target[1];
				else
					tempy = (j-N)*W + target[1];
				allT[i*s+j] = new pt(tempx, tempy, cue[0], cue[1], (N-j) + Math.abs(N-i));
			}
		}

		// We sort these according to slope (by atan2), then distance, in terms of cushion bounces away.
		Arrays.sort(allT);

		// Look for the best.
		double bestD = 1000000000;
		for (int i=0; i<allT.length; i++) {

			// Not the right number of cushion bounces.
			if (allT[i].dist != N) continue;

			// If the ball before it is the same slope, then we will hit the target BEFORE N cushion bounces.
			if (i>0 && Math.abs(allT[i-1].slope() - allT[i].slope()) < 1e-10) continue;

			double tempD = allT[i].getD();

			// Update if this one's better.
			if (tempD < bestD)
				bestD = tempD;

		}

		return bestD;
	}
}

class pt implements Comparable<pt> {

	public int x;
	public int y;
	public int cuex;
	public int cuey;
	public int dist;

	// (myx, myy) is the target point, (cx, cy) the cue point, and d is the number of bounces
	// to get from the cue to the target.
	public pt(int myx, int myy, int cx, int cy, int d) {
		x = myx;
		y = myy;
		cuex = cx;
		cuey = cy;
		dist = d;
	}

	// This is key for our sort, using atan2.
	public Double slope() {
		return Math.atan2(y-cuey, x-cuex);
	}

	// How far to hit the target from the cue.
	public double getD() {
		return Math.sqrt(Math.pow(x-cuex, 2) + Math.pow(y-cuey, 2));
	}

	// This is how we sort.
	public int compareTo(pt other) {

		Double slope1 = this.slope();
		Double slope2 = other.slope();

		// Straight comparison based on atan2.
		if (Math.abs(slope1 - slope2) < 1e-10)
			return this.dist - other.dist;
		else if (slope1 < slope2)
			return -1;
		else
			return 1;

	}
}