Buggy python submission (verdict: Time Limit Exceeded):
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/agc033/tasks/agc033_b
# B - LRUD Game
"""
"""
H = gi()
W = gi()
N = gi()
sr = gi()
sc = gi()
S = gw()
T = gw()
d_to_i = {"L": 0, "R": 1, "U": 2, "D": 3}
cnt = [[0 for x in range(4)] for i in range(2)]


def o(pos, si, ti, d, sb, tb):
    for i in range(N):
        if (d_to_i[S[i]] == si):
            pos += d
            if pos == sb:
                return 1
        if (d_to_i[T[i]] == ti):
            if (pos - d != tb):
                pos -= d
    return 0


off = 0
for i in range(N):
    #  print(cnt)
    off = o(sc, 0, 1, -1, 0, W + 1)
    off = off or o(sc, 1, 0, 1, W + 1, 0)
    off = off or o(sr, 2, 3, -1, 0, H + 1)
    off = off or o(sr, 3, 2, 1, H + 1, 0)

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


Fixed submission:
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/agc033/tasks/agc033_b
# B - LRUD Game
"""
"""
H = gi()
W = gi()
N = gi()
sr = gi()
sc = gi()
S = gw()
T = gw()
d_to_i = {"L": 0, "R": 1, "U": 2, "D": 3}
cnt = [[0 for x in range(4)] for i in range(2)]


def o(pos, si, ti, d, sb, tb):
    for i in range(N):
        if (d_to_i[S[i]] == si):
            pos += d
            if pos == sb:
                return 1
        if (d_to_i[T[i]] == ti):
            if (pos - d != tb):
                pos -= d
    return 0


off = 0
#  print(cnt)
off = o(sc, 0, 1, -1, 0, W + 1)
off = off or o(sc, 1, 0, 1, W + 1, 0)
off = off or o(sr, 2, 3, -1, 0, H + 1)
off = off or o(sr, 3, 2, 1, H + 1, 0)

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

Buggy python submission (verdict: Time Limit Exceeded):
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/agc033/tasks/agc033_b
# B - LRUD Game
"""
"""
H = gi()
W = gi()
N = gi()
sr = gi()
sc = gi()
S = gw()
T = gw()
d_to_i = {"L": 0, "R": 1, "U": 2, "D": 3}
cnt = [[0 for x in range(4)] for i in range(2)]


def o(pos, si, ti, d, sb, tb):
    for i in range(N):
        if (d_to_i[S[i]] == si):
            pos += d
            if pos == sb:
                return 1
        if (d_to_i[T[i]] == ti):
            if (pos - d != tb):
                pos -= d
    return 0


off = 0
for i in range(N):
    #  print(cnt)
    off = o(sc, 0, 1, -1, 0, W + 1)
    off = off or o(sc, 1, 0, 1, W + 1, 0)
    off = off or o(sr, 2, 3, -1, 0, H + 1)
    off = off or o(sr, 3, 2, 1, H + 1, 0)

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


Fixed submission:
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/agc033/tasks/agc033_b
# B - LRUD Game
"""
"""
H = gi()
W = gi()
N = gi()
sr = gi()
sc = gi()
S = gw()
T = gw()
d_to_i = {"L": 0, "R": 1, "U": 2, "D": 3}
cnt = [[0 for x in range(4)] for i in range(2)]


def o(pos, si, ti, d, sb, tb):
    for i in range(N):
        if (d_to_i[S[i]] == si):
            pos += d
            if pos == sb:
                return 1
        if (d_to_i[T[i]] == ti):
            if (pos - d != tb):
                pos -= d
    return 0


off = 0
#  print(cnt)
off = o(sc, 0, 1, -1, 0, W + 1)
off = off or o(sc, 1, 0, 1, W + 1, 0)
off = off or o(sr, 2, 3, -1, 0, H + 1)
off = off or o(sr, 3, 2, 1, H + 1, 0)

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