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 Ruby (2.3.3) (judge verdict: Wrong Answer)

#!/usr/bin/env ruby

def overflow?(dp_i)
  [:U, :D, :L, :R].each do |sym|
    if dp_i[sym][:limit] - dp_i[sym][:S] + dp_i[sym][:T] < 0
      return true
    end
  end
  return false
end

if $0 == __FILE__
  H, W, N = gets.split(' ').map &:to_i
  sr, sc = gets.split(' ').map &:to_i
  S = gets.chomp.split('')
  T = gets.chomp.split('')

  u_limit = sr - 1
  d_limit = H - sr
  l_limit = sc - 1
  r_limit = W - sc

  # dp[i][L or R or D or U]: i番目までSが上下左右に全ブリした場合の残りカウントとTが逆ぶりできる猶予個数
  # dp[i] = {
  #   L: [残りカウント, 猶予],
  #   ...
  #   }
  dp = []

  (0...N).each do |i|
    dp[i] = {
      U: {
        limit: u_limit,
        S: i == 0 ? 0 : dp[i-1][:U][:S],
        T: i == 0 ? 0 : dp[i-1][:U][:T]
      },
      D: {
        limit: d_limit,
        S: i == 0 ? 0 : dp[i-1][:D][:S],
        T: i == 0 ? 0 : dp[i-1][:D][:T]
      },
      L: {
        limit: l_limit,
        S: i == 0 ? 0 : dp[i-1][:L][:S],
        T: i == 0 ? 0 : dp[i-1][:L][:T]
      },
      R: {
        limit: r_limit,
        S: i == 0 ? 0 : dp[i-1][:R][:S],
        T: i == 0 ? 0 : dp[i-1][:R][:T]
      }
    }

    case S[i]
    when 'U'
      dp[i][:U][:S] += 1
    when 'D'
      dp[i][:D][:S] += 1
    when 'L'
      dp[i][:L][:S] += 1
    when 'R'
      dp[i][:R][:S] += 1
    end

    if overflow?(dp[i])
      puts 'NO'
      exit
    end

    case T[i]
    when 'U'
      if u_limit - (dp[i][:D][:T]+1) - dp[i][:U][:S] >= 0
        dp[i][:D][:T] += 1
      end
    when 'D'
      if d_limit - (dp[i][:U][:T]+1) - dp[i][:D][:S] >= 0
        dp[i][:U][:T] += 1
      end
    when 'L'
      if l_limit - (dp[i][:R][:T]+1) - dp[i][:L][:S] >= 0
        dp[i][:R][:T] += 1
      end
    when 'R'
      if r_limit - (dp[i][:L][:T]+1) - dp[i][:R][:S] >= 0
        dp[i][:L][:T] += 1
      end
    end
  end

  puts 'YES'
end