#include using namespace std; using ll = long long; const int INF = 1e9 + 10; const ll INFL = 4e18; const vector dx = {1, 0, -1, 0}; const vector dy = {0, 1, 0, -1}; int main() { int H, W; cin >> H >> W; vector S(H); for (int i = 0; i < H; i++) cin >> S[i]; using P = pair; vector> dst(H, vector

(W, P(INF, INF))); priority_queue, vector>, greater>> pq; pq.push({P(0, 0), P(0, 0)}); while (!pq.empty()) { auto [horz, vert] = pq.top().first; auto [x, y] = pq.top().second; pq.pop(); if (dst[x][y] < P(horz, vert)) continue; for (int i = 0; i < 4; i++) { int nx = x + dx[i], ny = y + dy[i]; if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue; if (S[nx][ny] == '#') continue; int nvert = vert, nhorz = horz; if (x != nx) nvert++; if (y != ny) nhorz++; if (dst[nx][ny] > P(nhorz, nvert)) { dst[nx][ny] = P(nhorz, nvert); pq.push({P(nhorz, nvert), P(nx, ny)}); } } } if (dst.back().back() == P(INF, INF)) { cout << "No" << endl; } else { cout << "Yes" << endl; cout << dst.back().back().first << ' ' << dst.back().back().second << endl; } }