#include<bits/stdc++.h>
#define UP(i,x,y) for(int i=x; i<=y; i++)
#define N 200
using namespace std;
struct Node{
int a=0;
int b=0;
int step=0;
int begin; /* 表示从哪个出发的 0:从起点出发; 1:从终点出发的 */
};
int R,C;
char myMap[N][N];
int dir[5][5];
int book[N][N]={
0};
int from[N][N]; /* from[x][y]表示:上次到xy这个点在队列myqueue的什么位置 */
Node myQueue[N*N];
int head=0,tail=2;
/*
从a,b出发走到 ea,eb的最短步数
*/
int bfs(int a, int b, int ea