You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 ≤ H, W, N ≤ 2 × 10^5, 1 ≤ s_r ≤ H, 1 ≤ s_c ≤ W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output "YES" if the piece remains on the grid at the end of the game; otherwise, output "NO".

# Buggy version:
import functools
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
import random
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


H, W, N = read_values()
YP, XP = tuple(read_index())
S = input().strip()
T = input().strip()


def main():
    X = [-1, W]
    Y = [-1, H]
    for t, s in zip(T[::-1], S[::-1]):
        if t == "L":
            X[1] = min(W, X[1] + 1)
        elif t == "R":
            X[0] = max(-1, X[0] - 1)
        elif t == "D":
            Y[1] = min(H, Y[1] + 1)
        elif t == "U":
            Y[0] = max(-1, Y[0] - 1)

        if s == "L":
            X[0] += 1
        elif s == "R":
            X[1] -= 1
        elif s == "D":
            Y[0] += 1
        elif s == "U":
            Y[1] -= 1

        # if X[0] + 1 >= X[1] or Y[0] + 1 >= Y[1]:
        #     print("NO")
        #     return

    if X[0] < XP < X[1] and Y[0] < YP < Y[1]:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()



# Fixed version:
import functools
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
import random
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


H, W, N = read_values()
YP, XP = read_index()
S = input().strip()
T = input().strip()


def main():
    X = [0, W]
    Y = [0, H]
    for t, s in zip(T[::-1], S[::-1]):
        if t == "L":
            X[1] = min(W, X[1] + 1)
        elif t == "R":
            X[0] = max(0, X[0] - 1)
        elif t == "U":
            Y[1] = min(H, Y[1] + 1)
        elif t == "D":
            Y[0] = max(0, Y[0] - 1)

        if s == "L":
            X[0] += 1
        elif s == "R":
            X[1] -= 1
        elif s == "U":
            Y[0] += 1
        elif s == "D":
            Y[1] -= 1

        if X[0] >= X[1] or Y[0] >= Y[1]:
            print("NO")
            return

    if X[0] <= XP < X[1] and Y[0] <= YP < Y[1]:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()

# Buggy version:
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===

def main():
    h, w, n = ns()
    y, x = ns()
    s = list(input())
    t = list(input())

    su, sd, sl, sr = 0, 0, 0, 0
    tu, td, tl, tr = 0, 0, 0, 0

    yes = True

    for si, ti in zip(s, t):
        if si == "U":
            su += 1
        elif si == "D":
            sd += 1
        elif si == "L":
            sl += 1
        else:
            sr += 1

        if y - (su - td) < 1:
            yes = False
        if y + sd - tu > h:
            yes = False
        if x - (sl - tr) < 1:
            yes = False
        if x + sr - tl > w:
            yes = False

        if ti == "U":
            tu += 1
        elif ti == "D":
            td += 1
        elif ti == "L":
            tl += 1
        else:
            tr += 1

    print("YES" if yes else "NO")


if __name__ == '__main__':
    main()


# Fixed version:
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===

def main():
    h, w, n = ns()
    y, x = ns()
    s = list(input())
    t = list(input())

    su, sd, sl, sr = 0, 0, 0, 0
    tu, td, tl, tr = 0, 0, 0, 0

    yes = True

    for si, ti in zip(s, t):
        if si == "U":
            su += 1
        elif si == "D":
            sd += 1
        elif si == "L":
            sl += 1
        else:
            sr += 1

        if y - (su - td) < 1:
            yes = False
        if y + sd - tu > h:
            yes = False
        if x - (sl - tr) < 1:
            yes = False
        if x + sr - tl > w:
            yes = False

        if ti == "U":
            tu = min(tu + 1, y - 1 + sd)
        elif ti == "D":
            td = min(td + 1, h - y + su)
        elif ti == "L":
            tl = min(tl + 1, x - 1 + sr)
        else:
            tr = min(tr + 1, w - x + sl)

    print("YES" if yes else "NO")


if __name__ == '__main__':
    main()

# Buggy version:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W, N = map(int, input().split())
    sr, sc = map(int, input().split())
    S = input()[::-1]
    T = input()[::-1]

    left, right = 1, W
    up, bottom = 1, H
    for s, t in zip(S, T):
        if t == "R":
            left -= 1
            left = max(1, left)
        elif t == "L":
            right += 1
            right = min(W, right)
        elif t == "U":
            up -= 1
            up = max(1, up)
        elif t == "D":
            bottom += 1
            bottom = min(H, bottom)

        if s == "R":
            right -= 1
            right = max(1, right)
        elif s == "L":
            left += 1
            left = min(H, left)
        elif s == "U":
            bottom -= 1
            bottom = max(1, bottom)
        elif s == "D":
            up += 1
            up = min(H, up)

        if left > right or up > bottom:
            print("NO")
            exit()

    print("YES" if left <= sc <= right and up <= sr <= bottom else "NO")


if __name__ == '__main__':
    resolve()


# Fixed version:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W, N = map(int, input().split())
    sr, sc = map(int, input().split())
    sr = H + 1 - sr
    S = input()[::-1]
    T = input()[::-1]

    left, right = 1, W
    bottom, up = 1, H
    for s, t in zip(S, T):
        if t == "R":
            left -= 1
            left = max(1, left)
        elif t == "L":
            right += 1
            right = min(W, right)
        elif t == "U":
            bottom -= 1
            bottom = max(1, bottom)
        elif t == "D":
            up += 1
            up = min(H, up)

        if s == "R":
            right -= 1
        elif s == "L":
            left += 1
        elif s == "U":
            up -= 1
        elif s == "D":
            bottom += 1

        if left > right or bottom > up:
            print("NO")
            exit()

    print("YES" if left <= sc <= right and bottom <= sr <= up else "NO")


