#include using namespace std; typedef pair P; int H, W; char S[3100][3100]; int dist[3100][3100]; void bfs() { queue

q; for (int i=0; i> H >> W; for (int i=0; i> Si; for (int j=0; j