#include using namespace std; int main () { int H, W; cin >> H >> W; char A[555][555]; for (int i = 0; i <= H + 1; i ++) { for (int j = 0; j <= W + 1; j ++) { if (0 < i && i <= H && 0 < j && j <= W) { cin >> A[i][j]; } else { A[i][j] = '#'; } } } using P = pair; P D[555][555]; for (auto& a : D) { for (auto& [p, q] : a) { q = p = 1e9 + 7; } } using PP = tuple; priority_queue, greater> pque; D[1][1] = P{0, 0}; pque.emplace(D[1][1], 1, 1); while (!pque.empty()) { auto [l, ui, uj] = pque.top(); pque.pop(); for (int d = -1; d < 2; d += 2) { int vi = ui + d; P l2 = l; l2.second ++; if (A[vi][uj] == '.' && D[vi][uj] > l2) { D[vi][uj] = l2; pque.emplace(l2, vi, uj); } l2.second --; l2.first ++; int vj = uj + d; if (A[ui][vj] == '.' && D[ui][vj] > l2) { D[ui][vj] = l2; pque.emplace(l2, ui, vj); } } } auto& [p, q] = D[H][W]; if (p > H * W * 2) { puts("No"); } else { cout << "Yes\n" << p << " " << q << endl; } }