![]
using namespace std; const int maxn=10005; int vis[maxn][maxn]; int dir[2][2]={1,0,0,1};
struct node{
int x,y;
int step;
};
int bfs(int sx,int sy,int ex,int ey,int n,int m){
memset(vis,0,sizeof(vis));
queue<node> q;
struct node init;
init.x=sx;
init.y=sy;
init.step=0;
q.push(init);
vis[sx][sy]=1;
int ans=-1;
while(!q.empty()){
node now=q.front();
q.pop();
if(now.x==ex&&now.y==ey){ ans=now.step; return ans; }
for(int i=0;i<2;++i){
int nx=now.x+dir[i][0];
int ny=now.y+dir[i][1];
if(vis[nx][ny]==0&&(nx<=n&&ny<=m)){
struct node temp;
temp.x=nx;
temp.y=ny;
temp.step=now.step+1;
q.push(temp);
vis[nx][ny]=1; }
}
}
return ans;
}
main(){
int t,n,m;
int x1,y1,x2,y2;
cin>>t;
while(t--){
cin>>n>>m;
cin>>x1>>y1>>x2>>y2;
int ans=bfs(x1,y1,x2,y2,n,m);
if(ans==-1)cout<<"Single dog!"<<endl;
else cout<<ans<<endl;
}
}