if __name__ == '__main__':
    resolve()

# Buggy version:
import sys
input = sys.stdin.readline

H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input().rstrip()
T = input().rstrip()

l, r = 1, W
if S[-1] == 'L':
    l += 1
if S[-1] == 'R':
    r -= 1
for i in range(N-1)[::-1]:
    if T[i] == 'L':
        r += 1
    if T[i] == 'R':
        l -= 1

    if S[i] == 'L':
        l += 1
    if S[i] == 'R':
        r -= 1

    if l > r:
        print('NO')
        exit()

u, d = 1, H
if S[-1] == 'U':
    u += 1
if S[-1] == 'D':
    d -= 1
for i in range(N-1)[::-1]:
    if T[i] == 'U':
        d += 1
    if T[i] == 'D':
        u -= 1

    if S[i] == 'U':
        u += 1
    if S[i] == 'D':
        d -= 1

    if u > d:
        print('NO')
        exit()

if l <= sc <= r and u <= sr <= d:
    print('YES')
else:
    print('NO')

# Fixed version:
import sys
input = sys.stdin.readline

H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input().rstrip()
T = input().rstrip()

l, r = 1, W
if S[-1] == 'L':
    l += 1
if S[-1] == 'R':
    r -= 1
for i in range(N-1)[::-1]:
    if T[i] == 'L':
        r = min(r+1, W)
    if T[i] == 'R':
        l = max(l-1, 1)

    if S[i] == 'L':
        l += 1
    if S[i] == 'R':
        r -= 1
        
    if l > r:
        print('NO')
        exit()

u, d = 1, H
if S[-1] == 'U':
    u += 1
if S[-1] == 'D':
    d -= 1
for i in range(N-1)[::-1]:
    if T[i] == 'U':
        d = min(d+1, H)
    if T[i] == 'D':
        u = max(u-1, 1)

    if S[i] == 'U':
        u += 1
    if S[i] == 'D':
        d -= 1

    if u > d:
        print('NO')
        exit()

if l <= sc <= r and u <= sr <= d:
    print('YES')
else:
    print('NO')

# Buggy version:
h, w, n = map(int, input().split())
sy, sx = map(int, input().split())
l, r = 1, w
d, u = 1, h
for a, b in zip(input()[::-1], input()[::-1]):
	r = min(r + (b == "L"), w) - (a == "R")
	l = max(l - (b == "R"), 1) + (a == "L")
	u = min(u + (b == "D"), h) - (a == "U")
	d = max(d - (b == "U"), 1) + (a == "D")
print("YES" if l <= sx <= r and d <= h - sy - 1 <= u else "NO")

# Fixed version:
h, w, n = map(int, input().split())
sy, sx = map(int, input().split())
l, r = 1, w
d, u = 1, h
for a, b in zip(input()[::-1], input()[::-1]):
	r = min(r + (b == "L"), w) - (a == "R")
	l = max(l - (b == "R"), 1) + (a == "L")
	u = min(u + (b == "D"), h) - (a == "U")
	d = max(d - (b == "U"), 1) + (a == "D")
	if l > r or d > u:break
print("YES" if l <= sx <= r and d <= h - sy + 1 <= u else "NO")

# Buggy version:
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()
B = [1, W, 1, H]
for i in range(N - 1, -1, -1):
  if T[i] == 'L': B[1] = min(B[1] + 1, W)
  if T[i] == 'R': B[0] = max(B[0] - 1, 1)
  if T[i] == 'U': B[3] = min(B[3] + 1, H)
  if T[i] == 'D': B[2] = max(B[2] - 1, 1)
  if S[i] == 'L': B[0] += 1
  if S[i] == 'R': B[1] -= 1
  if S[i] == 'U': B[2] += 1
  if S[i] == 'D': B[3] -= 1
  if B[1] < B[0] or B[3] < B[2]:
    print('NO')
    break
else:
  print('YES' if B[0] <= sc <= B[1] and B[3] <= sr <= B[2] else 'NO')

# Fixed version:
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()
B = [1, W, 1, H]
for i in range(N - 1, -1, -1):
  if T[i] == 'L': B[1] = min(B[1] + 1, W)
  if T[i] == 'R': B[0] = max(B[0] - 1, 1)
  if T[i] == 'U': B[3] = min(B[3] + 1, H)
  if T[i] == 'D': B[2] = max(B[2] - 1, 1)
  if S[i] == 'L': B[0] += 1
  if S[i] == 'R': B[1] -= 1
  if S[i] == 'U': B[2] += 1
  if S[i] == 'D': B[3] -= 1
  if B[1] < B[0] or B[3] < B[2]:
    print('NO')
    break
else:
  print('YES' if B[0] <= sc <= B[1] and B[2] <= sr <= B[3] else 'NO')

# Buggy version:
h,w,n = map(int,input().split())
sr,sc = map(int,input().split())
t = input()
s = input()
hei = [1,h]
wid = [1,w]
for i in range(n-1,-1,-1):
  if s[i] == "L":
    wid[1] = min(wid[1]+1,w)
  elif s[i] == "R":
    wid[0] = max(wid[0]-1,0)
  elif s[i] == "U":
    hei[1] = min(hei[1]+1,h)
  elif s[i] == "D":
    hei[0] = max(hei[0]-1,0)
  if t[i] == "L":
    wid[0] += 1
  elif t[i] == "R":
    wid[1] -= 1
  elif t[i] == "U":
    hei[0] += 1
  elif t[i] == "D":
    hei[1] -= 1
  if wid[0]==wid[1] or hei[0]==hei[1]:
    print("NO")
    exit(0)
