#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        a: usize1,
        b: usize1,
        c: usize1,
        d: usize1,
        s: chars
    }
    //b->d
    let mut prev_rock = false;
    let mut goal = true;
    if c<d {
        for i in b..d {
            if prev_rock && s[i]=='#' {
                goal = false;
            }
            if s[i] == '#' {
                prev_rock = true;
            }else{
                prev_rock = false;
            }
        }
        prev_rock = false;
        for i in a..c {
            if prev_rock && s[i]=='#' {
                goal = false;
            }
            if s[i] == '#' {
                prev_rock = true;
            }else{
                prev_rock = false;
            }
        }
    }else{
        // any double rock?
        for i in b..d {
            if prev_rock && s[i]=='#' {
                goal = false;
            }
            if s[i] == '#' {
                prev_rock = true;
            }else{
                prev_rock = false;
            }
        }
        prev_rock = false;
        for i in a..c {
            if prev_rock && s[i]=='#' {
                goal = false;
            }
            if s[i] == '#' {
                prev_rock = true;
            }else{
                prev_rock = false;
            }
        }
        // ab conflict
        let mut top = false;
        let mut nor = false;
        if s[b-1]=='.' && s[b]=='.' && s[b+1]=='.' {
            top = true;
        }
        for i in b..d {
            if s[i]=='.' && s[i+1]=='.' && s[i+2]=='.' {
                nor = true;
            }
        }
        if nor==false {
            if top==true {
                // A,B initial state
            }else{
                goal = false;
            }
        }
    }
    if goal {
        println!("Yes");
    }else{
        println!("No");
    }
}

Measured memory_bytes: 4352