Problem:
Score : 600 points

Problem Statement

We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left.
On this grid, there is a piece, which is initially placed at square (s_r,s_c).

Takahashi and Aoki will play a game, where each player has a string of length N.
Takahashi's string is S, and Aoki's string is T. S and T both consist of four kinds of letters: L, R, U and D.

The game consists of N steps. The i-th step proceeds as follows:

First, Takahashi performs a move. He either moves the piece in the direction of S_i, or does not move the piece.

Second, Aoki performs a move. He either moves the piece in the direction of T_i, or does not move the piece.

Here, to move the piece in the direction of L, R, U and D, is to move the piece from square (r,c) to square (r,c-1), (r,c+1), (r-1,c) and (r+1,c), respectively. If the destination square does not exist, the piece is removed from the grid, and the game ends, even if less than N steps are done.

Takahashi wants to remove the piece from the grid in one of the N steps.
Aoki, on the other hand, wants to finish the N steps with the piece remaining on the grid.
Determine if the piece will remain on the grid at the end of the game when both players play optimally.

Constraints

2 \leq H,W \leq 2 \times 10^5

2 \leq N \leq 2 \times 10^5

1 \leq s_r \leq H

1 \leq s_c \leq W

|S|=|T|=N

S and T consists of the four kinds of letters L, R, U and D.

Input

Input is given from Standard Input in the following format:

H W N
s_r s_c
S
T

Output

If the piece will remain on the grid at the end of the game, print YES; otherwise, print NO.

Sample Input 1

2 3 3
2 2
RRL
LUD

Sample Output 1

YES

Here is one possible progress of the game:

Takahashi moves the piece right. The piece is now at (2,3).

Aoki moves the piece left. The piece is now at (2,2).

Takahashi does not move the piece. The piece remains at (2,2).

Aoki moves the piece up. The piece is now at (1,2).

Takahashi moves the piece left. The piece is now at (1,1).

Aoki does not move the piece. The piece remains at (1,1).

Sample Input 2

4 3 5
2 2
UDRRR
LLDUD

Sample Output 2

NO

Sample Input 3

5 6 11
2 1
RLDRRUDDLRL
URRDRLLDLRD

Sample Output 3

NO

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Runtime Error)

package solver;

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;

public class Main {
    
    int H, W, n;
    int x, y;
    String s, t;
    
    boolean okByLR(){
        int lft = 0, rgt = 0;
        for(int i = 0; i < n; i++){
            if(s.charAt(i) == 'L'){
                rgt--;
            } else {
                lft++;
            }
            // --
            if(t.charAt(i) == 'L'){
                lft--;
            } else {
                rgt++;
            }
            //---
            if(lft < 0 && (y + lft < 1)){
                return false;
            }
            if(rgt > 0 && (y + rgt > W)){
                return false;
            }
        }
        return true;
    }
    
    boolean okByUD(){
        int up = 0, down = 0;
        for(int i = 0; i < n; i++){
            if(s.charAt(i) == 'U'){
                down--;
            } else {
                up++;
            }
            //---
            if(t.charAt(i) == 'U'){
                up--;
            } else {
                down++;
            }
            //--
            if(up < 0 && (x - up < 1)){
                return false;
            }
            if(down > 0 && (x + down > H)){
                return false;
            }
        }
        return true;
    }
    
    void run() throws IOException {
        Reader in = new Reader();
        H = in.nextInt();
        W = in.nextInt();
        n = in.nextInt();
        x = in.nextInt();
        y = in.nextInt();
        s = in.readLine();
        t = in.readLine();
        
        if(okByUD() == false || okByLR() == false){
            System.out.println("NO");
        } else {
            System.out.println("YES");
        }
    }
    
    public static void main(String[] args) throws IOException {
        new Main().run();
    }
    
    static class Reader {
        final private int bufferSize = 1 << 16;
        final private DataInputStream din;
        final private byte[] buffer;
        private int bufferPointer, bytesRead;
        
        public Reader(){
            din = new DataInputStream(System.in);
            buffer = new byte[bufferSize];
            bufferPointer = bytesRead = 0;
        }
        
        public Reader(String fileName) throws IOException {
            din = new DataInputStream(new FileInputStream(fileName));
            buffer = new byte[bufferSize];
            bufferPointer = bytesRead = 0;
        }
        
        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, bufferSize);
            if(bytesRead == -1){
                buffer[0] = -1;
            }
        }
        
        private byte read() throws IOException {
            if(bufferPointer == bytesRead){
                fillBuffer();
            }
            return buffer[bufferPointer++];
        }
        
        private void close() throws IOException {
            if(din == null){
                return ;
            }
            din.close();
        }
        
        public String readLine() throws IOException {
            byte[] buf = new byte[200005];
            int cnt = 0, c;
            while((c = read()) != -1){
                if(c == '\n'){
                    break;
                }
                buf[cnt++] = (byte)c;
            }
            return new String(buf, 0, cnt);
        }
        
        public int nextInt() throws IOException { 
            int ret = 0; 
            byte c = read(); 
            while (c <= ' ') c = read(); 
            boolean neg = (c == '-'); 
            if (neg) 
                c = read();
            do{ 
                ret = ret * 10 + c - '0'; 
            } while ((c = read()) >= '0' && c <= '9'); 
            if (neg) 
                return -ret; 
            return ret; 
        }
        
        public long nextLong() throws IOException { 
            long ret = 0; 
            byte c = read(); 
            while (c <= ' ') c = read(); 
            boolean neg = (c == '-'); 
            if (neg) 
                c = read(); 
            do { 
                ret = ret * 10 + c - '0'; 
            } while ((c = read()) >= '0' && c <= '9'); 
            if (neg) 
                return -ret; 
            return ret; 
        }
        
        public double nextDouble() throws IOException { 
            double ret = 0, div = 1; 
            byte c = read(); 
            while (c <= ' ') c = read(); 
            boolean neg = (c == '-'); 
            if (neg) 
                c = read(); 
            do { 
                ret = ret * 10 + c - '0'; 
            } 
            while ((c = read()) >= '0' && c <= '9'); 
            if (c == '.'){
                while ((c = read()) >= '0' && c <= '9'){ 
                    ret += (c - '0') / (div *= 10); 
                } 
            }
            if (neg) 
                return -ret; 
            return ret; 
        } 
    }
}