if hei[0] <= sc <= hei[1] and wid[0] <= sr <= wid[1]:
  print("YES")
else:
  print("NO")

# Fixed version:
h,w,n = map(int,input().split())
sr,sc = map(int,input().split())
t = input()
s = input()
hei = [1,h]
wid = [1,w]
for i in range(n-1,-1,-1):
  if s[i] == "L":
    wid[1] = min(wid[1]+1,w)
  elif s[i] == "R":
    wid[0] = max(wid[0]-1,1)
  elif s[i] == "U":
    hei[1] = min(hei[1]+1,h)
  elif s[i] == "D":
    hei[0] = max(hei[0]-1,1)
  if t[i] == "L":
    wid[0] += 1
  elif t[i] == "R":
    wid[1] -= 1
  elif t[i] == "U":
    hei[0] += 1
  elif t[i] == "D":
    hei[1] -= 1
  if wid[0]>wid[1] or hei[0]>hei[1]:
    print("NO")
    exit(0)
if hei[0] <= sr <= hei[1] and wid[0] <= sc <= wid[1]:
  print("YES")
else:
  print("NO")

# Buggy version:
h,w,n=map(int,input().split())
sr,sc=map(int,input().split())
s=input()[::-1]
t=input()[::-1]
l,r,u,d=0,w+1,0,h+1
for i in range(n):
 si,ti=s[i],t[i]
 if l>r or u>d:break
 r=min(w+1,r+1)if ti=="L"else r
 l=max(0,l-1)if ti=="R"else l
 d=min(h+1,d+1)if ti=="U"else d
 u=max(0,u-1)if ti=="D"else u
 r-=1 if si=="R"else 0
 l+=1 if si=="L"else 0
 d-=1 if si=="D"else 0
 u+=1 if si=="U"else 0
print("YES"if l<sc<r and u<sr<d else"NO")

# Fixed version:
h, w, n = map(int, input().split())
sr, sc = map(int, input().split())
s = input()
t = input()
l, u = 1, 1
r = w
d = h
for i in range(n-1, -1, -1):
    if t[i] == 'L':
        r = min(w, r+1)
    if t[i] == 'R':
        l = max(1, l-1)
    if t[i] == 'U':
        d = min(h, d+1)
    if t[i] == 'D':
        u = max(1, u-1)
    if s[i] == 'L':
        l += 1
    if s[i] == 'R':
        r -= 1
    if s[i] == 'U':
        u += 1
    if s[i] == 'D':
        d -= 1
    if l > r or u > d:
        print("NO")
        quit()
print("YES" if l<=sc<=r and u<=sr<=d else "NO")

# Buggy version:
import sys

H, W, N = map(int, input().split())
s_r, s_c = map(int, input().split())
S = input()
T = input()

# vertical direction
up, down = 0, H-1
for i in range(H, -1, -1):
    if T[i] == 'U':
        down = min(H, down + 1)
    elif T[i] == 'D':
        up = max(0, up - 1)
    
    if S[i] == 'U':
        up += 1
    elif S[i] == 'D':
        down -= 1
    
    if up >= down:
        print('NO')
        sys.exit()
        
# horizontal direction
left, right = 0, W-1
for j in range(W-1, -1, -1):    
    if T[j] == 'L':
        right = min(H, right + 1)
    elif T[j] == 'R':
        left = max(0, left - 1)
    
    if S[j] == 'L':
        left += 1
    elif S[j] == 'R':
        right -= 1
    
    if left >= right:
        print('NO')
        sys.exit()
if up <= s_r <= down and left <= s_c <= right:
    print('YES')
else:
    print('NO')

# Fixed version:
H, W, N = map(int, input().split())
s_r, s_c = map(int, input().split())
S = input()
T = input()

# vertical direction
up, down = 0, H-1
for i in range(N-1, -1, -1):
    if T[i] == 'U':
        down = min(H-1, down + 1)
    elif T[i] == 'D':
        up = max(0, up - 1)
    
    if S[i] == 'U':
        up += 1
    elif S[i] == 'D':
        down -= 1
    
    if up > down:
        print('NO')
        exit()
        
# horizontal direction
left, right = 0, W-1
for i in range(N-1, -1, -1):    
    if T[i] == 'L':
        right = min(W-1, right + 1)
    elif T[i] == 'R':
        left = max(0, left - 1)
    
    if S[i] == 'L':
        left += 1
    elif S[i] == 'R':
        right -= 1
    
    if left > right:
        print('NO')
        exit()
if up <= s_r-1 <=down and left <= s_c-1 <= right:
    print('YES')
else:
    print('NO')

# Buggy version:
H,W,N = map(int,input().split())
sr,sc = map(int,input().split())
S = input()
T = input()

L = 0
R = W+1
U = 0
D = H+1

for i in range(N-1,-1,-1):
    if S[i] == "L":
        L += 1
    elif S[i] == "R":
        R -= 1
    elif S[i] == "U":
        U += 1
    elif S[i] == "D":
        D -= 1
    if L+1==R or U+1==D:
        print("NO")
        break

    if i>0:
        if T[i-1] == "L":
            R += 1
        elif T[i-1] == "R":
            L -= 1
        elif T[i-1] == "U":
            D += 1
        elif T[i-1] == "D":
            U -= 1
else:
    if sr<=U or D<=sr or sc<=L or R<=sc:
        print("NO")
    else:
        print("YES")


# Fixed version:
H,W,N = map(int,input().split())
sr,sc = map(int,input().split())
S = input()
T = input()

L = 0
R = W+1
U = 0
D = H+1

