#include<bits/stdc++.h> using namespace std; const int N = 1005; int n,m; int sx,sy,tx,ty; char ch[N][N]; int dx[4] = {0,1,-1,0}; int dy[4] = {1,0,0,-1}; bool vis[N][N]; struct node{ int x; int y; int now; }; queue<node>q; inline bool check(int x,int y){ if(x<1 || x>n) return false...