use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        h: usize,
        w: usize,
        mut grid: [Chars; h]
    }

    let start = {
        let mut start = (0,0);
        for i in 0..h {
            for j in 0..w {
                if grid[i][j] == 's' {
                    start = (i,j);
                }
            }
        }
        start
    };

    let flag: bool = {
        let mut flag = false;
        let mut stack = vec![start];
        while let Some((y,x)) = stack.pop() {
            if grid[y][x] == 'g' {
                flag = true;
                break;
            } else {
                grid[y][x] = '#';
                for &dy in &[-1,1] {
                    let mut y = y as i32;
                    y += dy;
                    for &dx in &[-1,1] {
                        let mut x = x as i32;
                        x += dx;
                        if 0 <= y && y < (h as i32) && 0 <= x && x < (w as i32) {
                            if grid[y as usize][x as usize] == '.' {
                                stack.push((y as usize,x as usize));
                            }
                        }
                    }
                }
            }
        }
        flag
    };

    if flag {
        println!("Yes")
    } else {
        println!("No")
    }
}