for i in range(N-1,-1,-1):
    if S[i] == "L":
        L += 1
    elif S[i] == "R":
        R -= 1
    elif S[i] == "U":
        U += 1
    elif S[i] == "D":
        D -= 1
    if L+1==R or U+1==D:
        print("NO")
        break

    if i>0:
        if T[i-1] == "L":
            R = min(W+1,R+1)
        elif T[i-1] == "R":
            L = max(0,L-1)
        elif T[i-1] == "U":
            D = min(H+1,D+1)
        elif T[i-1] == "D":
            U = max(0,U-1)
else:
    if sr<=U or D<=sr or sc<=L or R<=sc:
        print("NO")
    else:
        print("YES")

# Buggy version:
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()
l = 0
r = W+1
u = 0
d = H+1
flag = True
for s,t in zip(S[::-1],T[::-1]):
    if l+1==r or u+1==d:
        flag=False
        break
    if t == 'L':
        r = min(0, r-1)
    if t == 'R':
        l = max(W+1, l+1)
    if t == 'U':
        d = min(0, d-1)
    if t == 'D':
        u = max(H+1, u+1)
    if s == 'L':
        l += 1
    if s == 'R':
        r -= 1
    if s == 'U':
        u += 1
    if s == 'D':
        d -= 1
if not(l < sc < r and u < sr < d):
    flag = False
if flag:
    print('YES')
else:
    print('NO')

# Fixed version:
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()
l = 0
r = W+1
u = 0
d = H+1
flag = True
for s,t in zip(S[::-1],T[::-1]):
    if l+1==r or u+1==d:
        flag=False
        break
    if t == 'L':
        r = min(W+1, r+1)
    if t == 'R':
        l = max(0, l-1)
    if t == 'U':
        d = min(H+1, d+1)
    if t == 'D':
        u = max(0, u-1)
    if s == 'L':
        l += 1
    if s == 'R':
        r -= 1
    if s == 'U':
        u += 1
    if s == 'D':
        d -= 1
if not(l < sc < r and u < sr < d):
    flag = False
if flag:
    print('YES')
else:
    print('NO')

# Buggy version:
h, w, n = map(int, input().split())
sr, sc = map(int, input().split())
s = list(input())
t = list(input())
r, l, u, d = sr, 1, sc, 1
ns = list(range(n))
for i in ns[::-1]:
    if t[i] == 'L':
        r += 1
    elif t[i] == 'R':
        l -= 1
    elif t[i] == 'U':
        u += 1
    elif t[i] == 'D':
        d -= 1
    if s[i] == 'L':
        l += 1
    elif s[i] == 'R':
        r -= 1
    elif s[i] == 'U':
        d += 1
    elif s[i] == 'D':
        u -= 1
    if (l > r) or (u > d):
        ans = 'NO'
        break
if (l <= w <= r) and (u <= h <= d):
    ans = 'YES'
else:
    ans = 'NO'
print(ans)

# Fixed version:
h, w, n = map(int, input().split())
sr, sc = map(int, input().split())
s = list(input())
t = list(input())
r, l, u, d = w, 1, 1, h
ns = list(range(n))
for i in ns[::-1]:
    if t[i] == 'L' and r < w:
        r += 1
    elif t[i] == 'R' and l > 1:
        l -= 1
    elif t[i] == 'U' and d < h:
        d += 1
    elif t[i] == 'D' and u > 1:
        u -= 1
    if s[i] == 'L':
        l += 1
    elif s[i] == 'R':
        r -= 1
    elif s[i] == 'U':
        u += 1
    elif s[i] == 'D':
        d -= 1
    if (l > r) or (u > d):
        ans = 'NO'
        break
if (l <= sc <= r) and (u <= sr <= d):
    ans = 'YES'
else:
    ans = 'NO'
print(ans)

# Buggy version:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

H,W,N=map(int,input().split())

sr,sc=map(int,input().split())
S=input()[:-1]
T=input()[:-1]

left=0
right=W+1
up=0
down=H+1

ans="YES"
for i,(s,t) in enumerate(zip(reversed(S),reversed(T))):
    if i!=0:
        if t=='R':
            left=max(0,left-1)
        elif t=="L":
            right=min(W+1,right+1)
        elif t=="D":
            up = max(0,up-1)
        else:
            down=min(H+1,down+1)


    if s=="R":
        right-=1
    elif s=="L":
        left+=1
    elif s=="D":
        down-=1
    else:
        up+=1

    if right-left==1 or down-upp==1:
        ans="NO"
        break

if not left<sc<right or not up<sr<down:
    ans="NO"
print(ans)


# Fixed version:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

H,W,N=map(int,input().split())

sr,sc=map(int,input().split())
S=input()[:-1]
T=input()[:-1]

left=0
right=W+1
up=0
down=H+1

ans="YES"
for i,(s,t) in enumerate(zip(reversed(S),reversed(T))):
    if i!=0:
        if t=='R':
            left=max(0,left-1)
        elif t=="L":
            right=min(W+1,right+1)
        elif t=="D":
            up = max(0,up-1)
        else:
            down=min(H+1,down+1)


    if s=="R":
        right-=1
    elif s=="L":
        left+=1
    elif s=="D":
        down-=1
    else:
        up+=1

    if right-left==1 or down-up==1:
        ans="NO"
        break

if not left<sc<right or not up<sr<down:
    ans="NO"
print(ans)

# Buggy version:
import sys

input = sys.stdin.readline


