// Arup Guha
// 8/1/2013
// Solution to 2011 UCF Locals Problem(s): Gold and Black Knight

import java.util.*;

public class knight {

	public static long n;
	public static long r1;
	public static long c1;
	public static long r2;
	public static long c2;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Go through cases.
		for (int loop=1; loop<=numCases; loop++) {

			// Get input.
			n = stdin.nextLong();
			r1 = stdin.nextLong()-1;
			c1 = stdin.nextLong()-1;
			r2 = stdin.nextLong()-1;
			c2 = stdin.nextLong()-1;

			// Reflect case, so we go from bottom right to top left.
			// This problem is equivalent.
			if (r1 > r2) {
				r1 = n-1-r1;
				r2 = n-1-r2;
			}
			if (c1 > c2) {
				c1 = n-1-c1;
				c2 = n-1-c2;
			}

			// Reflect across y = x.
			if (r2 - r1 > c2 - c1) {
				long tmp = r1;
				r1 = c1;
				c1 = tmp;
				tmp = r2;
				r2 = c2;
				c2 = tmp;
			}

			// Print the solution.
			System.out.println("Case #"+loop+": "+solve());
			System.out.println();
		}
	}

	public static long solve() {

		long dx = r2-r1;
		long dy = c2-c1;
		long sum = dx+dy;

		ArrayList<pair> targets = new ArrayList<pair>();
		targets.add(new pair(r1,c1));

		// Close so just do a bfs.
		if (sum < 100)
			return bfs(targets);

		// Long rectangle.
		if (dy >= 2*dx) {

			// We basically take 2 hops at a time moving up 4 columns. Our row can be any even numbered
			// offset that we desire, since it's a long rectangle. I add in two rows of squares to our
			// possible targets.
			long doublehops = dy/4-1;
			long newc = 4*doublehops + c1;
			for (long newr=r2-dx%2; newr>=0 && newr>=r2-10; newr-=2)
				targets.add(new pair(newr, newc));
			for (long newr=r2-1+dx%2; newr>=0 && newr>=r2-10; newr-=2)
				targets.add(new pair(newr, newc-1));

			return doublehops*2 + bfs(targets);
		}
		else {

			long doublehops = (dx+dy)/6 - 1;
			long totalSteps = 6*doublehops;

			// Here our strategy is that we can move 6 spots in 2 moves anywhere with slope >= 1 and <= 2.
			// So I come within 6 spots of the target and add all of these points that clip the rectangle.
			for (int i=0;; i++) {
				long newc = c2 - i;
				long newr = r1 + (totalSteps - (dy-i));
				targets.add(new pair(newr, newc));
				if (newr >= r2) break;
			}

			return doublehops*2 + bfs(targets);
		}
	}

	// Returns the minimum distance from (r2, c2) to any item listed in targets.
	public static long bfs(ArrayList<pair> targets) {

		HashMap<String,Long> map = new HashMap<String,Long>();
		LinkedList<pair> q = new LinkedList<pair>();

		// Set up BFS.
		pair start = new pair(r2,c2);
		q.offer(start);
		map.put(start.toString(), 0L);

		// Defines the knight hops.
		int[] kdx = {-2,-2,-1,-1, 1, 1,  2, 2};
		int[] kdy = {-1, 1,-2, 2,-2, 2, -1, 1};

		// We'll return later.
		while (true) {

			// Get the next item.
			pair next = q.poll();

			// See if we're done!
			if (in(next, targets))
				return map.get(next.toString());

			// Try adding each neighbor.
			for (int i=0; i<kdx.length; i++) {

				pair newpair = new pair(next.r+kdx[i], next.c+kdy[i]);

				// Only add if we've never been here before AND it's inbounds.
				if (newpair.inbounds(n) && !map.containsKey(newpair.toString())) {
					q.offer(newpair);
					map.put(newpair.toString(), map.get(next.toString())+1);
				}
			}
		}
	}

	// Returns true iff p is in items.
	public static boolean in(pair p, ArrayList<pair> items) {
		for (int i=0; i<items.size(); i++)
			if (p.equals(items.get(i)))
				return true;
		return false;
	}
}

class pair {

	public long r;
	public long c;

	public pair(long a, long b) {
		r = a;
		c = b;
	}

	public boolean equals(pair other) {
		return r == other.r && c == other.c;
	}

	public boolean inbounds(long size) {
		return r >= 0 && c >= 0 && r < size && c < size;
	}

	public String toString() {
		return ""+r+","+c;
	}
}