package adv;
import java.util.ArrayDeque;
import java.util.Scanner;
/**
* Poj3984迷宫问题
* BFS+路径还原
* 一般用于走迷宫/求最短路径,
*/
public class POJ3984 {
static int T,n,m,ans;
static int startx,starty,endx,endy;
static int[][] map;
static boolean[][] flag;
static int[][] dir = {
{0,-1},{0,1},{-1,0},{1,0}};//标记四个方向
static Node[][] path;//标记路径
static ArrayDeque<Node> list = new ArrayDeque<Node>();//添加路径
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
T = sc.nextInt();
for(int test_case=1;test_case<=T;test_case++) {
n = sc.nextInt();
m = sc.nextInt();
startx = sc.nextInt();
starty = sc.nextInt();
endx = sc.nextInt();
endy = sc.nextInt();
map = new int[n][m];
flag = new boolean[n][m];//默认标识全部为false
path = new Node[n][m];
for(int i=0;i<n;i++) {
for(int j=0;j<m;j&