def main():
    h, w, n = map(int, input().split())
    y, x = map(int, input().split())
    y -= 1
    x -= 1
    s, t = input(), input()

    u, d, l, r = 0, h - 1, 0, w - 1

    for ss, tt in zip(s[::-1], t[::-1]):
        if tt == 'U':
            d = min(d + 1, h - 1)
        elif tt == 'D':
            u = max(u - 1, 0)
        elif tt == 'L':
            r = min(r + 1, w - 1)
        else:
            l = max(l - 1, 0)  # tt == 'R'

        if ss == 'U':
            u += 1
        elif ss == 'D':
            d -= 1
        elif ss == 'L':
            l += 1
        else:
            r -= 1  # ss == 'R'

        if l > r or u > d:
            print('NO')
            return

    if l <= x <= r and u <= y <= d:
        print('YES')
        return
    else:
        print('NO')
        return


if __name__ == '__main__':
    main()

# Fixed version:
def main():
    h, w, n = map(int, input().split())
    y, x = map(int, input().split())
    y -= 1
    x -= 1
    s, t = input(), input()

    u, d, l, r = 0, h - 1, 0, w - 1

    for ss, tt in zip(s[::-1], t[::-1]):
        if tt == 'U':
            d = min(d + 1, h - 1)
        elif tt == 'D':
            u = max(u - 1, 0)
        elif tt == 'L':
            r = min(r + 1, w - 1)
        else:
            l = max(l - 1, 0)  # tt == 'R'

        if ss == 'U':
            u += 1
        elif ss == 'D':
            d -= 1
        elif ss == 'L':
            l += 1
        else:
            r -= 1  # ss == 'R'

        if l > r or u > d:
            print('NO')
            return

    if l <= x <= r and u <= y <= d:
        print('YES')
        return
    else:
        print('NO')
        return


if __name__ == '__main__':
    main()

# Buggy version:
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()

left = 0
right = W
up = 0
down = H

for i in reversed(range(N)):
    if i != N - 1:
        if T[i] == "U":
            if down != H:
                down -= 1
        elif T[i] == "D":
            if up != 0:
                up += 1
        elif T[i] == "L":
            if right != W:
                right += 1
        else:
            if left != 0:
                left -= 1
    if S[i] == "U":
        up += 1
    elif S[i] == "D":
        down -= 1
    elif S[i] == "L":
        left += 1
    else:
        right -= 1
    if left > right or up > down:
        print("NO")
        exit()
#print(left, right)
#print(up, down)
if left <= sr <= right and up <= sc <= down:
    print("YES")
else:
    print("NO")


# Fixed version:
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()

left = 1
right = W
up = 1
down = H

for i in reversed(range(N)):
    if T[i] == "U":
        down = min(H, down+1)
    elif T[i] == "D":
        up = max(1, up-1)
    elif T[i] == "L":
        right = min(W, right+1)
    else:
        left = max(1, left-1)

    if S[i] == "U":
        up += 1
    elif S[i] == "D":
        down -= 1
    elif S[i] == "L":
        left += 1
    else:
        right -= 1

    #print(left, right, " ", up, down)

    if left > right or up > down:
        print("NO")
        exit()

#print(left, right)
#print(up, down)
if left <= sc <= right and up <= sr <= down:
    print("YES")
else:
    print("NO")

# Buggy version:
H,W,N = map(int, input().split())
sr,sc = map(int, input().split())
S = input()
T = input()

left, right = 0, W+1
if S[-1] == "R":
    right -= 1
elif S[-1] == "L":
    left += 1
for i in reversed(range(N-1)):
    si, ti = S[i], T[i]
    if ti == "R":
        left -= 1
    elif ti == "L":
        right += 1
    left = max(0, left)
    right = min(W+1, right)

    if si == "R":
        right -= 1
    elif si == "L":
        left += 1

    if right - left == 1:
        print("NO")
        exit()

if sc <= left or right <= sc:
    print("NO")
    exit()


left, right = 0, H+1
if S[-1] == "U":
    left += 1
elif S[-1] == "D":
    right -= 1

for i in reversed(range(N-1)):
    si, ti = S[i], T[i]
    if ti == "D":
        left -= 1
    elif ti == "U":
        right += 1
    down = max(0, down)
    up = min(H+1, up)

    if si == "D":
        right -= 1
    elif si == "":
        left += 1

    if right - left == 1:
        print("NO")
        exit()

if sr <= left or right <= sr:
    print("NO")
    exit()

print("YES")


# Fixed version:
H,W,N = map(int, input().split())
sr,sc = map(int, input().split())
S = input()
T = input()

left, right = 0, W+1
if S[-1] == "R":
    right -= 1
elif S[-1] == "L":
    left += 1
for i in reversed(range(N-1)):
    si, ti = S[i], T[i]
    if ti == "R":
        left -= 1
    elif ti == "L":
        right += 1
    left = max(0, left)
    right = min(W+1, right)

    if si == "R":
        right -= 1
    elif si == "L":
        left += 1

    if right - left == 1:
        print("NO")
        exit()

if sc <= left or right <= sc:
    print("NO")
    exit()


left, right = 0, H+1
if S[-1] == "U":
    left += 1
elif S[-1] == "D":
    right -= 1

for i in reversed(range(N-1)):
    si, ti = S[i], T[i]
    if ti == "D":
        left -= 1
    elif ti == "U":
        right += 1
    left = max(0, left)
    right = min(H+1, right)

    if si == "D":
        right -= 1
    elif si == "U":
        left += 1

    if right - left == 1:
        print("NO")
        exit()

if sr <= left or right <= sr:
    print("NO")
    exit()

print("YES")

# Buggy version:
H,W,N = map(int, input().split())
st = [int(i) for i in input().split()]
S = input()
T = input()


