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)*}
    };
}

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)*}
    };
}

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, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        let y = max!($($z),*);
        if $x > y {
            $x
        } else {
            y
        }
    }}
}
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        let y = min!($($z),*);
        if $x < y {
            $x
        } else {
            y
        }
    }}
}

#[derive(Debug)]
pub struct LRUDGame {
    H: usize,
    W: usize,
    N: usize,
    Sr: usize,
    Sc: usize,
    S: Vec<char>,
    T: Vec<char>,
}

impl LRUDGame {
    pub fn new(param: (usize, usize, usize, usize, usize, Vec<char>, Vec<char>)) -> LRUDGame {
        LRUDGame {
            H: param.0,
            W: param.1,
            N: param.2,
            Sr: param.3,
            Sc: param.4,
            S: param.5,
            T: param.6,
        }
    }

    fn solve(&mut self) -> usize {
        let mut lbound = 0;
        let mut rbound = self.W as i32 - 1;
        let mut ubound = 0;
        let mut dbound = self.H as i32 - 1;
        
        if self.S[self.N-1] == 'U' { ubound += 1; }
        if self.S[self.N-1] == 'D' { dbound -= 1; }
        for i in (0..self.N-1).rev() {
            if self.T[i] == 'U' { dbound = min!(dbound+1, (self.H-1) as i32); }
            if self.T[i] == 'D' { ubound = max!(ubound-1, 0); }
            if self.S[i] == 'U' { ubound += 1; }
            if self.S[i] == 'D' { dbound -= 1; }
            if dbound < ubound { return 0; }
        }
        if (self.Sr as i32) < ubound || dbound < self.Sr as i32 { return 0; }

        if self.S[self.N-1] == 'L' { lbound += 1; }
        if self.S[self.N-1] == 'R' { rbound -= 1; }
        for i in (0..self.N-1).rev() {
            if self.T[i] == 'L' { rbound = min!(rbound+1, (self.W-1) as i32); }
            if self.T[i] == 'R' { lbound = max!(lbound-1, 0); }
            if self.S[i] == 'L' { lbound += 1; }
            if self.S[i] == 'R' { rbound -= 1; }
            if rbound < lbound { return 0; }
        }
        if (self.Sc as i32) < lbound || rbound < self.Sc as i32 { return 0; }

        return 1;
    }
}
fn main() {
    input! {
        H: usize,
        W: usize,
        N: usize,
        Sr: usize,
        Sc: usize,
        S: String,
        T: String,
    };

    let S:Vec<char> = S.chars().collect();
    let T:Vec<char> = T.chars().collect();
    let mut lrudgame = LRUDGame::new((H, W, N, Sr-1, Sc-1, S, T));
    println!("{}", if lrudgame.solve() == 0 { "NO" } else { "YES" });
}


Measured memory_bytes: 6396