import java.util.*;
import java.util.Arrays;
import java.math.BigInteger;
class Point{
int x1,y1,x2,y2,t;
Point(){
x1=x2=y1=y2=t=0;
}
}
class Pair{
int x,y;
Pair(){
x=y=0;
}
Pair(int x, int y)
{
this.x = x;
this.y = y;
}
}
public class Main {
static long ans = Integer.MAX_VALUE;
public static ArrayList arr = new ArrayList<>();
public static Point start_end = new Point();
static boolean[] visited = new boolean[51];
public static void getMin(long time , Pair begin , int n)
{
ans = Math.min(ans, time+Math.abs(begin.x-start_end.x2)+Math.abs(begin.y-start_end.y2));
for (int i = 0; i < n; i++) {
if(visited[i])
continue;
visited[i] = true;
Point temp = arr.get(i);
long dis = Math.abs(temp.x1-begin.x)+Math.abs(temp.y1-begin.y)+temp.t;
getMin(time + dis, new Pair(temp.x2,temp.y2), n);
dis = Math.abs(temp.x2-begin.x)+Math.abs(temp.y2-begin.y)+temp.t;
getMin(time + dis , new Pair(temp.x1,temp.x2),n);
visited[i] = false;
}
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
int index = 1;
// int count = 0;
while(t>0)
{
int n = sc.nextInt();
start_end.x1 = sc.nextInt();
start_end.y1 = sc.nextInt();
start_end.x2 = sc.nextInt();
start_end.y2 = sc.nextInt();
arr.clear();
for (int i = 0; i < n; i++) {
Point temp = new Point();
temp.x1 = sc.nextInt();
temp.y1 = sc.nextInt();
temp.x2 = sc.nextInt();
temp.y2 = sc.nextInt();
temp.t = sc.nextInt();
arr.add(temp);
}
if(n==0)
{
ans = Math.abs(start_end.x1-start_end.x2)+Math.abs(start_end.y2-start_end.y1);
System.out.println("#"+index+" : "+ans);
ans = Integer.MAX_VALUE;
}
else{
// count++;
Arrays.fill(visited,false);
ans = Integer.MAX_VALUE;
getMin(0, new Pair(start_end.x1,start_end.y1), n);
System.out.println("#"+index+" : "+ans);
}
index++;
t--;
}
}
}