def simu(dim1):
    now = [st[0],st[1]]

    if dim1 == 'U':
        dim2,L,step,dim = 'D',H,-1,0
    if dim1 == 'D':
        dim2,L,step,dim = 'U',H,1,0
    if dim1 == 'R':
        dim2,L,step,dim = 'L',W,1,1
    if dim1 == 'L':
        dim2,L,step,dim = 'R',W,-1,1

    for i in range(N):
        if S[i] == dim1:
            now[dim] -= step
        if now[dim] < 1 or now[dim] >= L+1:
            return True
        if T[i] == dim2:
            if step == -1:
                if now[dim] < L:
                    now[dim] += step
            else:
                if now[dim] > 0:
                    now[dim] += step
        
D = ['U','D','R','L']
for d in D:
    if simu(d):
        print('YES')
        exit()
print('NO')

# Fixed version:
H,W,N = map(int, input().split())
st = [int(i) for i in input().split()]
S = input()
T = input()


def simu(dim1):
    now = [st[0],st[1]]

    if dim1 == 'U':
        dim2,L,step,dim = 'D',H,1,0
    if dim1 == 'D':
        dim2,L,step,dim = 'U',H,-1,0
    if dim1 == 'L':
        dim2,L,step,dim = 'R',W,1,1
    if dim1 == 'R':
        dim2,L,step,dim = 'L',W,-1,1

    for i in range(N):
        if S[i] == dim1:
            now[dim] -= step
        if now[dim] < 1 or now[dim] >= L+1:
            return True
        if T[i] == dim2:
            if step == 1:
                if now[dim] < L:
                    now[dim] += step
            else:
                if now[dim] > 1:
                    now[dim] += step
    return False
        
Dim = ['U','D','R','L']
for d in Dim:
    if simu(d):
        print('NO')
        exit()
print('YES')

# Buggy version:
h, w, n = map(int, input().split())
sr, sc = map(int, input().split())
s = input()
t = input()
sr -= 1; sc -= 1
 
L=0; R=w-1; U=0; D=h-1;
is_drop = False
for i in range(n)[::-1]:
    if t[i] == 'U': D = min(D+1, h-1)
    if t[i] == 'D': U = max(U-1, 0)
    if t[i] == 'L': R = min(R+1, w-1)
    if t[i] == 'R': L = max(L-1, 0)
    if s[i] == 'U': U++
    if s[i] == 'D': D--
    if s[i] == 'L': L++
    if s[i] == 'R': R--
    if R < L or D < U: is_drop = True
    if (not L <= sc <= R) or (not U <= sr <= D):  is_drop = True

print( "NO" if is_drop else "YES" )


# Fixed version:
h, w, n = map(int, input().split())
sr, sc = map(int, input().split())
s = input()
t = input()
sr -= 1; sc -= 1
 
L=0; R=w-1; U=0; D=h-1;
is_drop = False
for i in range(n)[::-1]:
    if t[i] == 'U': D = min(D+1, h-1)
    if t[i] == 'D': U = max(U-1, 0)
    if t[i] == 'L': R = min(R+1, w-1)
    if t[i] == 'R': L = max(L-1, 0)
    if s[i] == 'U': U += 1
    if s[i] == 'D': D -= 1
    if s[i] == 'L': L += 1
    if s[i] == 'R': R -= 1
    if R < L or D < U: is_drop = True
if (not L <= sc <= R) or (not U <= sr <= D):  is_drop = True

print( "NO" if is_drop else "YES" )

# Buggy version:
#!/usr/bin/env python3
H, W, N = map(int, input().split())
sr, sc = map(lambda x: int(x) - 1, input().split())
S = input()
T = input()
l, r = 0, W
u, d = 0, H
for i in range(N)[::-1]:
    if T[i] == 'L': r = min(W, r + 1)
    if T[i] == 'R': l = max(0, l - 1)
    if T[i] == 'U': d = min(H, d + 1)
    if T[i] == 'D': u = max(0, u - 1)
    if S[i] == 'L': l += 1
    if S[i] == 'R': r -= 1
    if S[i] == 'U': u += 1
    if S[i] == 'D': d -= 1
    if l == r or u == d:
        print("NO")
        exit()

print("YES")



# Fixed version:
#!/usr/bin/env python3
H, W, N = map(int, input().split())
sr, sc = map(lambda x: int(x) - 1, input().split())
S = input()
T = input()
l, r = 0, W
u, d = 0, H
for i in range(N)[::-1]:
    if T[i] == 'L': r = min(W, r + 1)
    if T[i] == 'R': l = max(0, l - 1)
    if T[i] == 'U': d = min(H, d + 1)
    if T[i] == 'D': u = max(0, u - 1)
    if S[i] == 'L': l += 1
    if S[i] == 'R': r -= 1
    if S[i] == 'U': u += 1
    if S[i] == 'D': d -= 1
    if l == r or u == d: 
        print("NO")
        exit()

print(("NO", "YES")[l <= sc < r and u <= sr < d])

# Buggy version:
h, w, n = map(int, input().split())
ar, ac = map(int, input().split())
s = input()
t = input()
r = ac
l = ac
u = ar
d = ar

for i in range(n):
    if s[i] == "R":
        r += 1
    if s[i] == "L":
        l -= 1
    if s[i] == "U":
        u -= 1
    if s[i] == "D":
        d += 1
    if l==0 or r==w+1 or u==0 or d==h+1:
        print("NO")
        ans = True
        break
        
    if t[i] == "R" and l != w:
        l += 1
    if t[i] == "L" and r != 1:
        r -= 1
    if t[i] == "U" and d != 1:
        d -= 1
    if t[i] == "D" and u != h:
        u += 1
 
if ans != True:
    print("YES")

# Fixed version:
h, w, n = map(int, input().split())
ar, ac = map(int, input().split())
s = input()
t = input()
r = ac
l = ac
u = ar
d = ar
ans = False

for i in range(n):
    if s[i] == "R":
        r += 1
    if s[i] == "L":
        l -= 1
    if s[i] == "U":
        u -= 1
    if s[i] == "D":
        d += 1
    if l==0 or r==w+1 or u==0 or d==h+1:
        print("NO")
        ans = True
        break
        
    if t[i] == "R" and l != w:
        l += 1
    if t[i] == "L" and r != 1:
        r -= 1
    if t[i] == "U" and d != 1:
        d -= 1
    if t[i] == "D" and u != h:
        u += 1
 
if ans != True:
    print("YES")

# Buggy version:
H,W,N=map(int,input().split())
sr,sc=map(int,input().split())
S=input()
T=input()

lu=H-sr
ld=sr-1
ll=W-sc
lr=sc-1

for i in range(N):
  x=S[i]
  y=T[i]

  if x=='U':
    lu-=1
  elif x=='D':
    ld-=1
  elif x=='L':
    ll-=1
  elif x=='R':
    lr-=1

  # print(lu,ld,ll,lr)

  if lu<0 or ld<0 or ll<0 or lr<0:
    print('NO')
    exit()

  if y=='U':
    ld+=1
  elif y=='D':
    lu+=1
  elif y=='L':
    lr+=1
  elif y=='R':
    ll+=1

  # print(lu,ld,ll,lr)

print('YES')

# Fixed version:
H,W,N=map(int,input().split())
sr,sc=map(int,input().split())
S=input()
T=input()

ld=H-sr
lu=sr-1
lr=W-sc
ll=sc-1

for i in range(N):
  x=S[i]
  y=T[i]

  if x=='U':
    lu-=1
  elif x=='D':
    ld-=1
  elif x=='L':
    ll-=1
  elif x=='R':
    lr-=1

  # print(lu,ld,ll,lr)

  if lu<0 or ld<0 or ll<0 or lr<0:
    print('NO')
    exit()

  if y=='U' and ld<H-1:
    ld+=1
  elif y=='D' and lu<H-1:
    lu+=1
  elif y=='L' and lr<W-1:
    lr+=1
  elif y=='R' and ll<W-1:
    ll+=1

  # print(lu,ld,ll,lr)

print('YES')

# Buggy version:
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

h,w,n = na()
sh,sw = na()
s = ns()
t = ns()

iit = [sw,sh,h-sh+1,w-sw+1]

print(iit)
#ludr
tshi = [0,0,0,0]
aoki = [0,0,0,0]

for i in range(n):
    if s[i] == 'L':
        tshi[0] += 1
    if s[i] == 'U':
        tshi[1] += 1
    if s[i] == 'D':
        tshi[2] += 1
    if s[i] == 'R':
        tshi[3] += 1
    print(tshi)
    print(aoki)
    for j in range(4):
        if tshi[j] >= iit[j]+aoki[3-j]:
            print('NO')
            exit()
    if t[i] == 'L':
        aoki[0] += 1
    if t[i] == 'U':
        aoki[1] += 1
    if t[i] == 'D':
        aoki[2] += 1
    if t[i] == 'R':
        aoki[3] += 1
    for j in range(4):
        if aoki[j] >= iit[j]+tshi[3-j]:
            aoki[j] -= 1

print('YES')

# Fixed version:
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

h,w,n = na()
sh,sw = na()
s = ns()
t = ns()

iit = [sw,sh,h-sh+1,w-sw+1]

#ludr
tshi = [0,0,0,0]
aoki = [0,0,0,0]

for i in range(n):
    if s[i] == 'L':
        tshi[0] += 1
    if s[i] == 'U':
        tshi[1] += 1
    if s[i] == 'D':
        tshi[2] += 1
    if s[i] == 'R':
        tshi[3] += 1
    for j in range(4):
        if tshi[j] >= iit[j]+aoki[3-j]:
            print('NO')
            exit()
    if t[i] == 'L':
        aoki[0] += 1
    if t[i] == 'U':
        aoki[1] += 1
    if t[i] == 'D':
        aoki[2] += 1
    if t[i] == 'R':
        aoki[3] += 1
    for j in range(4):
        if aoki[j] >= iit[j]+tshi[3-j]:
            aoki[j] -= 1

print('YES')

# Buggy version:
h, w, n = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()
win = 0

SR = sr
SC = sc
sr = SR
sc = SC
for i in range(n):
    if S[i] == "L":
        sc -= 1
    if sc <= 0:
        break
    if T[i] == "R" and sc < w:
        sc += 1
if sc <= 0:
    win = 1


sr = SR
sc = SC
for i in range(n):
    if S[i] == "R":
        sc += 1
    if sc > w:
        break
    if T[i] == "L" and sc > 1:
        sc -= 1
if sc > w:
    win = 1


sr = SR
sc = SC
for i in range(n):
    if S[i] == "D":
        sr += 1
    if sr > h:
        break
    if T[i] == "U" and sr > 1:
        sr -= 1
if sr > h:
    win = 1


sr = SR
sc = SC
for i in range(n):
    if S[i] == "U":
        sr -= 1
    if sr <= 0:
        break
    if T[i] == "D" and sr < h:
        sr += 1
if sr <= 0:
    win = 1

if win:
    print("No")
else:
    print("Yes")

# Fixed version:
h, w, n = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()
win = 0

SR = sr
SC = sc
sr = SR
sc = SC
for i in range(n):
    if S[i] == "L":
        sc -= 1
    if sc <= 0:
        break
    if T[i] == "R" and sc < w:
        sc += 1
if sc <= 0:
    win = 1


sr = SR
sc = SC
for i in range(n):
    if S[i] == "R":
        sc += 1
    if sc > w:
        break
    if T[i] == "L" and sc > 1:
        sc -= 1
if sc > w:
    win = 1


sr = SR
sc = SC
for i in range(n):
    if S[i] == "D":
        sr += 1
    if sr > h:
        break
    if T[i] == "U" and sr > 1:
        sr -= 1
if sr > h:
    win = 1


sr = SR
sc = SC
for i in range(n):
    if S[i] == "U":
        sr -= 1
    if sr <= 0:
        break
    if T[i] == "D" and sr < h:
        sr += 1
if sr <= 0:
    win = 1

if win:
    print("NO")
else:
    print("YES")

# Buggy version:
from sys import exit
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()
ul = 1
dl = H
rl = W
ll = 1
for s, t in zip(S[1::][::-1], T[::-1]):
    if t == 'U':
        dl = min(H, dl+1)
    elif t == 'D':
        ul = max(1, ul-1)
    elif t == 'L':
        rl = min(W, rl+1)
    else:
        ll = max(1, ll-1)
    if s == 'U':
        ul += 1
    elif s == 'D':
        dl -= 1
    elif s == 'L':
        ll += 1
    else:
        rl -= 1
    if ul > dl or ll > rl or ul == H + 1 or dl == 0 or ll == W + 1 or rl == 0:
        print('NO')
        exit()
s = S[0]
if s == 'U':
    ul += 1
elif s == 'D':
    dl -= 1
elif s == 'L':
    ll += 1
else:
    rl -= 1

if ul <= sr <= dl and ll <= sc <= rl:
    print('YES')
else:
    print('NO')

# Fixed version:
from sys import exit
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()
ul = 1
dl = H
rl = W
ll = 1
for s, t in zip(S[1::][::-1], T[:-1:][::-1]):
    if s == 'U':
        ul += 1
    elif s == 'D':
        dl -= 1
    elif s == 'L':
        ll += 1
    else:
        rl -= 1
    if ul > dl or ll > rl or ul == H + 1 or dl == 0 or ll == W + 1 or rl == 0:
        print('NO')
        exit()
    if t == 'U':
        dl = min(H, dl+1)
    elif t == 'D':
        ul = max(1, ul-1)
    elif t == 'L':
        rl = min(W, rl+1)
    else:
        ll = max(1, ll-1)
s = S[0]
if s == 'U':
    ul += 1
elif s == 'D':
    dl -= 1
elif s == 'L':
    ll += 1
else:
    rl -= 1

if ul <= sr <= dl and ll <= sc <= rl:
    print('YES')
else:
    print('NO')

# Buggy version:
H, W, N = map(int, input().split())
Sr, Sc = map(int, input().split())
S = input()
T = input()


l = 1
r = W
u = 1
d = H
for s, t in zip(S[::-1], T[::-1]):

    if t=="L":
        r = min(r+1, W)
    elif t=="R":
        l = max(l-1, 1)
    elif t=="U":
        d = min(d+1, W)
    else:
        u = max(u-1, 1)

    if s=="L":
        l+=1
    elif s=="R":
        r-=1
    elif s=="U":
        u+=1
    else:
        d-=1

    if l > r or u > d:
        print("NO")
        exit()
    #print(l, r, u, d)
if d<=Sr<=u and l<=Sc<=r:
    print("YES")
else:
    print("NO")


# Fixed version:
H, W, N = map(int, input().split())
Sr, Sc = map(int, input().split())
S = input()
T = input()


l = 1
r = W
u = 1
d = H
#print(l, r, u, d,)
for s, t in zip(S[::-1], T[::-1]):

    if t=="L":
        r = min(r+1, W)
    elif t=="R":
        l = max(l-1, 1)
    elif t=="U":
        d = min(d+1, H)
    else:
        u = max(u-1, 1)

    #print(d)
    if s=="L":
        l+=1
    elif s=="R":
        r-=1
    elif s=="U":
        u+=1
    else:
        d-=1

    if l > r or u > d:
        print("NO")
        exit()
    #print(l, r, u, d, " st", s, t)
if u<=Sr<=d and l<=Sc<=r:
    print("YES")
else:
    print("NO")

# Buggy version:
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()

flag = 0
hidari = sc
migi = sc
ue = sr
shita = sr
for i in range(N):
  print(hidari,migi,ue,shita)
  if S[i] == 'L':
    hidari -= 1
  if S[i] == 'R':
    migi += 1
  if S[i] == 'U':
    ue -= 1
  if S[i] == 'D':
    shita += 1
  if hidari == 0 or migi == W+1 or ue == H+1 or shita == 0:
    flag = 1
  
  print(hidari,migi,ue,shita)
  if T[i] == 'R' and hidari != W:
    hidari += 1
  if T[i] == 'L' and migi != 0:
    migi -= 1
  if T[i] == 'D' and ue != 0:
    ue += 1
  if T[i] == 'U' and shita != H:
    shita -= 1

if flag :
  print("NO")
else :
  print("YES")
  

# Fixed version:
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()

flag = 0
hidari = sc
migi = sc
ue = sr
shita = sr
for i in range(N):
  if S[i] == 'L':
    hidari -= 1
  if S[i] == 'R':
    migi += 1
  if S[i] == 'U':
    ue -= 1
  if S[i] == 'D':
    shita += 1
  if hidari == 0 or migi == W+1 or ue == 0 or shita == H+1 :
    flag = 1
  
  if T[i] == 'R' and hidari != W:
    hidari += 1
  if T[i] == 'L' and migi != 1:
    migi -= 1
  if T[i] == 'D' and ue != H:
    ue += 1
  if T[i] == 'U' and shita != 1:
    shita -= 1

if flag :
  print("NO")
else :
  print("YES")